Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(895)

Side by Side Diff: src/crankshaft/hydrogen.cc

Issue 2028983002: Introduce IsUndefined(Isolate*) and IsTheHole(Isolate*) (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: reducing old cmpare patterns Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 1355 matching lines...) Expand 10 before | Expand all | Expand 10 after
1366 set_current_block(graph()->entry_block()); 1366 set_current_block(graph()->entry_block());
1367 if (!BuildGraph()) return NULL; 1367 if (!BuildGraph()) return NULL;
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 Isolate* isolate = shared->GetIsolate();
1376 int inline_id = static_cast<int>(graph()->inlined_function_infos().size()); 1377 int inline_id = static_cast<int>(graph()->inlined_function_infos().size());
1377 HInlinedFunctionInfo info(shared->start_position()); 1378 HInlinedFunctionInfo info(shared->start_position());
1378 if (!shared->script()->IsUndefined()) { 1379 if (!shared->script()->IsUndefined(isolate)) {
1379 Handle<Script> script(Script::cast(shared->script())); 1380 Handle<Script> script(Script::cast(shared->script()), isolate);
1380 1381
1381 if (FLAG_hydrogen_track_positions && !script->source()->IsUndefined()) { 1382 if (FLAG_hydrogen_track_positions &&
1382 CodeTracer::Scope tracing_scope(isolate()->GetCodeTracer()); 1383 !script->source()->IsUndefined(isolate)) {
1384 CodeTracer::Scope tracing_scope(isolate->GetCodeTracer());
1383 Object* source_name = script->name(); 1385 Object* source_name = script->name();
1384 OFStream os(tracing_scope.file()); 1386 OFStream os(tracing_scope.file());
1385 os << "--- FUNCTION SOURCE ("; 1387 os << "--- FUNCTION SOURCE (";
1386 if (source_name->IsString()) { 1388 if (source_name->IsString()) {
1387 os << String::cast(source_name)->ToCString().get() << ":"; 1389 os << String::cast(source_name)->ToCString().get() << ":";
1388 } 1390 }
1389 os << shared->DebugName()->ToCString().get() << ") id{"; 1391 os << shared->DebugName()->ToCString().get() << ") id{";
1390 os << info_->optimization_id() << "," << inline_id << "} ---\n"; 1392 os << info_->optimization_id() << "," << inline_id << "} ---\n";
1391 { 1393 {
1392 DisallowHeapAllocation no_allocation; 1394 DisallowHeapAllocation no_allocation;
1393 int start = shared->start_position(); 1395 int start = shared->start_position();
1394 int len = shared->end_position() - start; 1396 int len = shared->end_position() - start;
1395 String::SubStringRange source(String::cast(script->source()), start, 1397 String::SubStringRange source(String::cast(script->source()), start,
1396 len); 1398 len);
1397 for (const auto& c : source) { 1399 for (const auto& c : source) {
1398 os << AsReversiblyEscapedUC16(c); 1400 os << AsReversiblyEscapedUC16(c);
1399 } 1401 }
1400 } 1402 }
1401 1403
1402 os << "\n--- END ---\n"; 1404 os << "\n--- END ---\n";
1403 } 1405 }
1404 } 1406 }
1405 1407
1406 graph()->inlined_function_infos().push_back(info); 1408 graph()->inlined_function_infos().push_back(info);
1407 1409
1408 if (FLAG_hydrogen_track_positions && inline_id != 0) { 1410 if (FLAG_hydrogen_track_positions && inline_id != 0) {
1409 CodeTracer::Scope tracing_scope(isolate()->GetCodeTracer()); 1411 CodeTracer::Scope tracing_scope(isolate->GetCodeTracer());
1410 OFStream os(tracing_scope.file()); 1412 OFStream os(tracing_scope.file());
1411 os << "INLINE (" << shared->DebugName()->ToCString().get() << ") id{" 1413 os << "INLINE (" << shared->DebugName()->ToCString().get() << ") id{"
1412 << info_->optimization_id() << "," << inline_id << "} AS " << inline_id 1414 << info_->optimization_id() << "," << inline_id << "} AS " << inline_id
1413 << " AT " << position << std::endl; 1415 << " AT " << position << std::endl;
1414 } 1416 }
1415 1417
1416 return inline_id; 1418 return inline_id;
1417 } 1419 }
1418 1420
1419 HInstruction* HGraphBuilder::AddInstruction(HInstruction* instr) { 1421 HInstruction* HGraphBuilder::AddInstruction(HInstruction* instr) {
(...skipping 4405 matching lines...) Expand 10 before | Expand all | Expand 10 after
5825 ScriptContextTable::LookupResult lookup; 5827 ScriptContextTable::LookupResult lookup;
5826 if (ScriptContextTable::Lookup(script_contexts, variable->name(), 5828 if (ScriptContextTable::Lookup(script_contexts, variable->name(),
5827 &lookup)) { 5829 &lookup)) {
5828 Handle<Context> script_context = ScriptContextTable::GetContext( 5830 Handle<Context> script_context = ScriptContextTable::GetContext(
5829 script_contexts, lookup.context_index); 5831 script_contexts, lookup.context_index);
5830 Handle<Object> current_value = 5832 Handle<Object> current_value =
5831 FixedArray::get(*script_context, lookup.slot_index, isolate()); 5833 FixedArray::get(*script_context, lookup.slot_index, isolate());
5832 5834
5833 // If the values is not the hole, it will stay initialized, 5835 // If the values is not the hole, it will stay initialized,
5834 // so no need to generate a check. 5836 // so no need to generate a check.
5835 if (*current_value == *isolate()->factory()->the_hole_value()) { 5837 if (current_value->IsTheHole(isolate())) {
5836 return Bailout(kReferenceToUninitializedVariable); 5838 return Bailout(kReferenceToUninitializedVariable);
5837 } 5839 }
5838 HInstruction* result = New<HLoadNamedField>( 5840 HInstruction* result = New<HLoadNamedField>(
5839 Add<HConstant>(script_context), nullptr, 5841 Add<HConstant>(script_context), nullptr,
5840 HObjectAccess::ForContextSlot(lookup.slot_index)); 5842 HObjectAccess::ForContextSlot(lookup.slot_index));
5841 return ast_context()->ReturnInstruction(result, expr->id()); 5843 return ast_context()->ReturnInstruction(result, expr->id());
5842 } 5844 }
5843 } 5845 }
5844 5846
5845 LookupIterator it(global, variable->name(), LookupIterator::OWN); 5847 LookupIterator it(global, variable->name(), LookupIterator::OWN);
(...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after
6048 6050
6049 Handle<JSFunction> closure = function_state()->compilation_info()->closure(); 6051 Handle<JSFunction> closure = function_state()->compilation_info()->closure();
6050 HInstruction* literal; 6052 HInstruction* literal;
6051 6053
6052 // Check whether to use fast or slow deep-copying for boilerplate. 6054 // Check whether to use fast or slow deep-copying for boilerplate.
6053 int max_properties = kMaxFastLiteralProperties; 6055 int max_properties = kMaxFastLiteralProperties;
6054 Handle<Object> literals_cell( 6056 Handle<Object> literals_cell(
6055 closure->literals()->literal(expr->literal_index()), isolate()); 6057 closure->literals()->literal(expr->literal_index()), isolate());
6056 Handle<AllocationSite> site; 6058 Handle<AllocationSite> site;
6057 Handle<JSObject> boilerplate; 6059 Handle<JSObject> boilerplate;
6058 if (!literals_cell->IsUndefined()) { 6060 if (!literals_cell->IsUndefined(isolate())) {
6059 // Retrieve the boilerplate 6061 // Retrieve the boilerplate
6060 site = Handle<AllocationSite>::cast(literals_cell); 6062 site = Handle<AllocationSite>::cast(literals_cell);
6061 boilerplate = Handle<JSObject>(JSObject::cast(site->transition_info()), 6063 boilerplate = Handle<JSObject>(JSObject::cast(site->transition_info()),
6062 isolate()); 6064 isolate());
6063 } 6065 }
6064 6066
6065 if (!boilerplate.is_null() && 6067 if (!boilerplate.is_null() &&
6066 IsFastLiteral(boilerplate, kMaxFastLiteralDepth, &max_properties)) { 6068 IsFastLiteral(boilerplate, kMaxFastLiteralDepth, &max_properties)) {
6067 AllocationSiteUsageContext site_context(isolate(), site, false); 6069 AllocationSiteUsageContext site_context(isolate(), site, false);
6068 site_context.EnterNewScope(); 6070 site_context.EnterNewScope();
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
6166 ZoneList<Expression*>* subexprs = expr->values(); 6168 ZoneList<Expression*>* subexprs = expr->values();
6167 int length = subexprs->length(); 6169 int length = subexprs->length();
6168 HInstruction* literal; 6170 HInstruction* literal;
6169 6171
6170 Handle<AllocationSite> site; 6172 Handle<AllocationSite> site;
6171 Handle<LiteralsArray> literals(environment()->closure()->literals(), 6173 Handle<LiteralsArray> literals(environment()->closure()->literals(),
6172 isolate()); 6174 isolate());
6173 Handle<Object> literals_cell(literals->literal(expr->literal_index()), 6175 Handle<Object> literals_cell(literals->literal(expr->literal_index()),
6174 isolate()); 6176 isolate());
6175 Handle<JSObject> boilerplate_object; 6177 Handle<JSObject> boilerplate_object;
6176 if (!literals_cell->IsUndefined()) { 6178 if (!literals_cell->IsUndefined(isolate())) {
6177 DCHECK(literals_cell->IsAllocationSite()); 6179 DCHECK(literals_cell->IsAllocationSite());
6178 site = Handle<AllocationSite>::cast(literals_cell); 6180 site = Handle<AllocationSite>::cast(literals_cell);
6179 boilerplate_object = Handle<JSObject>( 6181 boilerplate_object = Handle<JSObject>(
6180 JSObject::cast(site->transition_info()), isolate()); 6182 JSObject::cast(site->transition_info()), isolate());
6181 } 6183 }
6182 6184
6183 // Check whether to use fast or slow deep-copying for boilerplate. 6185 // Check whether to use fast or slow deep-copying for boilerplate.
6184 int max_properties = kMaxFastLiteralProperties; 6186 int max_properties = kMaxFastLiteralProperties;
6185 if (!boilerplate_object.is_null() && 6187 if (!boilerplate_object.is_null() &&
6186 IsFastLiteral(boilerplate_object, kMaxFastLiteralDepth, 6188 IsFastLiteral(boilerplate_object, kMaxFastLiteralDepth,
(...skipping 820 matching lines...) Expand 10 before | Expand all | Expand 10 after
7007 return Bailout(kNonInitializerAssignmentToConst); 7009 return Bailout(kNonInitializerAssignmentToConst);
7008 } 7010 }
7009 Handle<Context> script_context = 7011 Handle<Context> script_context =
7010 ScriptContextTable::GetContext(script_contexts, lookup.context_index); 7012 ScriptContextTable::GetContext(script_contexts, lookup.context_index);
7011 7013
7012 Handle<Object> current_value = 7014 Handle<Object> current_value =
7013 FixedArray::get(*script_context, lookup.slot_index, isolate()); 7015 FixedArray::get(*script_context, lookup.slot_index, isolate());
7014 7016
7015 // If the values is not the hole, it will stay initialized, 7017 // If the values is not the hole, it will stay initialized,
7016 // so no need to generate a check. 7018 // so no need to generate a check.
7017 if (*current_value == *isolate()->factory()->the_hole_value()) { 7019 if (current_value->IsTheHole(isolate())) {
7018 return Bailout(kReferenceToUninitializedVariable); 7020 return Bailout(kReferenceToUninitializedVariable);
7019 } 7021 }
7020 7022
7021 HStoreNamedField* instr = Add<HStoreNamedField>( 7023 HStoreNamedField* instr = Add<HStoreNamedField>(
7022 Add<HConstant>(script_context), 7024 Add<HConstant>(script_context),
7023 HObjectAccess::ForContextSlot(lookup.slot_index), value); 7025 HObjectAccess::ForContextSlot(lookup.slot_index), value);
7024 USE(instr); 7026 USE(instr);
7025 DCHECK(instr->HasObservableSideEffects()); 7027 DCHECK(instr->HasObservableSideEffects());
7026 Add<HSimulate>(ast_id, REMOVABLE_SIMULATE); 7028 Add<HSimulate>(ast_id, REMOVABLE_SIMULATE);
7027 return; 7029 return;
(...skipping 2417 matching lines...) Expand 10 before | Expand all | Expand 10 after
9445 break; 9447 break;
9446 case CallOptimization::kHolderIsReceiver: 9448 case CallOptimization::kHolderIsReceiver:
9447 holder = receiver; 9449 holder = receiver;
9448 break; 9450 break;
9449 case CallOptimization::kHolderNotFound: 9451 case CallOptimization::kHolderNotFound:
9450 UNREACHABLE(); 9452 UNREACHABLE();
9451 break; 9453 break;
9452 } 9454 }
9453 Handle<CallHandlerInfo> api_call_info = optimization.api_call_info(); 9455 Handle<CallHandlerInfo> api_call_info = optimization.api_call_info();
9454 Handle<Object> call_data_obj(api_call_info->data(), isolate()); 9456 Handle<Object> call_data_obj(api_call_info->data(), isolate());
9455 bool call_data_undefined = call_data_obj->IsUndefined(); 9457 bool call_data_undefined = call_data_obj->IsUndefined(isolate());
9456 HValue* call_data = Add<HConstant>(call_data_obj); 9458 HValue* call_data = Add<HConstant>(call_data_obj);
9457 ApiFunction fun(v8::ToCData<Address>(api_call_info->callback())); 9459 ApiFunction fun(v8::ToCData<Address>(api_call_info->callback()));
9458 ExternalReference ref = ExternalReference(&fun, 9460 ExternalReference ref = ExternalReference(&fun,
9459 ExternalReference::DIRECT_API_CALL, 9461 ExternalReference::DIRECT_API_CALL,
9460 isolate()); 9462 isolate());
9461 HValue* api_function_address = Add<HConstant>(ExternalReference(ref)); 9463 HValue* api_function_address = Add<HConstant>(ExternalReference(ref));
9462 9464
9463 HValue* op_vals[] = {context(), Add<HConstant>(function), call_data, holder, 9465 HValue* op_vals[] = {context(), Add<HConstant>(function), call_data, holder,
9464 api_function_address, nullptr}; 9466 api_function_address, nullptr};
9465 9467
(...skipping 4177 matching lines...) Expand 10 before | Expand all | Expand 10 after
13643 isolate()->GetHTracer()->TraceHydrogen(name(), graph_); 13645 isolate()->GetHTracer()->TraceHydrogen(name(), graph_);
13644 } 13646 }
13645 13647
13646 #ifdef DEBUG 13648 #ifdef DEBUG
13647 graph_->Verify(false); // No full verify. 13649 graph_->Verify(false); // No full verify.
13648 #endif 13650 #endif
13649 } 13651 }
13650 13652
13651 } // namespace internal 13653 } // namespace internal
13652 } // namespace v8 13654 } // namespace v8
OLDNEW
« no previous file with comments | « src/contexts-inl.h ('k') | src/crankshaft/hydrogen-instructions.cc » ('j') | src/objects.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698