| 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/crankshaft/hydrogen.h" | 5 #include "src/crankshaft/hydrogen.h" |
| 6 | 6 |
| 7 #include <sstream> | 7 #include <sstream> |
| 8 | 8 |
| 9 #include "src/allocation-site-scopes.h" | 9 #include "src/allocation-site-scopes.h" |
| 10 #include "src/ast/ast-numbering.h" | 10 #include "src/ast/ast-numbering.h" |
| (...skipping 1357 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1368 graph()->FinalizeUniqueness(); | 1368 graph()->FinalizeUniqueness(); |
| 1369 return graph_; | 1369 return graph_; |
| 1370 } | 1370 } |
| 1371 | 1371 |
| 1372 int HGraphBuilder::TraceInlinedFunction(Handle<SharedFunctionInfo> shared, | 1372 int HGraphBuilder::TraceInlinedFunction(Handle<SharedFunctionInfo> shared, |
| 1373 SourcePosition position) { | 1373 SourcePosition position) { |
| 1374 DCHECK(info_->is_tracking_positions()); | 1374 DCHECK(info_->is_tracking_positions()); |
| 1375 | 1375 |
| 1376 int inline_id = static_cast<int>(graph()->inlined_function_infos().size()); | 1376 int inline_id = static_cast<int>(graph()->inlined_function_infos().size()); |
| 1377 HInlinedFunctionInfo info(shared->start_position()); | 1377 HInlinedFunctionInfo info(shared->start_position()); |
| 1378 if (!shared->script()->IsUndefined()) { | 1378 if (!shared->script()->IsUndefined(isolate())) { |
| 1379 Handle<Script> script(Script::cast(shared->script())); | 1379 Handle<Script> script(Script::cast(shared->script()), isolate()); |
| 1380 | 1380 |
| 1381 if (FLAG_hydrogen_track_positions && !script->source()->IsUndefined()) { | 1381 if (FLAG_hydrogen_track_positions && |
| 1382 !script->source()->IsUndefined(isolate())) { |
| 1382 CodeTracer::Scope tracing_scope(isolate()->GetCodeTracer()); | 1383 CodeTracer::Scope tracing_scope(isolate()->GetCodeTracer()); |
| 1383 Object* source_name = script->name(); | 1384 Object* source_name = script->name(); |
| 1384 OFStream os(tracing_scope.file()); | 1385 OFStream os(tracing_scope.file()); |
| 1385 os << "--- FUNCTION SOURCE ("; | 1386 os << "--- FUNCTION SOURCE ("; |
| 1386 if (source_name->IsString()) { | 1387 if (source_name->IsString()) { |
| 1387 os << String::cast(source_name)->ToCString().get() << ":"; | 1388 os << String::cast(source_name)->ToCString().get() << ":"; |
| 1388 } | 1389 } |
| 1389 os << shared->DebugName()->ToCString().get() << ") id{"; | 1390 os << shared->DebugName()->ToCString().get() << ") id{"; |
| 1390 os << info_->optimization_id() << "," << inline_id << "} ---\n"; | 1391 os << info_->optimization_id() << "," << inline_id << "} ---\n"; |
| 1391 { | 1392 { |
| (...skipping 4433 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5825 ScriptContextTable::LookupResult lookup; | 5826 ScriptContextTable::LookupResult lookup; |
| 5826 if (ScriptContextTable::Lookup(script_contexts, variable->name(), | 5827 if (ScriptContextTable::Lookup(script_contexts, variable->name(), |
| 5827 &lookup)) { | 5828 &lookup)) { |
| 5828 Handle<Context> script_context = ScriptContextTable::GetContext( | 5829 Handle<Context> script_context = ScriptContextTable::GetContext( |
| 5829 script_contexts, lookup.context_index); | 5830 script_contexts, lookup.context_index); |
| 5830 Handle<Object> current_value = | 5831 Handle<Object> current_value = |
| 5831 FixedArray::get(*script_context, lookup.slot_index, isolate()); | 5832 FixedArray::get(*script_context, lookup.slot_index, isolate()); |
| 5832 | 5833 |
| 5833 // If the values is not the hole, it will stay initialized, | 5834 // If the values is not the hole, it will stay initialized, |
| 5834 // so no need to generate a check. | 5835 // so no need to generate a check. |
| 5835 if (*current_value == *isolate()->factory()->the_hole_value()) { | 5836 if (current_value->IsTheHole(isolate())) { |
| 5836 return Bailout(kReferenceToUninitializedVariable); | 5837 return Bailout(kReferenceToUninitializedVariable); |
| 5837 } | 5838 } |
| 5838 HInstruction* result = New<HLoadNamedField>( | 5839 HInstruction* result = New<HLoadNamedField>( |
| 5839 Add<HConstant>(script_context), nullptr, | 5840 Add<HConstant>(script_context), nullptr, |
| 5840 HObjectAccess::ForContextSlot(lookup.slot_index)); | 5841 HObjectAccess::ForContextSlot(lookup.slot_index)); |
| 5841 return ast_context()->ReturnInstruction(result, expr->id()); | 5842 return ast_context()->ReturnInstruction(result, expr->id()); |
| 5842 } | 5843 } |
| 5843 } | 5844 } |
| 5844 | 5845 |
| 5845 LookupIterator it(global, variable->name(), LookupIterator::OWN); | 5846 LookupIterator it(global, variable->name(), LookupIterator::OWN); |
| (...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6048 | 6049 |
| 6049 Handle<JSFunction> closure = function_state()->compilation_info()->closure(); | 6050 Handle<JSFunction> closure = function_state()->compilation_info()->closure(); |
| 6050 HInstruction* literal; | 6051 HInstruction* literal; |
| 6051 | 6052 |
| 6052 // Check whether to use fast or slow deep-copying for boilerplate. | 6053 // Check whether to use fast or slow deep-copying for boilerplate. |
| 6053 int max_properties = kMaxFastLiteralProperties; | 6054 int max_properties = kMaxFastLiteralProperties; |
| 6054 Handle<Object> literals_cell( | 6055 Handle<Object> literals_cell( |
| 6055 closure->literals()->literal(expr->literal_index()), isolate()); | 6056 closure->literals()->literal(expr->literal_index()), isolate()); |
| 6056 Handle<AllocationSite> site; | 6057 Handle<AllocationSite> site; |
| 6057 Handle<JSObject> boilerplate; | 6058 Handle<JSObject> boilerplate; |
| 6058 if (!literals_cell->IsUndefined()) { | 6059 if (!literals_cell->IsUndefined(isolate())) { |
| 6059 // Retrieve the boilerplate | 6060 // Retrieve the boilerplate |
| 6060 site = Handle<AllocationSite>::cast(literals_cell); | 6061 site = Handle<AllocationSite>::cast(literals_cell); |
| 6061 boilerplate = Handle<JSObject>(JSObject::cast(site->transition_info()), | 6062 boilerplate = Handle<JSObject>(JSObject::cast(site->transition_info()), |
| 6062 isolate()); | 6063 isolate()); |
| 6063 } | 6064 } |
| 6064 | 6065 |
| 6065 if (!boilerplate.is_null() && | 6066 if (!boilerplate.is_null() && |
| 6066 IsFastLiteral(boilerplate, kMaxFastLiteralDepth, &max_properties)) { | 6067 IsFastLiteral(boilerplate, kMaxFastLiteralDepth, &max_properties)) { |
| 6067 AllocationSiteUsageContext site_context(isolate(), site, false); | 6068 AllocationSiteUsageContext site_context(isolate(), site, false); |
| 6068 site_context.EnterNewScope(); | 6069 site_context.EnterNewScope(); |
| (...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6166 ZoneList<Expression*>* subexprs = expr->values(); | 6167 ZoneList<Expression*>* subexprs = expr->values(); |
| 6167 int length = subexprs->length(); | 6168 int length = subexprs->length(); |
| 6168 HInstruction* literal; | 6169 HInstruction* literal; |
| 6169 | 6170 |
| 6170 Handle<AllocationSite> site; | 6171 Handle<AllocationSite> site; |
| 6171 Handle<LiteralsArray> literals(environment()->closure()->literals(), | 6172 Handle<LiteralsArray> literals(environment()->closure()->literals(), |
| 6172 isolate()); | 6173 isolate()); |
| 6173 Handle<Object> literals_cell(literals->literal(expr->literal_index()), | 6174 Handle<Object> literals_cell(literals->literal(expr->literal_index()), |
| 6174 isolate()); | 6175 isolate()); |
| 6175 Handle<JSObject> boilerplate_object; | 6176 Handle<JSObject> boilerplate_object; |
| 6176 if (!literals_cell->IsUndefined()) { | 6177 if (!literals_cell->IsUndefined(isolate())) { |
| 6177 DCHECK(literals_cell->IsAllocationSite()); | 6178 DCHECK(literals_cell->IsAllocationSite()); |
| 6178 site = Handle<AllocationSite>::cast(literals_cell); | 6179 site = Handle<AllocationSite>::cast(literals_cell); |
| 6179 boilerplate_object = Handle<JSObject>( | 6180 boilerplate_object = Handle<JSObject>( |
| 6180 JSObject::cast(site->transition_info()), isolate()); | 6181 JSObject::cast(site->transition_info()), isolate()); |
| 6181 } | 6182 } |
| 6182 | 6183 |
| 6183 // Check whether to use fast or slow deep-copying for boilerplate. | 6184 // Check whether to use fast or slow deep-copying for boilerplate. |
| 6184 int max_properties = kMaxFastLiteralProperties; | 6185 int max_properties = kMaxFastLiteralProperties; |
| 6185 if (!boilerplate_object.is_null() && | 6186 if (!boilerplate_object.is_null() && |
| 6186 IsFastLiteral(boilerplate_object, kMaxFastLiteralDepth, | 6187 IsFastLiteral(boilerplate_object, kMaxFastLiteralDepth, |
| (...skipping 820 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7007 return Bailout(kNonInitializerAssignmentToConst); | 7008 return Bailout(kNonInitializerAssignmentToConst); |
| 7008 } | 7009 } |
| 7009 Handle<Context> script_context = | 7010 Handle<Context> script_context = |
| 7010 ScriptContextTable::GetContext(script_contexts, lookup.context_index); | 7011 ScriptContextTable::GetContext(script_contexts, lookup.context_index); |
| 7011 | 7012 |
| 7012 Handle<Object> current_value = | 7013 Handle<Object> current_value = |
| 7013 FixedArray::get(*script_context, lookup.slot_index, isolate()); | 7014 FixedArray::get(*script_context, lookup.slot_index, isolate()); |
| 7014 | 7015 |
| 7015 // If the values is not the hole, it will stay initialized, | 7016 // If the values is not the hole, it will stay initialized, |
| 7016 // so no need to generate a check. | 7017 // so no need to generate a check. |
| 7017 if (*current_value == *isolate()->factory()->the_hole_value()) { | 7018 if (current_value->IsTheHole(isolate())) { |
| 7018 return Bailout(kReferenceToUninitializedVariable); | 7019 return Bailout(kReferenceToUninitializedVariable); |
| 7019 } | 7020 } |
| 7020 | 7021 |
| 7021 HStoreNamedField* instr = Add<HStoreNamedField>( | 7022 HStoreNamedField* instr = Add<HStoreNamedField>( |
| 7022 Add<HConstant>(script_context), | 7023 Add<HConstant>(script_context), |
| 7023 HObjectAccess::ForContextSlot(lookup.slot_index), value); | 7024 HObjectAccess::ForContextSlot(lookup.slot_index), value); |
| 7024 USE(instr); | 7025 USE(instr); |
| 7025 DCHECK(instr->HasObservableSideEffects()); | 7026 DCHECK(instr->HasObservableSideEffects()); |
| 7026 Add<HSimulate>(ast_id, REMOVABLE_SIMULATE); | 7027 Add<HSimulate>(ast_id, REMOVABLE_SIMULATE); |
| 7027 return; | 7028 return; |
| (...skipping 2426 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 9454 break; | 9455 break; |
| 9455 case CallOptimization::kHolderIsReceiver: | 9456 case CallOptimization::kHolderIsReceiver: |
| 9456 holder = receiver; | 9457 holder = receiver; |
| 9457 break; | 9458 break; |
| 9458 case CallOptimization::kHolderNotFound: | 9459 case CallOptimization::kHolderNotFound: |
| 9459 UNREACHABLE(); | 9460 UNREACHABLE(); |
| 9460 break; | 9461 break; |
| 9461 } | 9462 } |
| 9462 Handle<CallHandlerInfo> api_call_info = optimization.api_call_info(); | 9463 Handle<CallHandlerInfo> api_call_info = optimization.api_call_info(); |
| 9463 Handle<Object> call_data_obj(api_call_info->data(), isolate()); | 9464 Handle<Object> call_data_obj(api_call_info->data(), isolate()); |
| 9464 bool call_data_undefined = call_data_obj->IsUndefined(); | 9465 bool call_data_undefined = call_data_obj->IsUndefined(isolate()); |
| 9465 HValue* call_data = Add<HConstant>(call_data_obj); | 9466 HValue* call_data = Add<HConstant>(call_data_obj); |
| 9466 ApiFunction fun(v8::ToCData<Address>(api_call_info->callback())); | 9467 ApiFunction fun(v8::ToCData<Address>(api_call_info->callback())); |
| 9467 ExternalReference ref = ExternalReference(&fun, | 9468 ExternalReference ref = ExternalReference(&fun, |
| 9468 ExternalReference::DIRECT_API_CALL, | 9469 ExternalReference::DIRECT_API_CALL, |
| 9469 isolate()); | 9470 isolate()); |
| 9470 HValue* api_function_address = Add<HConstant>(ExternalReference(ref)); | 9471 HValue* api_function_address = Add<HConstant>(ExternalReference(ref)); |
| 9471 | 9472 |
| 9472 HValue* op_vals[] = {context(), Add<HConstant>(function), call_data, holder, | 9473 HValue* op_vals[] = {context(), Add<HConstant>(function), call_data, holder, |
| 9473 api_function_address, nullptr}; | 9474 api_function_address, nullptr}; |
| 9474 | 9475 |
| (...skipping 4168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 13643 isolate()->GetHTracer()->TraceHydrogen(name(), graph_); | 13644 isolate()->GetHTracer()->TraceHydrogen(name(), graph_); |
| 13644 } | 13645 } |
| 13645 | 13646 |
| 13646 #ifdef DEBUG | 13647 #ifdef DEBUG |
| 13647 graph_->Verify(false); // No full verify. | 13648 graph_->Verify(false); // No full verify. |
| 13648 #endif | 13649 #endif |
| 13649 } | 13650 } |
| 13650 | 13651 |
| 13651 } // namespace internal | 13652 } // namespace internal |
| 13652 } // namespace v8 | 13653 } // namespace v8 |
| OLD | NEW |