Mercurial > hg > truffle
comparison src/share/vm/graal/graalCodeInstaller.cpp @ 10540:0ba44a5a8420
Add sanity check to avoid overwriting the reserved code buffer for very large methods.
author | Thomas Wuerthinger <thomas.wuerthinger@oracle.com> |
---|---|
date | Wed, 26 Jun 2013 15:22:11 +0200 |
parents | 9062da84cd75 |
children | 6ff467cdb105 |
comparison
equal
deleted
inserted
replaced
10539:5d460d3465fd | 10540:0ba44a5a8420 |
---|---|
367 initialize_assumptions(JNIHandles::resolve(compiled_code_obj)); | 367 initialize_assumptions(JNIHandles::resolve(compiled_code_obj)); |
368 | 368 |
369 { | 369 { |
370 No_Safepoint_Verifier no_safepoint; | 370 No_Safepoint_Verifier no_safepoint; |
371 initialize_fields(JNIHandles::resolve(compiled_code_obj)); | 371 initialize_fields(JNIHandles::resolve(compiled_code_obj)); |
372 initialize_buffer(buffer); | 372 if (!initialize_buffer(buffer)) { |
373 result = GraalEnv::code_too_large; | |
374 return; | |
375 } | |
373 process_exception_handlers(); | 376 process_exception_handlers(); |
374 } | 377 } |
375 | 378 |
376 int stack_slots = _total_frame_size / HeapWordSize; // conversion to words | 379 int stack_slots = _total_frame_size / HeapWordSize; // conversion to words |
377 GrowableArray<jlong>* leaf_graph_ids = get_leaf_graph_ids(compiled_code); | 380 GrowableArray<jlong>* leaf_graph_ids = get_leaf_graph_ids(compiled_code); |
425 | 428 |
426 _next_call_type = MARK_INVOKE_INVALID; | 429 _next_call_type = MARK_INVOKE_INVALID; |
427 } | 430 } |
428 | 431 |
429 // perform data and call relocation on the CodeBuffer | 432 // perform data and call relocation on the CodeBuffer |
430 void CodeInstaller::initialize_buffer(CodeBuffer& buffer) { | 433 bool CodeInstaller::initialize_buffer(CodeBuffer& buffer) { |
431 int locs_buffer_size = _sites->length() * (relocInfo::length_limit + sizeof(relocInfo)); | 434 int locs_buffer_size = _sites->length() * (relocInfo::length_limit + sizeof(relocInfo)); |
432 char* locs_buffer = NEW_RESOURCE_ARRAY(char, locs_buffer_size); | 435 char* locs_buffer = NEW_RESOURCE_ARRAY(char, locs_buffer_size); |
433 buffer.insts()->initialize_shared_locs((relocInfo*)locs_buffer, locs_buffer_size / sizeof(relocInfo)); | 436 buffer.insts()->initialize_shared_locs((relocInfo*)locs_buffer, locs_buffer_size / sizeof(relocInfo)); |
434 buffer.initialize_stubs_size(256); | 437 buffer.initialize_stubs_size(256); |
435 buffer.initialize_consts_size(_constants_size); | 438 buffer.initialize_consts_size(_constants_size); |
441 | 444 |
442 _instructions = buffer.insts(); | 445 _instructions = buffer.insts(); |
443 _constants = buffer.consts(); | 446 _constants = buffer.consts(); |
444 | 447 |
445 // copy the code into the newly created CodeBuffer | 448 // copy the code into the newly created CodeBuffer |
449 address end_pc = _instructions->start() + _code_size; | |
450 if (!_instructions->allocates2(end_pc)) { | |
451 return false; | |
452 } | |
446 memcpy(_instructions->start(), _code->base(T_BYTE), _code_size); | 453 memcpy(_instructions->start(), _code->base(T_BYTE), _code_size); |
447 _instructions->set_end(_instructions->start() + _code_size); | 454 _instructions->set_end(end_pc); |
448 | 455 |
449 for (int i = 0; i < _sites->length(); i++) { | 456 for (int i = 0; i < _sites->length(); i++) { |
450 oop site=((objArrayOop) (_sites))->obj_at(i); | 457 oop site=((objArrayOop) (_sites))->obj_at(i); |
451 jint pc_offset = CompilationResult_Site::pcOffset(site); | 458 jint pc_offset = CompilationResult_Site::pcOffset(site); |
452 | 459 |
484 char* text = java_lang_String::as_utf8_string(HotSpotCompiledCode_Comment::text(comment)); | 491 char* text = java_lang_String::as_utf8_string(HotSpotCompiledCode_Comment::text(comment)); |
485 buffer.block_comment(offset, text); | 492 buffer.block_comment(offset, text); |
486 } | 493 } |
487 } | 494 } |
488 #endif | 495 #endif |
496 return true; | |
489 } | 497 } |
490 | 498 |
491 void CodeInstaller::assumption_MethodContents(Handle assumption) { | 499 void CodeInstaller::assumption_MethodContents(Handle assumption) { |
492 Handle method_handle = Assumptions_MethodContents::method(assumption()); | 500 Handle method_handle = Assumptions_MethodContents::method(assumption()); |
493 methodHandle method = getMethodFromHotSpotMethod(method_handle()); | 501 methodHandle method = getMethodFromHotSpotMethod(method_handle()); |