248
249 switch (sig) {
250 case SIGBREAK: {
251 // Check if the signal is a trigger to start the Attach Listener - in that
252 // case don't print stack traces.
253 if (!DisableAttachMechanism && AttachListener::is_init_trigger()) {
254 continue;
255 }
256 // Print stack traces
257 // Any SIGBREAK operations added here should make sure to flush
258 // the output stream (e.g. tty->flush()) after output. See 4803766.
259 // Each module also prints an extra carriage return after its output.
260 VM_PrintThreads op;
261 VMThread::execute(&op);
262 VM_PrintJNI jni_op;
263 VMThread::execute(&jni_op);
264 VM_FindDeadlocks op1(tty);
265 VMThread::execute(&op1);
266 Universe::print_heap_at_SIGBREAK();
267 if (PrintClassHistogram) {
268 VM_GC_HeapInspection op1(gclog_or_tty, true /* force full GC before heap inspection */,
269 true /* need_prologue */);
270 VMThread::execute(&op1);
271 }
272 if (JvmtiExport::should_post_data_dump()) {
273 JvmtiExport::post_data_dump();
274 }
275 break;
276 }
277 default: {
278 // Dispatch the signal to java
279 HandleMark hm(THREAD);
280 Klass* k = SystemDictionary::resolve_or_null(vmSymbols::sun_misc_Signal(), THREAD);
281 KlassHandle klass (THREAD, k);
282 if (klass.not_null()) {
283 JavaValue result(T_VOID);
284 JavaCallArguments args;
285 args.push_int(sig);
286 JavaCalls::call_static(
287 &result,
288 klass,
289 vmSymbols::dispatch_name(),
1427
1428 if (sz != 1) {
1429 // EOF reached. if we read chars before EOF return them and
1430 // return EOF on next call otherwise return EOF
1431
1432 return (i == 0) ? -1 : (int) i;
1433 }
1434
1435 // line is longer than size of buf, skip to EOL
1436 char ch;
1437 while (read(fd, &ch, 1) == 1 && ch != '\n') {
1438 // Do nothing
1439 }
1440
1441 // return initial part of line that fits in buf.
1442 // If we reached EOF, it will be returned on next call.
1443
1444 return (int) i;
1445 }
1446
1447 bool os::create_stack_guard_pages(char* addr, size_t bytes) {
1448 return os::pd_create_stack_guard_pages(addr, bytes);
1449 }
1450
1451
1452 char* os::reserve_memory(size_t bytes, char* addr, size_t alignment_hint) {
1453 char* result = pd_reserve_memory(bytes, addr, alignment_hint);
1454 if (result != NULL) {
1455 MemTracker::record_virtual_memory_reserve((address)result, bytes, CALLER_PC);
1456 }
1457
1458 return result;
1459 }
1460
1461 char* os::reserve_memory(size_t bytes, char* addr, size_t alignment_hint,
1462 MEMFLAGS flags) {
1463 char* result = pd_reserve_memory(bytes, addr, alignment_hint);
1464 if (result != NULL) {
1465 MemTracker::record_virtual_memory_reserve((address)result, bytes, CALLER_PC);
1466 MemTracker::record_virtual_memory_type((address)result, flags);
1467 }
1468
1469 return result;
1470 }
1471
1534 read_only, allow_exec);
1535 }
1536
1537 bool os::unmap_memory(char *addr, size_t bytes) {
1538 bool result = pd_unmap_memory(addr, bytes);
1539 if (result) {
1540 MemTracker::record_virtual_memory_uncommit((address)addr, bytes);
1541 MemTracker::record_virtual_memory_release((address)addr, bytes);
1542 }
1543 return result;
1544 }
1545
1546 void os::free_memory(char *addr, size_t bytes, size_t alignment_hint) {
1547 pd_free_memory(addr, bytes, alignment_hint);
1548 }
1549
1550 void os::realign_memory(char *addr, size_t bytes, size_t alignment_hint) {
1551 pd_realign_memory(addr, bytes, alignment_hint);
1552 }
1553
|
248
249 switch (sig) {
250 case SIGBREAK: {
251 // Check if the signal is a trigger to start the Attach Listener - in that
252 // case don't print stack traces.
253 if (!DisableAttachMechanism && AttachListener::is_init_trigger()) {
254 continue;
255 }
256 // Print stack traces
257 // Any SIGBREAK operations added here should make sure to flush
258 // the output stream (e.g. tty->flush()) after output. See 4803766.
259 // Each module also prints an extra carriage return after its output.
260 VM_PrintThreads op;
261 VMThread::execute(&op);
262 VM_PrintJNI jni_op;
263 VMThread::execute(&jni_op);
264 VM_FindDeadlocks op1(tty);
265 VMThread::execute(&op1);
266 Universe::print_heap_at_SIGBREAK();
267 if (PrintClassHistogram) {
268 VM_GC_HeapInspection op1(gclog_or_tty, true /* force full GC before heap inspection */);
269 VMThread::execute(&op1);
270 }
271 if (JvmtiExport::should_post_data_dump()) {
272 JvmtiExport::post_data_dump();
273 }
274 break;
275 }
276 default: {
277 // Dispatch the signal to java
278 HandleMark hm(THREAD);
279 Klass* k = SystemDictionary::resolve_or_null(vmSymbols::sun_misc_Signal(), THREAD);
280 KlassHandle klass (THREAD, k);
281 if (klass.not_null()) {
282 JavaValue result(T_VOID);
283 JavaCallArguments args;
284 args.push_int(sig);
285 JavaCalls::call_static(
286 &result,
287 klass,
288 vmSymbols::dispatch_name(),
1426
1427 if (sz != 1) {
1428 // EOF reached. if we read chars before EOF return them and
1429 // return EOF on next call otherwise return EOF
1430
1431 return (i == 0) ? -1 : (int) i;
1432 }
1433
1434 // line is longer than size of buf, skip to EOL
1435 char ch;
1436 while (read(fd, &ch, 1) == 1 && ch != '\n') {
1437 // Do nothing
1438 }
1439
1440 // return initial part of line that fits in buf.
1441 // If we reached EOF, it will be returned on next call.
1442
1443 return (int) i;
1444 }
1445
1446 void os::SuspendedThreadTask::run() {
1447 assert(Threads_lock->owned_by_self() || (_thread == VMThread::vm_thread()), "must have threads lock to call this");
1448 internal_do_task();
1449 _done = true;
1450 }
1451
1452 bool os::create_stack_guard_pages(char* addr, size_t bytes) {
1453 return os::pd_create_stack_guard_pages(addr, bytes);
1454 }
1455
1456 char* os::reserve_memory(size_t bytes, char* addr, size_t alignment_hint) {
1457 char* result = pd_reserve_memory(bytes, addr, alignment_hint);
1458 if (result != NULL) {
1459 MemTracker::record_virtual_memory_reserve((address)result, bytes, CALLER_PC);
1460 }
1461
1462 return result;
1463 }
1464
1465 char* os::reserve_memory(size_t bytes, char* addr, size_t alignment_hint,
1466 MEMFLAGS flags) {
1467 char* result = pd_reserve_memory(bytes, addr, alignment_hint);
1468 if (result != NULL) {
1469 MemTracker::record_virtual_memory_reserve((address)result, bytes, CALLER_PC);
1470 MemTracker::record_virtual_memory_type((address)result, flags);
1471 }
1472
1473 return result;
1474 }
1475
1538 read_only, allow_exec);
1539 }
1540
1541 bool os::unmap_memory(char *addr, size_t bytes) {
1542 bool result = pd_unmap_memory(addr, bytes);
1543 if (result) {
1544 MemTracker::record_virtual_memory_uncommit((address)addr, bytes);
1545 MemTracker::record_virtual_memory_release((address)addr, bytes);
1546 }
1547 return result;
1548 }
1549
1550 void os::free_memory(char *addr, size_t bytes, size_t alignment_hint) {
1551 pd_free_memory(addr, bytes, alignment_hint);
1552 }
1553
1554 void os::realign_memory(char *addr, size_t bytes, size_t alignment_hint) {
1555 pd_realign_memory(addr, bytes, alignment_hint);
1556 }
1557
1558 #ifndef TARGET_OS_FAMILY_windows
1559 /* try to switch state from state "from" to state "to"
1560 * returns the state set after the method is complete
1561 */
1562 os::SuspendResume::State os::SuspendResume::switch_state(os::SuspendResume::State from,
1563 os::SuspendResume::State to)
1564 {
1565 os::SuspendResume::State result =
1566 (os::SuspendResume::State) Atomic::cmpxchg((jint) to, (jint *) &_state, (jint) from);
1567 if (result == from) {
1568 // success
1569 return to;
1570 }
1571 return result;
1572 }
1573 #endif
|