OLD | NEW |
1 // Copyright 2013 the V8 project authors. All rights reserved. | 1 // Copyright 2013 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "src/objects.h" | 5 #include "src/objects.h" |
6 | 6 |
7 #include <cmath> | 7 #include <cmath> |
8 #include <iomanip> | 8 #include <iomanip> |
9 #include <sstream> | 9 #include <sstream> |
10 | 10 |
(...skipping 10139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
10150 DCHECK(code->kind() == Code::OPTIMIZED_FUNCTION); | 10150 DCHECK(code->kind() == Code::OPTIMIZED_FUNCTION); |
10151 Handle<Object> value(shared->optimized_code_map(), isolate); | 10151 Handle<Object> value(shared->optimized_code_map(), isolate); |
10152 if (value->IsSmi()) return; // Empty code maps are unsupported. | 10152 if (value->IsSmi()) return; // Empty code maps are unsupported. |
10153 Handle<FixedArray> code_map = Handle<FixedArray>::cast(value); | 10153 Handle<FixedArray> code_map = Handle<FixedArray>::cast(value); |
10154 code_map->set(kSharedCodeIndex, *code); | 10154 code_map->set(kSharedCodeIndex, *code); |
10155 } | 10155 } |
10156 | 10156 |
10157 | 10157 |
10158 void SharedFunctionInfo::AddToOptimizedCodeMap( | 10158 void SharedFunctionInfo::AddToOptimizedCodeMap( |
10159 Handle<SharedFunctionInfo> shared, Handle<Context> native_context, | 10159 Handle<SharedFunctionInfo> shared, Handle<Context> native_context, |
10160 Handle<HeapObject> code, Handle<FixedArray> literals, | 10160 Handle<HeapObject> code, Handle<LiteralsArray> literals, |
10161 BailoutId osr_ast_id) { | 10161 BailoutId osr_ast_id) { |
10162 Isolate* isolate = shared->GetIsolate(); | 10162 Isolate* isolate = shared->GetIsolate(); |
10163 DCHECK(*code == isolate->heap()->undefined_value() || | 10163 DCHECK(*code == isolate->heap()->undefined_value() || |
10164 !shared->SearchOptimizedCodeMap(*native_context, osr_ast_id).code); | 10164 !shared->SearchOptimizedCodeMap(*native_context, osr_ast_id).code); |
10165 DCHECK(*code == isolate->heap()->undefined_value() || | 10165 DCHECK(*code == isolate->heap()->undefined_value() || |
10166 Code::cast(*code)->kind() == Code::OPTIMIZED_FUNCTION); | 10166 Code::cast(*code)->kind() == Code::OPTIMIZED_FUNCTION); |
10167 DCHECK(native_context->IsNativeContext()); | 10167 DCHECK(native_context->IsNativeContext()); |
10168 STATIC_ASSERT(kEntryLength == 4); | 10168 STATIC_ASSERT(kEntryLength == 4); |
10169 Handle<FixedArray> new_code_map; | 10169 Handle<FixedArray> new_code_map; |
10170 Handle<Object> value(shared->optimized_code_map(), isolate); | 10170 Handle<Object> value(shared->optimized_code_map(), isolate); |
(...skipping 1169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
11340 int entry = SearchOptimizedCodeMapEntry(native_context, osr_ast_id); | 11340 int entry = SearchOptimizedCodeMapEntry(native_context, osr_ast_id); |
11341 if (entry != kNotFound) { | 11341 if (entry != kNotFound) { |
11342 FixedArray* code_map = FixedArray::cast(optimized_code_map()); | 11342 FixedArray* code_map = FixedArray::cast(optimized_code_map()); |
11343 if (entry == kSharedCodeIndex) { | 11343 if (entry == kSharedCodeIndex) { |
11344 result = {Code::cast(code_map->get(kSharedCodeIndex)), nullptr}; | 11344 result = {Code::cast(code_map->get(kSharedCodeIndex)), nullptr}; |
11345 | 11345 |
11346 } else { | 11346 } else { |
11347 DCHECK_LE(entry + kEntryLength, code_map->length()); | 11347 DCHECK_LE(entry + kEntryLength, code_map->length()); |
11348 Object* code = code_map->get(entry + kCachedCodeOffset); | 11348 Object* code = code_map->get(entry + kCachedCodeOffset); |
11349 result = {code->IsUndefined() ? nullptr : Code::cast(code), | 11349 result = {code->IsUndefined() ? nullptr : Code::cast(code), |
11350 FixedArray::cast(code_map->get(entry + kLiteralsOffset))}; | 11350 LiteralsArray::cast(code_map->get(entry + kLiteralsOffset))}; |
11351 } | 11351 } |
11352 } | 11352 } |
11353 if (FLAG_trace_opt && !optimized_code_map()->IsSmi() && | 11353 if (FLAG_trace_opt && !optimized_code_map()->IsSmi() && |
11354 result.code == nullptr) { | 11354 result.code == nullptr) { |
11355 PrintF("[didn't find optimized code in optimized code map for "); | 11355 PrintF("[didn't find optimized code in optimized code map for "); |
11356 ShortPrint(); | 11356 ShortPrint(); |
11357 PrintF("]\n"); | 11357 PrintF("]\n"); |
11358 } | 11358 } |
11359 return result; | 11359 return result; |
11360 } | 11360 } |
(...skipping 857 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
12218 for (int i = 0; i < this->DeoptPoints(); i++) { | 12218 for (int i = 0; i < this->DeoptPoints(); i++) { |
12219 int pc_and_state = this->PcAndState(i)->value(); | 12219 int pc_and_state = this->PcAndState(i)->value(); |
12220 os << std::setw(6) << this->AstId(i).ToInt() << " " << std::setw(8) | 12220 os << std::setw(6) << this->AstId(i).ToInt() << " " << std::setw(8) |
12221 << FullCodeGenerator::PcField::decode(pc_and_state) << " " | 12221 << FullCodeGenerator::PcField::decode(pc_and_state) << " " |
12222 << FullCodeGenerator::State2String( | 12222 << FullCodeGenerator::State2String( |
12223 FullCodeGenerator::StateField::decode(pc_and_state)) << "\n"; | 12223 FullCodeGenerator::StateField::decode(pc_and_state)) << "\n"; |
12224 } | 12224 } |
12225 } | 12225 } |
12226 | 12226 |
12227 | 12227 |
| 12228 // static |
| 12229 Handle<LiteralsArray> LiteralsArray::Allocate(Isolate* isolate, |
| 12230 Handle<TypeFeedbackVector> vector, |
| 12231 int number_of_literals, |
| 12232 PretenureFlag pretenure) { |
| 12233 Handle<FixedArray> literals = isolate->factory()->NewFixedArray( |
| 12234 number_of_literals + kFirstLiteralIndex, pretenure); |
| 12235 Handle<LiteralsArray> casted_literals = Handle<LiteralsArray>::cast(literals); |
| 12236 casted_literals->set_feedback_vector(*vector); |
| 12237 return casted_literals; |
| 12238 } |
| 12239 |
| 12240 |
12228 void HandlerTable::HandlerTableRangePrint(std::ostream& os) { | 12241 void HandlerTable::HandlerTableRangePrint(std::ostream& os) { |
12229 os << " from to hdlr\n"; | 12242 os << " from to hdlr\n"; |
12230 for (int i = 0; i < length(); i += kRangeEntrySize) { | 12243 for (int i = 0; i < length(); i += kRangeEntrySize) { |
12231 int pc_start = Smi::cast(get(i + kRangeStartIndex))->value(); | 12244 int pc_start = Smi::cast(get(i + kRangeStartIndex))->value(); |
12232 int pc_end = Smi::cast(get(i + kRangeEndIndex))->value(); | 12245 int pc_end = Smi::cast(get(i + kRangeEndIndex))->value(); |
12233 int handler_field = Smi::cast(get(i + kRangeHandlerIndex))->value(); | 12246 int handler_field = Smi::cast(get(i + kRangeHandlerIndex))->value(); |
12234 int handler_offset = HandlerOffsetField::decode(handler_field); | 12247 int handler_offset = HandlerOffsetField::decode(handler_field); |
12235 CatchPrediction prediction = HandlerPredictionField::decode(handler_field); | 12248 CatchPrediction prediction = HandlerPredictionField::decode(handler_field); |
12236 int depth = Smi::cast(get(i + kRangeDepthIndex))->value(); | 12249 int depth = Smi::cast(get(i + kRangeDepthIndex))->value(); |
12237 os << " (" << std::setw(4) << pc_start << "," << std::setw(4) << pc_end | 12250 os << " (" << std::setw(4) << pc_start << "," << std::setw(4) << pc_end |
(...skipping 4517 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
16755 if (cell->value() != *new_value) { | 16768 if (cell->value() != *new_value) { |
16756 cell->set_value(*new_value); | 16769 cell->set_value(*new_value); |
16757 Isolate* isolate = cell->GetIsolate(); | 16770 Isolate* isolate = cell->GetIsolate(); |
16758 cell->dependent_code()->DeoptimizeDependentCodeGroup( | 16771 cell->dependent_code()->DeoptimizeDependentCodeGroup( |
16759 isolate, DependentCode::kPropertyCellChangedGroup); | 16772 isolate, DependentCode::kPropertyCellChangedGroup); |
16760 } | 16773 } |
16761 } | 16774 } |
16762 | 16775 |
16763 } // namespace internal | 16776 } // namespace internal |
16764 } // namespace v8 | 16777 } // namespace v8 |
OLD | NEW |