| Index: src/objects.cc
|
| diff --git a/src/objects.cc b/src/objects.cc
|
| index f96fd83849cff3090814484757f26b352932bc87..bf7f808eb17186f0a3381b11e4db1c6a01cd836e 100644
|
| --- a/src/objects.cc
|
| +++ b/src/objects.cc
|
| @@ -9543,22 +9543,26 @@ void SharedFunctionInfo::AddToOptimizedCodeMap(
|
| Handle<SharedFunctionInfo> shared,
|
| Handle<Context> native_context,
|
| Handle<Code> code,
|
| - Handle<FixedArray> literals) {
|
| + Handle<FixedArray> literals,
|
| + BailoutId osr_ast_id) {
|
| CALL_HEAP_FUNCTION_VOID(
|
| shared->GetIsolate(),
|
| - shared->AddToOptimizedCodeMap(*native_context, *code, *literals));
|
| + shared->AddToOptimizedCodeMap(
|
| + *native_context, *code, *literals, osr_ast_id));
|
| }
|
|
|
|
|
| MaybeObject* SharedFunctionInfo::AddToOptimizedCodeMap(Context* native_context,
|
| Code* code,
|
| - FixedArray* literals) {
|
| + FixedArray* literals,
|
| + BailoutId osr_ast_id) {
|
| ASSERT(code->kind() == Code::OPTIMIZED_FUNCTION);
|
| ASSERT(native_context->IsNativeContext());
|
| - STATIC_ASSERT(kEntryLength == 3);
|
| + STATIC_ASSERT(kEntryLength == 4);
|
| Heap* heap = GetHeap();
|
| FixedArray* new_code_map;
|
| Object* value = optimized_code_map();
|
| + Smi* osr_smi = Smi::FromInt(osr_ast_id.ToInt());
|
| if (value->IsSmi()) {
|
| // No optimized code map.
|
| ASSERT_EQ(0, Smi::cast(value)->value());
|
| @@ -9568,10 +9572,11 @@ MaybeObject* SharedFunctionInfo::AddToOptimizedCodeMap(Context* native_context,
|
| new_code_map->set(kEntriesStart + 0, native_context);
|
| new_code_map->set(kEntriesStart + 1, code);
|
| new_code_map->set(kEntriesStart + 2, literals);
|
| + new_code_map->set(kEntriesStart + 3, osr_smi);
|
| } else {
|
| // Copy old map and append one new entry.
|
| FixedArray* old_code_map = FixedArray::cast(value);
|
| - ASSERT_EQ(-1, SearchOptimizedCodeMap(native_context));
|
| + ASSERT_EQ(-1, SearchOptimizedCodeMap(native_context, osr_ast_id));
|
| int old_length = old_code_map->length();
|
| int new_length = old_length + kEntryLength;
|
| MaybeObject* maybe = old_code_map->CopySize(new_length);
|
| @@ -9579,6 +9584,7 @@ MaybeObject* SharedFunctionInfo::AddToOptimizedCodeMap(Context* native_context,
|
| new_code_map->set(old_length + 0, native_context);
|
| new_code_map->set(old_length + 1, code);
|
| new_code_map->set(old_length + 2, literals);
|
| + new_code_map->set(old_length + 3, osr_smi);
|
| // Zap the old map for the sake of the heap verifier.
|
| if (Heap::ShouldZapGarbage()) {
|
| Object** data = old_code_map->data_start();
|
| @@ -9592,6 +9598,7 @@ MaybeObject* SharedFunctionInfo::AddToOptimizedCodeMap(Context* native_context,
|
| ASSERT(Code::cast(new_code_map->get(i + 1))->kind() ==
|
| Code::OPTIMIZED_FUNCTION);
|
| ASSERT(new_code_map->get(i + 2)->IsFixedArray());
|
| + ASSERT(new_code_map->get(i + 3)->IsSmi());
|
| }
|
| #endif
|
| set_optimized_code_map(new_code_map);
|
| @@ -9653,6 +9660,7 @@ void SharedFunctionInfo::EvictFromOptimizedCodeMap(Code* optimized_code,
|
| code_map->set(i, code_map->get(i + kEntryLength));
|
| code_map->set(i + 1, code_map->get(i + 1 + kEntryLength));
|
| code_map->set(i + 2, code_map->get(i + 2 + kEntryLength));
|
| + code_map->set(i + 3, code_map->get(i + 3 + kEntryLength));
|
| i += kEntryLength;
|
| }
|
| if (removed_entry) {
|
| @@ -10258,15 +10266,18 @@ void SharedFunctionInfo::CompleteInobjectSlackTracking() {
|
| }
|
|
|
|
|
| -int SharedFunctionInfo::SearchOptimizedCodeMap(Context* native_context) {
|
| +int SharedFunctionInfo::SearchOptimizedCodeMap(Context* native_context,
|
| + BailoutId osr_ast_id) {
|
| ASSERT(native_context->IsNativeContext());
|
| if (!FLAG_cache_optimized_code) return -1;
|
| Object* value = optimized_code_map();
|
| + Smi* osr_smi = Smi::FromInt(osr_ast_id.ToInt());
|
| if (!value->IsSmi()) {
|
| FixedArray* optimized_code_map = FixedArray::cast(value);
|
| int length = optimized_code_map->length();
|
| for (int i = kEntriesStart; i < length; i += kEntryLength) {
|
| - if (optimized_code_map->get(i) == native_context) {
|
| + if (optimized_code_map->get(i) == native_context &&
|
| + optimized_code_map->get(i + 3) == osr_smi) {
|
| return i + 1;
|
| }
|
| }
|
| @@ -10693,6 +10704,18 @@ BailoutId Code::TranslatePcOffsetToAstId(uint32_t pc_offset) {
|
| }
|
|
|
|
|
| +uint32_t Code::TranslateAstIdToPcOffset(BailoutId ast_id) {
|
| + DisallowHeapAllocation no_gc;
|
| + ASSERT(kind() == FUNCTION);
|
| + BackEdgeTable back_edges(this, &no_gc);
|
| + for (uint32_t i = 0; i < back_edges.length(); i++) {
|
| + if (back_edges.ast_id(i) == ast_id) return back_edges.pc_offset(i);
|
| + }
|
| + UNREACHABLE();
|
| + return 0;
|
| +}
|
| +
|
| +
|
| void Code::MakeCodeAgeSequenceYoung(byte* sequence, Isolate* isolate) {
|
| PatchPlatformCodeAge(isolate, sequence, kNoAgeCodeAge, NO_MARKING_PARITY);
|
| }
|
|
|