Mercurial > hg > truffle
comparison src/share/vm/runtime/os.cpp @ 12144:d8e99408faad
8009062: poor performance of JNI AttachCurrentThread after fix for 7017193
Summary: don't re-evaluate stack bounds for main thread before install guard page
Reviewed-by: coleenp, dholmes, dlong
author | dsamersoff |
---|---|
date | Thu, 29 Aug 2013 21:48:23 +0400 |
parents | 5e3b6f79d280 |
children | c636758ea616 |
comparison
equal
deleted
inserted
replaced
12142:76482cbba706 | 12144:d8e99408faad |
---|---|
1422 } | 1422 } |
1423 } | 1423 } |
1424 return result; | 1424 return result; |
1425 } | 1425 } |
1426 | 1426 |
1427 // Read file line by line, if line is longer than bsize, | |
1428 // skip rest of line. | |
1429 int os::get_line_chars(int fd, char* buf, const size_t bsize){ | |
1430 size_t sz, i = 0; | |
1431 | |
1432 // read until EOF, EOL or buf is full | |
1433 while ((sz = (int) read(fd, &buf[i], 1)) == 1 && i < (bsize-2) && buf[i] != '\n') { | |
1434 ++i; | |
1435 } | |
1436 | |
1437 if (buf[i] == '\n') { | |
1438 // EOL reached so ignore EOL character and return | |
1439 | |
1440 buf[i] = 0; | |
1441 return (int) i; | |
1442 } | |
1443 | |
1444 buf[i+1] = 0; | |
1445 | |
1446 if (sz != 1) { | |
1447 // EOF reached. if we read chars before EOF return them and | |
1448 // return EOF on next call otherwise return EOF | |
1449 | |
1450 return (i == 0) ? -1 : (int) i; | |
1451 } | |
1452 | |
1453 // line is longer than size of buf, skip to EOL | |
1454 char ch; | |
1455 while (read(fd, &ch, 1) == 1 && ch != '\n') { | |
1456 // Do nothing | |
1457 } | |
1458 | |
1459 // return initial part of line that fits in buf. | |
1460 // If we reached EOF, it will be returned on next call. | |
1461 | |
1462 return (int) i; | |
1463 } | |
1464 | |
1465 void os::SuspendedThreadTask::run() { | 1427 void os::SuspendedThreadTask::run() { |
1466 assert(Threads_lock->owned_by_self() || (_thread == VMThread::vm_thread()), "must have threads lock to call this"); | 1428 assert(Threads_lock->owned_by_self() || (_thread == VMThread::vm_thread()), "must have threads lock to call this"); |
1467 internal_do_task(); | 1429 internal_do_task(); |
1468 _done = true; | 1430 _done = true; |
1469 } | 1431 } |