Mercurial > hg > graal-compiler
comparison src/share/vm/runtime/os.cpp @ 14422:2b8e28fdf503
Merge
author | kvn |
---|---|
date | Tue, 05 Nov 2013 17:38:04 -0800 |
parents | e2722a66aba7 179cd89fb279 |
children | abec000618bf f040cf9fc9c0 |
comparison
equal
deleted
inserted
replaced
14421:3068270ba476 | 14422:2b8e28fdf503 |
---|---|
312 } | 312 } |
313 } | 313 } |
314 } | 314 } |
315 } | 315 } |
316 | 316 |
317 void os::init_before_ergo() { | |
318 // We need to initialize large page support here because ergonomics takes some | |
319 // decisions depending on large page support and the calculated large page size. | |
320 large_page_init(); | |
321 } | |
317 | 322 |
318 void os::signal_init() { | 323 void os::signal_init() { |
319 if (!ReduceSignalUsage) { | 324 if (!ReduceSignalUsage) { |
320 // Setup JavaThread for processing signals | 325 // Setup JavaThread for processing signals |
321 EXCEPTION_MARK; | 326 EXCEPTION_MARK; |
452 * executable if agent_lib->is_static_lib() == true or in the shared library | 457 * executable if agent_lib->is_static_lib() == true or in the shared library |
453 * referenced by 'handle'. | 458 * referenced by 'handle'. |
454 */ | 459 */ |
455 void* os::find_agent_function(AgentLibrary *agent_lib, bool check_lib, | 460 void* os::find_agent_function(AgentLibrary *agent_lib, bool check_lib, |
456 const char *syms[], size_t syms_len) { | 461 const char *syms[], size_t syms_len) { |
462 assert(agent_lib != NULL, "sanity check"); | |
457 const char *lib_name; | 463 const char *lib_name; |
458 void *handle = agent_lib->os_lib(); | 464 void *handle = agent_lib->os_lib(); |
459 void *entryName = NULL; | 465 void *entryName = NULL; |
460 char *agent_function_name; | 466 char *agent_function_name; |
461 size_t i; | 467 size_t i; |
482 size_t syms_len) { | 488 size_t syms_len) { |
483 void *ret; | 489 void *ret; |
484 void *proc_handle; | 490 void *proc_handle; |
485 void *save_handle; | 491 void *save_handle; |
486 | 492 |
493 assert(agent_lib != NULL, "sanity check"); | |
487 if (agent_lib->name() == NULL) { | 494 if (agent_lib->name() == NULL) { |
488 return false; | 495 return false; |
489 } | 496 } |
490 proc_handle = get_default_process_handle(); | 497 proc_handle = get_default_process_handle(); |
491 // Check for Agent_OnLoad/Attach_lib_name function | 498 // Check for Agent_OnLoad/Attach_lib_name function |
492 save_handle = agent_lib->os_lib(); | 499 save_handle = agent_lib->os_lib(); |
493 // We want to look in this process' symbol table. | 500 // We want to look in this process' symbol table. |
494 agent_lib->set_os_lib(proc_handle); | 501 agent_lib->set_os_lib(proc_handle); |
495 ret = find_agent_function(agent_lib, true, syms, syms_len); | 502 ret = find_agent_function(agent_lib, true, syms, syms_len); |
496 agent_lib->set_os_lib(save_handle); | |
497 if (ret != NULL) { | 503 if (ret != NULL) { |
498 // Found an entry point like Agent_OnLoad_lib_name so we have a static agent | 504 // Found an entry point like Agent_OnLoad_lib_name so we have a static agent |
499 agent_lib->set_os_lib(proc_handle); | |
500 agent_lib->set_valid(); | 505 agent_lib->set_valid(); |
501 agent_lib->set_static_lib(true); | 506 agent_lib->set_static_lib(true); |
502 return true; | 507 return true; |
503 } | 508 } |
509 agent_lib->set_os_lib(save_handle); | |
504 return false; | 510 return false; |
505 } | 511 } |
506 | 512 |
507 // --------------------- heap allocation utilities --------------------- | 513 // --------------------- heap allocation utilities --------------------- |
508 | 514 |
1483 } | 1489 } |
1484 } | 1490 } |
1485 return result; | 1491 return result; |
1486 } | 1492 } |
1487 | 1493 |
1488 // Read file line by line, if line is longer than bsize, | |
1489 // skip rest of line. | |
1490 int os::get_line_chars(int fd, char* buf, const size_t bsize){ | |
1491 size_t sz, i = 0; | |
1492 | |
1493 // read until EOF, EOL or buf is full | |
1494 while ((sz = (int) read(fd, &buf[i], 1)) == 1 && i < (bsize-2) && buf[i] != '\n') { | |
1495 ++i; | |
1496 } | |
1497 | |
1498 if (buf[i] == '\n') { | |
1499 // EOL reached so ignore EOL character and return | |
1500 | |
1501 buf[i] = 0; | |
1502 return (int) i; | |
1503 } | |
1504 | |
1505 buf[i+1] = 0; | |
1506 | |
1507 if (sz != 1) { | |
1508 // EOF reached. if we read chars before EOF return them and | |
1509 // return EOF on next call otherwise return EOF | |
1510 | |
1511 return (i == 0) ? -1 : (int) i; | |
1512 } | |
1513 | |
1514 // line is longer than size of buf, skip to EOL | |
1515 char ch; | |
1516 while (read(fd, &ch, 1) == 1 && ch != '\n') { | |
1517 // Do nothing | |
1518 } | |
1519 | |
1520 // return initial part of line that fits in buf. | |
1521 // If we reached EOF, it will be returned on next call. | |
1522 | |
1523 return (int) i; | |
1524 } | |
1525 | |
1526 void os::SuspendedThreadTask::run() { | 1494 void os::SuspendedThreadTask::run() { |
1527 assert(Threads_lock->owned_by_self() || (_thread == VMThread::vm_thread()), "must have threads lock to call this"); | 1495 assert(Threads_lock->owned_by_self() || (_thread == VMThread::vm_thread()), "must have threads lock to call this"); |
1528 internal_do_task(); | 1496 internal_do_task(); |
1529 _done = true; | 1497 _done = true; |
1530 } | 1498 } |