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

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

Issue 2451853002: Uniform and precise source positions for inlining (Closed)
Patch Set: fixed compile issue Created 4 years, 1 month 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 <memory> 7 #include <memory>
8 #include <sstream> 8 #include <sstream>
9 9
10 #include "src/allocation-site-scopes.h" 10 #include "src/allocation-site-scopes.h"
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
79 } 79 }
80 80
81 #define DEF_VISIT(type) \ 81 #define DEF_VISIT(type) \
82 void Visit##type(type* node) override { \ 82 void Visit##type(type* node) override { \
83 SourcePosition old_position = SourcePosition::Unknown(); \ 83 SourcePosition old_position = SourcePosition::Unknown(); \
84 if (node->position() != kNoSourcePosition) { \ 84 if (node->position() != kNoSourcePosition) { \
85 old_position = source_position(); \ 85 old_position = source_position(); \
86 SetSourcePosition(node->position()); \ 86 SetSourcePosition(node->position()); \
87 } \ 87 } \
88 HOptimizedGraphBuilder::Visit##type(node); \ 88 HOptimizedGraphBuilder::Visit##type(node); \
89 if (!old_position.IsUnknown()) { \ 89 if (old_position.IsKnown()) { \
90 set_source_position(old_position); \ 90 set_source_position(old_position); \
91 } \ 91 } \
92 } 92 }
93 EXPRESSION_NODE_LIST(DEF_VISIT) 93 EXPRESSION_NODE_LIST(DEF_VISIT)
94 #undef DEF_VISIT 94 #undef DEF_VISIT
95 95
96 #define DEF_VISIT(type) \ 96 #define DEF_VISIT(type) \
97 void Visit##type(type* node) override { \ 97 void Visit##type(type* node) override { \
98 SourcePosition old_position = SourcePosition::Unknown(); \ 98 SourcePosition old_position = SourcePosition::Unknown(); \
99 if (node->position() != kNoSourcePosition) { \ 99 if (node->position() != kNoSourcePosition) { \
100 old_position = source_position(); \ 100 old_position = source_position(); \
101 SetSourcePosition(node->position()); \ 101 SetSourcePosition(node->position()); \
102 } \ 102 } \
103 HOptimizedGraphBuilder::Visit##type(node); \ 103 HOptimizedGraphBuilder::Visit##type(node); \
104 if (!old_position.IsUnknown()) { \ 104 if (old_position.IsKnown()) { \
105 set_source_position(old_position); \ 105 set_source_position(old_position); \
106 } \ 106 } \
107 } 107 }
108 STATEMENT_NODE_LIST(DEF_VISIT) 108 STATEMENT_NODE_LIST(DEF_VISIT)
109 #undef DEF_VISIT 109 #undef DEF_VISIT
110 110
111 #define DEF_VISIT(type) \ 111 #define DEF_VISIT(type) \
112 void Visit##type(type* node) override { \ 112 void Visit##type(type* node) override { \
113 HOptimizedGraphBuilder::Visit##type(node); \ 113 HOptimizedGraphBuilder::Visit##type(node); \
114 } 114 }
(...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after
305 phis_.RemoveElement(phi); 305 phis_.RemoveElement(phi);
306 phi->SetBlock(NULL); 306 phi->SetBlock(NULL);
307 } 307 }
308 308
309 309
310 void HBasicBlock::AddInstruction(HInstruction* instr, SourcePosition position) { 310 void HBasicBlock::AddInstruction(HInstruction* instr, SourcePosition position) {
311 DCHECK(!IsStartBlock() || !IsFinished()); 311 DCHECK(!IsStartBlock() || !IsFinished());
312 DCHECK(!instr->IsLinked()); 312 DCHECK(!instr->IsLinked());
313 DCHECK(!IsFinished()); 313 DCHECK(!IsFinished());
314 314
315 if (!position.IsUnknown()) { 315 if (position.IsKnown()) {
316 instr->set_position(position); 316 instr->set_position(position);
317 } 317 }
318 if (first_ == NULL) { 318 if (first_ == NULL) {
319 DCHECK(last_environment() != NULL); 319 DCHECK(last_environment() != NULL);
320 DCHECK(!last_environment()->ast_id().IsNone()); 320 DCHECK(!last_environment()->ast_id().IsNone());
321 HBlockEntry* entry = new(zone()) HBlockEntry(); 321 HBlockEntry* entry = new(zone()) HBlockEntry();
322 entry->InitializeAsFirst(this); 322 entry->InitializeAsFirst(this);
323 if (!position.IsUnknown()) { 323 if (position.IsKnown()) {
324 entry->set_position(position); 324 entry->set_position(position);
325 } else { 325 } else {
326 DCHECK(!FLAG_hydrogen_track_positions || 326 DCHECK(!FLAG_hydrogen_track_positions ||
327 !graph()->info()->IsOptimizing() || instr->IsAbnormalExit()); 327 !graph()->info()->IsOptimizing() || instr->IsAbnormalExit());
328 } 328 }
329 first_ = last_ = entry; 329 first_ = last_ = entry;
330 } 330 }
331 instr->InsertAfter(last_); 331 instr->InsertAfter(last_);
332 } 332 }
333 333
(...skipping 1024 matching lines...) Expand 10 before | Expand all | Expand 10 after
1358 } 1358 }
1359 finished_ = true; 1359 finished_ = true;
1360 } 1360 }
1361 1361
1362 1362
1363 HGraph* HGraphBuilder::CreateGraph() { 1363 HGraph* HGraphBuilder::CreateGraph() {
1364 DCHECK(!FLAG_minimal); 1364 DCHECK(!FLAG_minimal);
1365 graph_ = new (zone()) HGraph(info_, descriptor_); 1365 graph_ = new (zone()) HGraph(info_, descriptor_);
1366 if (FLAG_hydrogen_stats) isolate()->GetHStatistics()->Initialize(info_); 1366 if (FLAG_hydrogen_stats) isolate()->GetHStatistics()->Initialize(info_);
1367 if (!info_->IsStub() && is_tracking_positions()) { 1367 if (!info_->IsStub() && is_tracking_positions()) {
1368 TraceInlinedFunction(info_->shared_info(), SourcePosition::Unknown()); 1368 TraceInlinedFunction(info_->shared_info(), SourcePosition::Unknown(),
1369 SourcePosition::kNotInlined);
1369 } 1370 }
1370 CompilationPhase phase("H_Block building", info_); 1371 CompilationPhase phase("H_Block building", info_);
1371 set_current_block(graph()->entry_block()); 1372 set_current_block(graph()->entry_block());
1372 if (!BuildGraph()) return NULL; 1373 if (!BuildGraph()) return NULL;
1373 graph()->FinalizeUniqueness(); 1374 graph()->FinalizeUniqueness();
1374 return graph_; 1375 return graph_;
1375 } 1376 }
1376 1377
1377 int HGraphBuilder::TraceInlinedFunction(Handle<SharedFunctionInfo> shared, 1378 void HGraphBuilder::TraceInlinedFunction(Handle<SharedFunctionInfo> shared,
1378 SourcePosition position) { 1379 SourcePosition position,
1380 int inlining_id) {
1379 DCHECK(is_tracking_positions()); 1381 DCHECK(is_tracking_positions());
1380 1382
1381 int inline_id = static_cast<int>(graph()->inlined_function_infos().size());
1382 HInlinedFunctionInfo info(shared->start_position());
1383 if (!shared->script()->IsUndefined(isolate())) { 1383 if (!shared->script()->IsUndefined(isolate())) {
1384 Handle<Script> script(Script::cast(shared->script()), isolate()); 1384 Handle<Script> script(Script::cast(shared->script()), isolate());
1385 1385
1386 if (FLAG_hydrogen_track_positions && 1386 if (FLAG_hydrogen_track_positions &&
1387 !script->source()->IsUndefined(isolate())) { 1387 !script->source()->IsUndefined(isolate())) {
1388 CodeTracer::Scope tracing_scope(isolate()->GetCodeTracer()); 1388 CodeTracer::Scope tracing_scope(isolate()->GetCodeTracer());
1389 Object* source_name = script->name(); 1389 Object* source_name = script->name();
1390 OFStream os(tracing_scope.file()); 1390 OFStream os(tracing_scope.file());
1391 os << "--- FUNCTION SOURCE ("; 1391 os << "--- FUNCTION SOURCE (";
1392 if (source_name->IsString()) { 1392 if (source_name->IsString()) {
1393 os << String::cast(source_name)->ToCString().get() << ":"; 1393 os << String::cast(source_name)->ToCString().get() << ":";
1394 } 1394 }
1395 os << shared->DebugName()->ToCString().get() << ") id{"; 1395 os << shared->DebugName()->ToCString().get() << ") id{";
1396 os << info_->optimization_id() << "," << inline_id << "} ---\n"; 1396 os << info_->optimization_id() << "," << inlining_id << "} ---\n";
1397 { 1397 {
1398 DisallowHeapAllocation no_allocation; 1398 DisallowHeapAllocation no_allocation;
1399 int start = shared->start_position(); 1399 int start = shared->start_position();
1400 int len = shared->end_position() - start; 1400 int len = shared->end_position() - start;
1401 String::SubStringRange source(String::cast(script->source()), start, 1401 String::SubStringRange source(String::cast(script->source()), start,
1402 len); 1402 len);
1403 for (const auto& c : source) { 1403 for (const auto& c : source) {
1404 os << AsReversiblyEscapedUC16(c); 1404 os << AsReversiblyEscapedUC16(c);
1405 } 1405 }
1406 } 1406 }
1407 1407
1408 os << "\n--- END ---\n"; 1408 os << "\n--- END ---\n";
1409 } 1409 }
1410 } 1410 }
1411 1411
1412 graph()->inlined_function_infos().push_back(info); 1412 if (FLAG_hydrogen_track_positions &&
1413 1413 inlining_id != SourcePosition::kNotInlined) {
1414 if (FLAG_hydrogen_track_positions && inline_id != 0) {
1415 CodeTracer::Scope tracing_scope(isolate()->GetCodeTracer()); 1414 CodeTracer::Scope tracing_scope(isolate()->GetCodeTracer());
1416 OFStream os(tracing_scope.file()); 1415 OFStream os(tracing_scope.file());
1417 os << "INLINE (" << shared->DebugName()->ToCString().get() << ") id{" 1416 os << "INLINE (" << shared->DebugName()->ToCString().get() << ") id{"
1418 << info_->optimization_id() << "," << inline_id << "} AS " << inline_id 1417 << info_->optimization_id() << "," << inlining_id << "} AS "
1419 << " AT " << position << std::endl; 1418 << inlining_id << " AT " << position.ScriptOffset() << std::endl;
1420 } 1419 }
1421
1422 return inline_id;
1423 } 1420 }
1424 1421
1425 HInstruction* HGraphBuilder::AddInstruction(HInstruction* instr) { 1422 HInstruction* HGraphBuilder::AddInstruction(HInstruction* instr) {
1426 DCHECK(current_block() != NULL); 1423 DCHECK(current_block() != NULL);
1427 DCHECK(!FLAG_hydrogen_track_positions || 1424 DCHECK(!FLAG_hydrogen_track_positions || position_.IsKnown() ||
1428 !position_.IsUnknown() ||
1429 !info_->IsOptimizing()); 1425 !info_->IsOptimizing());
1430 current_block()->AddInstruction(instr, source_position()); 1426 current_block()->AddInstruction(instr, source_position());
1431 if (graph()->IsInsideNoSideEffectsScope()) { 1427 if (graph()->IsInsideNoSideEffectsScope()) {
1432 instr->SetFlag(HValue::kHasNoObservableSideEffects); 1428 instr->SetFlag(HValue::kHasNoObservableSideEffects);
1433 } 1429 }
1434 return instr; 1430 return instr;
1435 } 1431 }
1436 1432
1437 1433
1438 void HGraphBuilder::FinishCurrentBlock(HControlInstruction* last) { 1434 void HGraphBuilder::FinishCurrentBlock(HControlInstruction* last) {
1439 DCHECK(!FLAG_hydrogen_track_positions || 1435 DCHECK(!FLAG_hydrogen_track_positions || !info_->IsOptimizing() ||
1440 !info_->IsOptimizing() || 1436 position_.IsKnown());
1441 !position_.IsUnknown());
1442 current_block()->Finish(last, source_position()); 1437 current_block()->Finish(last, source_position());
1443 if (last->IsReturn() || last->IsAbnormalExit()) { 1438 if (last->IsReturn() || last->IsAbnormalExit()) {
1444 set_current_block(NULL); 1439 set_current_block(NULL);
1445 } 1440 }
1446 } 1441 }
1447 1442
1448 1443
1449 void HGraphBuilder::FinishExitCurrentBlock(HControlInstruction* instruction) { 1444 void HGraphBuilder::FinishExitCurrentBlock(HControlInstruction* instruction) {
1450 DCHECK(!FLAG_hydrogen_track_positions || !info_->IsOptimizing() || 1445 DCHECK(!FLAG_hydrogen_track_positions || !info_->IsOptimizing() ||
1451 !position_.IsUnknown()); 1446 position_.IsKnown());
1452 current_block()->FinishExit(instruction, source_position()); 1447 current_block()->FinishExit(instruction, source_position());
1453 if (instruction->IsReturn() || instruction->IsAbnormalExit()) { 1448 if (instruction->IsReturn() || instruction->IsAbnormalExit()) {
1454 set_current_block(NULL); 1449 set_current_block(NULL);
1455 } 1450 }
1456 } 1451 }
1457 1452
1458 1453
1459 void HGraphBuilder::AddIncrementCounter(StatsCounter* counter) { 1454 void HGraphBuilder::AddIncrementCounter(StatsCounter* counter) {
1460 if (FLAG_native_code_counters && counter->Enabled()) { 1455 if (FLAG_native_code_counters && counter->Enabled()) {
1461 HValue* reference = Add<HConstant>(ExternalReference(counter)); 1456 HValue* reference = Add<HConstant>(ExternalReference(counter));
(...skipping 1658 matching lines...) Expand 10 before | Expand all | Expand 10 after
3120 HValue* HGraphBuilder::AddLoadJSBuiltin(int context_index) { 3115 HValue* HGraphBuilder::AddLoadJSBuiltin(int context_index) {
3121 HValue* native_context = BuildGetNativeContext(); 3116 HValue* native_context = BuildGetNativeContext();
3122 HObjectAccess function_access = HObjectAccess::ForContextSlot(context_index); 3117 HObjectAccess function_access = HObjectAccess::ForContextSlot(context_index);
3123 return Add<HLoadNamedField>(native_context, nullptr, function_access); 3118 return Add<HLoadNamedField>(native_context, nullptr, function_access);
3124 } 3119 }
3125 3120
3126 HOptimizedGraphBuilder::HOptimizedGraphBuilder(CompilationInfo* info, 3121 HOptimizedGraphBuilder::HOptimizedGraphBuilder(CompilationInfo* info,
3127 bool track_positions) 3122 bool track_positions)
3128 : HGraphBuilder(info, CallInterfaceDescriptor(), track_positions), 3123 : HGraphBuilder(info, CallInterfaceDescriptor(), track_positions),
3129 function_state_(NULL), 3124 function_state_(NULL),
3130 initial_function_state_(this, info, NORMAL_RETURN, 0, 3125 initial_function_state_(this, info, NORMAL_RETURN, -1,
3131 TailCallMode::kAllow), 3126 TailCallMode::kAllow),
3132 ast_context_(NULL), 3127 ast_context_(NULL),
3133 break_scope_(NULL), 3128 break_scope_(NULL),
3134 inlined_count_(0), 3129 inlined_count_(0),
3135 globals_(10, info->zone()), 3130 globals_(10, info->zone()),
3136 osr_(new (info->zone()) HOsrBuilder(this)), 3131 osr_(new (info->zone()) HOsrBuilder(this)),
3137 bounds_(info->zone()) { 3132 bounds_(info->zone()) {
3138 // This is not initialized in the initializer list because the 3133 // This is not initialized in the initializer list because the
3139 // constructor for the initial state relies on function_state_ == NULL 3134 // constructor for the initial state relies on function_state_ == NULL
3140 // to know it's the initial state. 3135 // to know it's the initial state.
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
3236 info_(info), 3231 info_(info),
3237 descriptor_(descriptor), 3232 descriptor_(descriptor),
3238 zone_(info->zone()), 3233 zone_(info->zone()),
3239 allow_code_motion_(false), 3234 allow_code_motion_(false),
3240 use_optimistic_licm_(false), 3235 use_optimistic_licm_(false),
3241 depends_on_empty_array_proto_elements_(false), 3236 depends_on_empty_array_proto_elements_(false),
3242 depends_on_string_length_overflow_(false), 3237 depends_on_string_length_overflow_(false),
3243 type_change_checksum_(0), 3238 type_change_checksum_(0),
3244 maximum_environment_size_(0), 3239 maximum_environment_size_(0),
3245 no_side_effects_scope_count_(0), 3240 no_side_effects_scope_count_(0),
3246 disallow_adding_new_values_(false), 3241 disallow_adding_new_values_(false) {
3247 inlined_function_infos_(info->zone()) {
3248 if (info->IsStub()) { 3242 if (info->IsStub()) {
3249 // For stubs, explicitly add the context to the environment. 3243 // For stubs, explicitly add the context to the environment.
3250 start_environment_ = 3244 start_environment_ =
3251 new (zone_) HEnvironment(zone_, descriptor.GetParameterCount() + 1); 3245 new (zone_) HEnvironment(zone_, descriptor.GetParameterCount() + 1);
3252 } else { 3246 } else {
3253 start_environment_ = 3247 start_environment_ =
3254 new(zone_) HEnvironment(NULL, info->scope(), info->closure(), zone_); 3248 new(zone_) HEnvironment(NULL, info->scope(), info->closure(), zone_);
3255 } 3249 }
3256 start_environment_->set_ast_id(BailoutId::FunctionContext()); 3250 start_environment_->set_ast_id(BailoutId::FunctionContext());
3257 entry_block_ = CreateBasicBlock(); 3251 entry_block_ = CreateBasicBlock();
(...skipping 11 matching lines...) Expand all
3269 void HGraph::FinalizeUniqueness() { 3263 void HGraph::FinalizeUniqueness() {
3270 DisallowHeapAllocation no_gc; 3264 DisallowHeapAllocation no_gc;
3271 for (int i = 0; i < blocks()->length(); ++i) { 3265 for (int i = 0; i < blocks()->length(); ++i) {
3272 for (HInstructionIterator it(blocks()->at(i)); !it.Done(); it.Advance()) { 3266 for (HInstructionIterator it(blocks()->at(i)); !it.Done(); it.Advance()) {
3273 it.Current()->FinalizeUniqueness(); 3267 it.Current()->FinalizeUniqueness();
3274 } 3268 }
3275 } 3269 }
3276 } 3270 }
3277 3271
3278 3272
3279 int HGraph::SourcePositionToScriptPosition(SourcePosition pos) {
3280 return (FLAG_hydrogen_track_positions && !pos.IsUnknown())
3281 ? inlined_function_infos_.at(pos.inlining_id()).start_position +
3282 pos.position()
3283 : pos.raw();
3284 }
3285
3286
3287 // Block ordering was implemented with two mutually recursive methods, 3273 // Block ordering was implemented with two mutually recursive methods,
3288 // HGraph::Postorder and HGraph::PostorderLoopBlocks. 3274 // HGraph::Postorder and HGraph::PostorderLoopBlocks.
3289 // The recursion could lead to stack overflow so the algorithm has been 3275 // The recursion could lead to stack overflow so the algorithm has been
3290 // implemented iteratively. 3276 // implemented iteratively.
3291 // At a high level the algorithm looks like this: 3277 // At a high level the algorithm looks like this:
3292 // 3278 //
3293 // Postorder(block, loop_header) : { 3279 // Postorder(block, loop_header) : {
3294 // if (block has already been visited or is of another loop) return; 3280 // if (block has already been visited or is of another loop) return;
3295 // mark block as visited; 3281 // mark block as visited;
3296 // if (block is a loop header) { 3282 // if (block is a loop header) {
(...skipping 404 matching lines...) Expand 10 before | Expand all | Expand 10 after
3701 } 3687 }
3702 // Set this after possibly allocating a new TestContext above. 3688 // Set this after possibly allocating a new TestContext above.
3703 call_context_ = owner->ast_context(); 3689 call_context_ = owner->ast_context();
3704 } 3690 }
3705 3691
3706 // Push on the state stack. 3692 // Push on the state stack.
3707 owner->set_function_state(this); 3693 owner->set_function_state(this);
3708 3694
3709 if (owner->is_tracking_positions()) { 3695 if (owner->is_tracking_positions()) {
3710 outer_source_position_ = owner->source_position(); 3696 outer_source_position_ = owner->source_position();
3711 owner->EnterInlinedSource( 3697 owner->EnterInlinedSource(inlining_id);
3712 info->shared_info()->start_position(),
3713 inlining_id);
3714 owner->SetSourcePosition(info->shared_info()->start_position()); 3698 owner->SetSourcePosition(info->shared_info()->start_position());
3715 } 3699 }
3716 } 3700 }
3717 3701
3718 3702
3719 FunctionState::~FunctionState() { 3703 FunctionState::~FunctionState() {
3720 delete test_context_; 3704 delete test_context_;
3721 owner_->set_function_state(outer_); 3705 owner_->set_function_state(outer_);
3722 3706
3723 if (owner_->is_tracking_positions()) { 3707 if (owner_->is_tracking_positions()) {
3724 owner_->set_source_position(outer_source_position_); 3708 owner_->set_source_position(outer_source_position_);
3725 owner_->EnterInlinedSource( 3709 owner_->EnterInlinedSource(outer_->inlining_id());
3726 outer_->compilation_info()->shared_info()->start_position(),
3727 outer_->inlining_id());
3728 } 3710 }
3729 } 3711 }
3730 3712
3731 3713
3732 // Implementation of utility classes to represent an expression's context in 3714 // Implementation of utility classes to represent an expression's context in
3733 // the AST. 3715 // the AST.
3734 AstContext::AstContext(HOptimizedGraphBuilder* owner, Expression::Context kind) 3716 AstContext::AstContext(HOptimizedGraphBuilder* owner, Expression::Context kind)
3735 : owner_(owner), 3717 : owner_(owner),
3736 kind_(kind), 3718 kind_(kind),
3737 outer_(owner->ast_context()), 3719 outer_(owner->ast_context()),
(...skipping 4391 matching lines...) Expand 10 before | Expand all | Expand 10 after
8129 // Generate the deoptimization data for the unoptimized version of 8111 // Generate the deoptimization data for the unoptimized version of
8130 // the target function if we don't already have it. 8112 // the target function if we don't already have it.
8131 if (!Compiler::EnsureDeoptimizationSupport(&target_info)) { 8113 if (!Compiler::EnsureDeoptimizationSupport(&target_info)) {
8132 TraceInline(target, caller, "could not generate deoptimization info"); 8114 TraceInline(target, caller, "could not generate deoptimization info");
8133 return false; 8115 return false;
8134 } 8116 }
8135 8117
8136 // Remember that we inlined this function. This needs to be called right 8118 // Remember that we inlined this function. This needs to be called right
8137 // after the EnsureDeoptimizationSupport call so that the code flusher 8119 // after the EnsureDeoptimizationSupport call so that the code flusher
8138 // does not remove the code with the deoptimization support. 8120 // does not remove the code with the deoptimization support.
8139 top_info()->AddInlinedFunction(target_info.shared_info()); 8121 int inlining_id = top_info()->AddInlinedFunction(target_info.shared_info(),
8122 source_position());
8140 8123
8141 // ---------------------------------------------------------------- 8124 // ----------------------------------------------------------------
8142 // After this point, we've made a decision to inline this function (so 8125 // After this point, we've made a decision to inline this function (so
8143 // TryInline should always return true). 8126 // TryInline should always return true).
8144 8127
8145 // If target was lazily compiled, it's literals array may not yet be set up. 8128 // If target was lazily compiled, it's literals array may not yet be set up.
8146 JSFunction::EnsureLiterals(target); 8129 JSFunction::EnsureLiterals(target);
8147 8130
8148 // Type-check the inlined function. 8131 // Type-check the inlined function.
8149 DCHECK(target_shared->has_deoptimization_support()); 8132 DCHECK(target_shared->has_deoptimization_support());
8150 AstTyper(target_info.isolate(), target_info.zone(), target_info.closure(), 8133 AstTyper(target_info.isolate(), target_info.zone(), target_info.closure(),
8151 target_info.scope(), target_info.osr_ast_id(), target_info.literal(), 8134 target_info.scope(), target_info.osr_ast_id(), target_info.literal(),
8152 &bounds_) 8135 &bounds_)
8153 .Run(); 8136 .Run();
8154 8137
8155 int inlining_id = 0;
8156 if (is_tracking_positions()) { 8138 if (is_tracking_positions()) {
8157 inlining_id = TraceInlinedFunction(target_shared, source_position()); 8139 TraceInlinedFunction(target_shared, source_position(), inlining_id);
8158 } 8140 }
8159 8141
8160 // Save the pending call context. Set up new one for the inlined function. 8142 // Save the pending call context. Set up new one for the inlined function.
8161 // The function state is new-allocated because we need to delete it 8143 // The function state is new-allocated because we need to delete it
8162 // in two different places. 8144 // in two different places.
8163 FunctionState* target_state = new FunctionState( 8145 FunctionState* target_state = new FunctionState(
8164 this, &target_info, inlining_kind, inlining_id, 8146 this, &target_info, inlining_kind, inlining_id,
8165 function_state()->ComputeTailCallMode(syntactic_tail_call_mode)); 8147 function_state()->ComputeTailCallMode(syntactic_tail_call_mode));
8166 8148
8167 HConstant* undefined = graph()->GetConstantUndefined(); 8149 HConstant* undefined = graph()->GetConstantUndefined();
(...skipping 30 matching lines...) Expand all
8198 current_block()->UpdateEnvironment(inner_env); 8180 current_block()->UpdateEnvironment(inner_env);
8199 Scope* saved_scope = scope(); 8181 Scope* saved_scope = scope();
8200 set_scope(target_info.scope()); 8182 set_scope(target_info.scope());
8201 HEnterInlined* enter_inlined = Add<HEnterInlined>( 8183 HEnterInlined* enter_inlined = Add<HEnterInlined>(
8202 return_id, target, context, arguments_count, function, 8184 return_id, target, context, arguments_count, function,
8203 function_state()->inlining_kind(), function->scope()->arguments(), 8185 function_state()->inlining_kind(), function->scope()->arguments(),
8204 arguments_object, syntactic_tail_call_mode); 8186 arguments_object, syntactic_tail_call_mode);
8205 if (is_tracking_positions()) { 8187 if (is_tracking_positions()) {
8206 enter_inlined->set_inlining_id(inlining_id); 8188 enter_inlined->set_inlining_id(inlining_id);
8207 } 8189 }
8190
8208 function_state()->set_entry(enter_inlined); 8191 function_state()->set_entry(enter_inlined);
8209 8192
8210 VisitDeclarations(target_info.scope()->declarations()); 8193 VisitDeclarations(target_info.scope()->declarations());
8211 VisitStatements(function->body()); 8194 VisitStatements(function->body());
8212 set_scope(saved_scope); 8195 set_scope(saved_scope);
8213 if (HasStackOverflow()) { 8196 if (HasStackOverflow()) {
8214 // Bail out if the inline function did, as we cannot residualize a call 8197 // Bail out if the inline function did, as we cannot residualize a call
8215 // instead, but do not disable optimization for the outer function. 8198 // instead, but do not disable optimization for the outer function.
8216 TraceInline(target, caller, "inline graph construction failed"); 8199 TraceInline(target, caller, "inline graph construction failed");
8217 target_shared->DisableOptimization(kInliningBailedOut); 8200 target_shared->DisableOptimization(kInliningBailedOut);
(...skipping 2905 matching lines...) Expand 10 before | Expand all | Expand 10 after
11123 void HOptimizedGraphBuilder::VisitArithmeticExpression(BinaryOperation* expr) { 11106 void HOptimizedGraphBuilder::VisitArithmeticExpression(BinaryOperation* expr) {
11124 CHECK_ALIVE(VisitForValue(expr->left())); 11107 CHECK_ALIVE(VisitForValue(expr->left()));
11125 CHECK_ALIVE(VisitForValue(expr->right())); 11108 CHECK_ALIVE(VisitForValue(expr->right()));
11126 SetSourcePosition(expr->position()); 11109 SetSourcePosition(expr->position());
11127 HValue* right = Pop(); 11110 HValue* right = Pop();
11128 HValue* left = Pop(); 11111 HValue* left = Pop();
11129 HValue* result = 11112 HValue* result =
11130 BuildBinaryOperation(expr, left, right, 11113 BuildBinaryOperation(expr, left, right,
11131 ast_context()->IsEffect() ? NO_PUSH_BEFORE_SIMULATE 11114 ast_context()->IsEffect() ? NO_PUSH_BEFORE_SIMULATE
11132 : PUSH_BEFORE_SIMULATE); 11115 : PUSH_BEFORE_SIMULATE);
11133 if (is_tracking_positions() && result->IsBinaryOperation()) {
11134 HBinaryOperation::cast(result)->SetOperandPositions(
11135 zone(),
11136 ScriptPositionToSourcePosition(expr->left()->position()),
11137 ScriptPositionToSourcePosition(expr->right()->position()));
11138 }
11139 return ast_context()->ReturnValue(result); 11116 return ast_context()->ReturnValue(result);
11140 } 11117 }
11141 11118
11142 11119
11143 void HOptimizedGraphBuilder::HandleLiteralCompareTypeof(CompareOperation* expr, 11120 void HOptimizedGraphBuilder::HandleLiteralCompareTypeof(CompareOperation* expr,
11144 Expression* sub_expr, 11121 Expression* sub_expr,
11145 Handle<String> check) { 11122 Handle<String> check) {
11146 CHECK_ALIVE(VisitForTypeOf(sub_expr)); 11123 CHECK_ALIVE(VisitForTypeOf(sub_expr));
11147 SetSourcePosition(expr->position()); 11124 SetSourcePosition(expr->position());
11148 HValue* value = Pop(); 11125 HValue* value = Pop();
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after
11308 return New<HBranch>(graph()->GetConstantTrue()); 11285 return New<HBranch>(graph()->GetConstantTrue());
11309 } 11286 }
11310 // Can we get away with map check and not instance type check? 11287 // Can we get away with map check and not instance type check?
11311 HValue* operand_to_check = 11288 HValue* operand_to_check =
11312 left->block()->block_id() < right->block()->block_id() ? left : right; 11289 left->block()->block_id() < right->block()->block_id() ? left : right;
11313 if (combined_type->IsClass()) { 11290 if (combined_type->IsClass()) {
11314 Handle<Map> map = combined_type->AsClass()->Map(); 11291 Handle<Map> map = combined_type->AsClass()->Map();
11315 AddCheckMap(operand_to_check, map); 11292 AddCheckMap(operand_to_check, map);
11316 HCompareObjectEqAndBranch* result = 11293 HCompareObjectEqAndBranch* result =
11317 New<HCompareObjectEqAndBranch>(left, right); 11294 New<HCompareObjectEqAndBranch>(left, right);
11318 if (is_tracking_positions()) {
11319 result->set_operand_position(zone(), 0, left_position);
11320 result->set_operand_position(zone(), 1, right_position);
11321 }
11322 return result; 11295 return result;
11323 } else { 11296 } else {
11324 BuildCheckHeapObject(operand_to_check); 11297 BuildCheckHeapObject(operand_to_check);
11325 Add<HCheckInstanceType>(operand_to_check, 11298 Add<HCheckInstanceType>(operand_to_check,
11326 HCheckInstanceType::IS_JS_RECEIVER); 11299 HCheckInstanceType::IS_JS_RECEIVER);
11327 HCompareObjectEqAndBranch* result = 11300 HCompareObjectEqAndBranch* result =
11328 New<HCompareObjectEqAndBranch>(left, right); 11301 New<HCompareObjectEqAndBranch>(left, right);
11329 return result; 11302 return result;
11330 } 11303 }
11331 } else { 11304 } else {
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
11451 AddSimulate(bailout_id, REMOVABLE_SIMULATE); 11424 AddSimulate(bailout_id, REMOVABLE_SIMULATE);
11452 } 11425 }
11453 } 11426 }
11454 // TODO(jkummerow): Can we make this more efficient? 11427 // TODO(jkummerow): Can we make this more efficient?
11455 HBranch* branch = New<HBranch>(result); 11428 HBranch* branch = New<HBranch>(result);
11456 return branch; 11429 return branch;
11457 } else { 11430 } else {
11458 HCompareNumericAndBranch* result = 11431 HCompareNumericAndBranch* result =
11459 New<HCompareNumericAndBranch>(left, right, op); 11432 New<HCompareNumericAndBranch>(left, right, op);
11460 result->set_observed_input_representation(left_rep, right_rep); 11433 result->set_observed_input_representation(left_rep, right_rep);
11461 if (is_tracking_positions()) {
11462 result->SetOperandPositions(zone(), left_position, right_position);
11463 }
11464 return result; 11434 return result;
11465 } 11435 }
11466 } 11436 }
11467 } 11437 }
11468 11438
11469 11439
11470 void HOptimizedGraphBuilder::HandleLiteralCompareNil(CompareOperation* expr, 11440 void HOptimizedGraphBuilder::HandleLiteralCompareNil(CompareOperation* expr,
11471 Expression* sub_expr, 11441 Expression* sub_expr,
11472 NilValue nil) { 11442 NilValue nil) {
11473 DCHECK(!HasStackOverflow()); 11443 DCHECK(!HasStackOverflow());
(...skipping 1348 matching lines...) Expand 10 before | Expand all | Expand 10 after
12822 } 12792 }
12823 12793
12824 { 12794 {
12825 Tag HIR_tag(this, "HIR"); 12795 Tag HIR_tag(this, "HIR");
12826 for (HInstructionIterator it(current); !it.Done(); it.Advance()) { 12796 for (HInstructionIterator it(current); !it.Done(); it.Advance()) {
12827 HInstruction* instruction = it.Current(); 12797 HInstruction* instruction = it.Current();
12828 int uses = instruction->UseCount(); 12798 int uses = instruction->UseCount();
12829 PrintIndent(); 12799 PrintIndent();
12830 std::ostringstream os; 12800 std::ostringstream os;
12831 os << "0 " << uses << " " << NameOf(instruction) << " " << *instruction; 12801 os << "0 " << uses << " " << NameOf(instruction) << " " << *instruction;
12832 if (instruction->has_position() && instruction->position().raw() != 0) { 12802 if (instruction->has_position()) {
12833 const SourcePosition pos = instruction->position(); 12803 const SourcePosition pos = instruction->position();
12834 os << " pos:"; 12804 os << " pos:";
12835 if (pos.inlining_id() != 0) os << pos.inlining_id() << "_"; 12805 if (pos.isInlined()) os << "inlining(" << pos.InliningId() << "),";
12836 os << pos.position(); 12806 os << pos.ScriptOffset();
12837 } 12807 }
12838 os << " <|@\n"; 12808 os << " <|@\n";
12839 trace_.Add(os.str().c_str()); 12809 trace_.Add(os.str().c_str());
12840 } 12810 }
12841 } 12811 }
12842 12812
12843 12813
12844 if (chunk != NULL) { 12814 if (chunk != NULL) {
12845 Tag LIR_tag(this, "LIR"); 12815 Tag LIR_tag(this, "LIR");
12846 int first_index = current->first_instruction_index(); 12816 int first_index = current->first_instruction_index();
(...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after
13033 isolate()->GetHTracer()->TraceHydrogen(name(), graph_); 13003 isolate()->GetHTracer()->TraceHydrogen(name(), graph_);
13034 } 13004 }
13035 13005
13036 #ifdef DEBUG 13006 #ifdef DEBUG
13037 graph_->Verify(false); // No full verify. 13007 graph_->Verify(false); // No full verify.
13038 #endif 13008 #endif
13039 } 13009 }
13040 13010
13041 } // namespace internal 13011 } // namespace internal
13042 } // namespace v8 13012 } // namespace v8
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698