| OLD | NEW |
| 1 // Copyright 2013 the V8 project authors. All rights reserved. | 1 // Copyright 2013 the V8 project authors. All rights reserved. |
| 2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
| 3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
| 4 // met: | 4 // met: |
| 5 // | 5 // |
| 6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
| 7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
| 8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
| 9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
| 10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
| (...skipping 9525 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 9536 ASSERT(shared->allows_lazy_compilation_without_context()); | 9536 ASSERT(shared->allows_lazy_compilation_without_context()); |
| 9537 CompilationInfoWithZone info(shared); | 9537 CompilationInfoWithZone info(shared); |
| 9538 return CompileLazyHelper(&info, flag); | 9538 return CompileLazyHelper(&info, flag); |
| 9539 } | 9539 } |
| 9540 | 9540 |
| 9541 | 9541 |
| 9542 void SharedFunctionInfo::AddToOptimizedCodeMap( | 9542 void SharedFunctionInfo::AddToOptimizedCodeMap( |
| 9543 Handle<SharedFunctionInfo> shared, | 9543 Handle<SharedFunctionInfo> shared, |
| 9544 Handle<Context> native_context, | 9544 Handle<Context> native_context, |
| 9545 Handle<Code> code, | 9545 Handle<Code> code, |
| 9546 Handle<FixedArray> literals) { | 9546 Handle<FixedArray> literals, |
| 9547 BailoutId osr_ast_id) { |
| 9547 CALL_HEAP_FUNCTION_VOID( | 9548 CALL_HEAP_FUNCTION_VOID( |
| 9548 shared->GetIsolate(), | 9549 shared->GetIsolate(), |
| 9549 shared->AddToOptimizedCodeMap(*native_context, *code, *literals)); | 9550 shared->AddToOptimizedCodeMap( |
| 9551 *native_context, *code, *literals, osr_ast_id)); |
| 9550 } | 9552 } |
| 9551 | 9553 |
| 9552 | 9554 |
| 9553 MaybeObject* SharedFunctionInfo::AddToOptimizedCodeMap(Context* native_context, | 9555 MaybeObject* SharedFunctionInfo::AddToOptimizedCodeMap(Context* native_context, |
| 9554 Code* code, | 9556 Code* code, |
| 9555 FixedArray* literals) { | 9557 FixedArray* literals, |
| 9558 BailoutId osr_ast_id) { |
| 9556 ASSERT(code->kind() == Code::OPTIMIZED_FUNCTION); | 9559 ASSERT(code->kind() == Code::OPTIMIZED_FUNCTION); |
| 9557 ASSERT(native_context->IsNativeContext()); | 9560 ASSERT(native_context->IsNativeContext()); |
| 9558 STATIC_ASSERT(kEntryLength == 3); | 9561 STATIC_ASSERT(kEntryLength == 3); |
| 9559 Heap* heap = GetHeap(); | 9562 Heap* heap = GetHeap(); |
| 9560 FixedArray* new_code_map; | 9563 FixedArray* new_code_map; |
| 9561 Object* value = optimized_code_map(); | 9564 Object* value = optimized_code_map(); |
| 9562 if (value->IsSmi()) { | 9565 if (value->IsSmi()) { |
| 9563 // No optimized code map. | 9566 // No optimized code map. |
| 9564 ASSERT_EQ(0, Smi::cast(value)->value()); | 9567 ASSERT_EQ(0, Smi::cast(value)->value()); |
| 9565 // Create 3 entries per context {context, code, literals}. | 9568 // Create 3 entries per context {context, code, literals}. |
| 9566 MaybeObject* maybe = heap->AllocateFixedArray(kInitialLength); | 9569 MaybeObject* maybe = heap->AllocateFixedArray(kInitialLength); |
| 9567 if (!maybe->To(&new_code_map)) return maybe; | 9570 if (!maybe->To(&new_code_map)) return maybe; |
| 9568 new_code_map->set(kEntriesStart + 0, native_context); | 9571 new_code_map->set(kEntriesStart + 0, native_context); |
| 9569 new_code_map->set(kEntriesStart + 1, code); | 9572 new_code_map->set(kEntriesStart + 1, code); |
| 9570 new_code_map->set(kEntriesStart + 2, literals); | 9573 new_code_map->set(kEntriesStart + 2, literals); |
| 9571 } else { | 9574 } else { |
| 9572 // Copy old map and append one new entry. | 9575 // Copy old map and append one new entry. |
| 9573 FixedArray* old_code_map = FixedArray::cast(value); | 9576 FixedArray* old_code_map = FixedArray::cast(value); |
| 9574 ASSERT_EQ(-1, SearchOptimizedCodeMap(native_context)); | 9577 ASSERT_EQ(-1, SearchOptimizedCodeMap(native_context, osr_ast_id)); |
| 9575 int old_length = old_code_map->length(); | 9578 int old_length = old_code_map->length(); |
| 9576 int new_length = old_length + kEntryLength; | 9579 int new_length = old_length + kEntryLength; |
| 9577 MaybeObject* maybe = old_code_map->CopySize(new_length); | 9580 MaybeObject* maybe = old_code_map->CopySize(new_length); |
| 9578 if (!maybe->To(&new_code_map)) return maybe; | 9581 if (!maybe->To(&new_code_map)) return maybe; |
| 9579 new_code_map->set(old_length + 0, native_context); | 9582 new_code_map->set(old_length + 0, native_context); |
| 9580 new_code_map->set(old_length + 1, code); | 9583 new_code_map->set(old_length + 1, code); |
| 9581 new_code_map->set(old_length + 2, literals); | 9584 new_code_map->set(old_length + 2, literals); |
| 9582 // Zap the old map for the sake of the heap verifier. | 9585 // Zap the old map for the sake of the heap verifier. |
| 9583 if (Heap::ShouldZapGarbage()) { | 9586 if (Heap::ShouldZapGarbage()) { |
| 9584 Object** data = old_code_map->data_start(); | 9587 Object** data = old_code_map->data_start(); |
| (...skipping 666 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 10251 // Resize the initial map and all maps in its transition tree. | 10254 // Resize the initial map and all maps in its transition tree. |
| 10252 map->TraverseTransitionTree(&ShrinkInstanceSize, &slack); | 10255 map->TraverseTransitionTree(&ShrinkInstanceSize, &slack); |
| 10253 | 10256 |
| 10254 // Give the correct expected_nof_properties to initial maps created later. | 10257 // Give the correct expected_nof_properties to initial maps created later. |
| 10255 ASSERT(expected_nof_properties() >= slack); | 10258 ASSERT(expected_nof_properties() >= slack); |
| 10256 set_expected_nof_properties(expected_nof_properties() - slack); | 10259 set_expected_nof_properties(expected_nof_properties() - slack); |
| 10257 } | 10260 } |
| 10258 } | 10261 } |
| 10259 | 10262 |
| 10260 | 10263 |
| 10261 int SharedFunctionInfo::SearchOptimizedCodeMap(Context* native_context) { | 10264 int SharedFunctionInfo::SearchOptimizedCodeMap(Context* native_context, |
| 10265 BailoutId osr_ast_id) { |
| 10262 ASSERT(native_context->IsNativeContext()); | 10266 ASSERT(native_context->IsNativeContext()); |
| 10263 if (!FLAG_cache_optimized_code) return -1; | 10267 if (!FLAG_cache_optimized_code) return -1; |
| 10264 Object* value = optimized_code_map(); | 10268 Object* value = optimized_code_map(); |
| 10265 if (!value->IsSmi()) { | 10269 if (!value->IsSmi()) { |
| 10266 FixedArray* optimized_code_map = FixedArray::cast(value); | 10270 FixedArray* optimized_code_map = FixedArray::cast(value); |
| 10267 int length = optimized_code_map->length(); | 10271 int length = optimized_code_map->length(); |
| 10268 for (int i = kEntriesStart; i < length; i += kEntryLength) { | 10272 for (int i = kEntriesStart; i < length; i += kEntryLength) { |
| 10269 if (optimized_code_map->get(i) == native_context) { | 10273 if (optimized_code_map->get(i) == native_context) { |
| 10270 return i + 1; | 10274 Code* code = Code::cast(optimized_code_map->get(i + 1)); |
| 10275 if (code->OsrAstId() == osr_ast_id) return i + 1; |
| 10271 } | 10276 } |
| 10272 } | 10277 } |
| 10273 if (FLAG_trace_opt) { | 10278 if (FLAG_trace_opt) { |
| 10274 PrintF("[didn't find optimized code in optimized code map for "); | 10279 PrintF("[didn't find optimized code in optimized code map for "); |
| 10275 ShortPrint(); | 10280 ShortPrint(); |
| 10276 PrintF("]\n"); | 10281 PrintF("]\n"); |
| 10277 } | 10282 } |
| 10278 } | 10283 } |
| 10279 return -1; | 10284 return -1; |
| 10280 } | 10285 } |
| (...skipping 405 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 10686 DisallowHeapAllocation no_gc; | 10691 DisallowHeapAllocation no_gc; |
| 10687 ASSERT(kind() == FUNCTION); | 10692 ASSERT(kind() == FUNCTION); |
| 10688 BackEdgeTable back_edges(this, &no_gc); | 10693 BackEdgeTable back_edges(this, &no_gc); |
| 10689 for (uint32_t i = 0; i < back_edges.length(); i++) { | 10694 for (uint32_t i = 0; i < back_edges.length(); i++) { |
| 10690 if (back_edges.pc_offset(i) == pc_offset) return back_edges.ast_id(i); | 10695 if (back_edges.pc_offset(i) == pc_offset) return back_edges.ast_id(i); |
| 10691 } | 10696 } |
| 10692 return BailoutId::None(); | 10697 return BailoutId::None(); |
| 10693 } | 10698 } |
| 10694 | 10699 |
| 10695 | 10700 |
| 10701 BailoutId Code::OsrAstId() { |
| 10702 ASSERT(kind() == Code::OPTIMIZED_FUNCTION); |
| 10703 DeoptimizationInputData* data = |
| 10704 DeoptimizationInputData::cast(deoptimization_data()); |
| 10705 return BailoutId(data->OsrAstId()->value()); |
| 10706 } |
| 10707 |
| 10708 |
| 10696 void Code::MakeCodeAgeSequenceYoung(byte* sequence, Isolate* isolate) { | 10709 void Code::MakeCodeAgeSequenceYoung(byte* sequence, Isolate* isolate) { |
| 10697 PatchPlatformCodeAge(isolate, sequence, kNoAgeCodeAge, NO_MARKING_PARITY); | 10710 PatchPlatformCodeAge(isolate, sequence, kNoAgeCodeAge, NO_MARKING_PARITY); |
| 10698 } | 10711 } |
| 10699 | 10712 |
| 10700 | 10713 |
| 10701 void Code::MarkCodeAsExecuted(byte* sequence, Isolate* isolate) { | 10714 void Code::MarkCodeAsExecuted(byte* sequence, Isolate* isolate) { |
| 10702 PatchPlatformCodeAge(isolate, sequence, kExecutedOnceCodeAge, | 10715 PatchPlatformCodeAge(isolate, sequence, kExecutedOnceCodeAge, |
| 10703 NO_MARKING_PARITY); | 10716 NO_MARKING_PARITY); |
| 10704 } | 10717 } |
| 10705 | 10718 |
| (...skipping 5945 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 16651 #define ERROR_MESSAGES_TEXTS(C, T) T, | 16664 #define ERROR_MESSAGES_TEXTS(C, T) T, |
| 16652 static const char* error_messages_[] = { | 16665 static const char* error_messages_[] = { |
| 16653 ERROR_MESSAGES_LIST(ERROR_MESSAGES_TEXTS) | 16666 ERROR_MESSAGES_LIST(ERROR_MESSAGES_TEXTS) |
| 16654 }; | 16667 }; |
| 16655 #undef ERROR_MESSAGES_TEXTS | 16668 #undef ERROR_MESSAGES_TEXTS |
| 16656 return error_messages_[reason]; | 16669 return error_messages_[reason]; |
| 16657 } | 16670 } |
| 16658 | 16671 |
| 16659 | 16672 |
| 16660 } } // namespace v8::internal | 16673 } } // namespace v8::internal |
| OLD | NEW |