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/hydrogen.h" | 5 #include "src/hydrogen.h" |
6 | 6 |
7 #include <sstream> | 7 #include <sstream> |
8 | 8 |
9 #include "src/v8.h" | 9 #include "src/v8.h" |
10 | 10 |
(...skipping 3432 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3443 uint32_instructions_(NULL), | 3443 uint32_instructions_(NULL), |
3444 osr_(NULL), | 3444 osr_(NULL), |
3445 info_(info), | 3445 info_(info), |
3446 zone_(info->zone()), | 3446 zone_(info->zone()), |
3447 is_recursive_(false), | 3447 is_recursive_(false), |
3448 use_optimistic_licm_(false), | 3448 use_optimistic_licm_(false), |
3449 depends_on_empty_array_proto_elements_(false), | 3449 depends_on_empty_array_proto_elements_(false), |
3450 type_change_checksum_(0), | 3450 type_change_checksum_(0), |
3451 maximum_environment_size_(0), | 3451 maximum_environment_size_(0), |
3452 no_side_effects_scope_count_(0), | 3452 no_side_effects_scope_count_(0), |
3453 disallow_adding_new_values_(false), | 3453 disallow_adding_new_values_(false) { |
3454 inlined_functions_(FLAG_hydrogen_track_positions ? 5 : 0, info->zone()), | |
3455 inlining_id_to_function_id_(FLAG_hydrogen_track_positions ? 5 : 0, | |
3456 info->zone()) { | |
3457 if (info->IsStub()) { | 3454 if (info->IsStub()) { |
3458 CallInterfaceDescriptor descriptor = | 3455 CallInterfaceDescriptor descriptor = |
3459 info->code_stub()->GetCallInterfaceDescriptor(); | 3456 info->code_stub()->GetCallInterfaceDescriptor(); |
3460 start_environment_ = new (zone_) | 3457 start_environment_ = new (zone_) |
3461 HEnvironment(zone_, descriptor.GetEnvironmentParameterCount()); | 3458 HEnvironment(zone_, descriptor.GetEnvironmentParameterCount()); |
3462 } else { | 3459 } else { |
3463 TraceInlinedFunction(info->shared_info(), HSourcePosition::Unknown()); | 3460 TraceInlinedFunction(info->shared_info(), HSourcePosition::Unknown()); |
3464 start_environment_ = | 3461 start_environment_ = |
3465 new(zone_) HEnvironment(NULL, info->scope(), info->closure(), zone_); | 3462 new(zone_) HEnvironment(NULL, info->scope(), info->closure(), zone_); |
3466 } | 3463 } |
(...skipping 21 matching lines...) Expand all Loading... | |
3488 } | 3485 } |
3489 | 3486 |
3490 | 3487 |
3491 int HGraph::TraceInlinedFunction( | 3488 int HGraph::TraceInlinedFunction( |
3492 Handle<SharedFunctionInfo> shared, | 3489 Handle<SharedFunctionInfo> shared, |
3493 HSourcePosition position) { | 3490 HSourcePosition position) { |
3494 if (!FLAG_hydrogen_track_positions) { | 3491 if (!FLAG_hydrogen_track_positions) { |
3495 return 0; | 3492 return 0; |
3496 } | 3493 } |
3497 | 3494 |
3498 int id = 0; | 3495 int id = info()->GetInlinedFunctionId(shared); |
3499 for (; id < inlined_functions_.length(); id++) { | |
3500 if (inlined_functions_[id].shared().is_identical_to(shared)) { | |
3501 break; | |
3502 } | |
3503 } | |
3504 | 3496 |
3505 if (id == inlined_functions_.length()) { | 3497 int inline_id = info()->inlining_id_to_function_id()->length(); |
Vyacheslav Egorov (Google)
2015/02/16 13:38:50
Should not all this code be also moved into GetInl
loislo
2015/02/16 14:48:32
Done.
| |
3506 inlined_functions_.Add(InlinedFunctionInfo(shared), zone()); | 3498 info()->inlining_id_to_function_id()->Add(id); |
3507 | |
3508 if (!shared->script()->IsUndefined()) { | |
3509 Handle<Script> script(Script::cast(shared->script())); | |
3510 if (!script->source()->IsUndefined()) { | |
3511 CodeTracer::Scope tracing_scopex(isolate()->GetCodeTracer()); | |
3512 OFStream os(tracing_scopex.file()); | |
3513 os << "--- FUNCTION SOURCE (" << shared->DebugName()->ToCString().get() | |
3514 << ") id{" << info()->optimization_id() << "," << id << "} ---\n"; | |
3515 { | |
3516 DisallowHeapAllocation no_allocation; | |
3517 int start = shared->start_position(); | |
3518 int len = shared->end_position() - start + 1; | |
3519 String::SubStringRange source(String::cast(script->source()), start, | |
3520 len); | |
3521 for (const auto& c : source) { | |
3522 os << AsReversiblyEscapedUC16(c); | |
3523 } | |
3524 } | |
3525 | |
3526 os << "\n--- END ---\n"; | |
3527 } | |
3528 } | |
3529 } | |
3530 | |
3531 int inline_id = inlining_id_to_function_id_.length(); | |
3532 inlining_id_to_function_id_.Add(id, zone()); | |
3533 | 3499 |
3534 if (inline_id != 0) { | 3500 if (inline_id != 0) { |
3535 CodeTracer::Scope tracing_scope(isolate()->GetCodeTracer()); | 3501 CodeTracer::Scope tracing_scope(isolate()->GetCodeTracer()); |
3536 OFStream os(tracing_scope.file()); | 3502 OFStream os(tracing_scope.file()); |
3537 os << "INLINE (" << shared->DebugName()->ToCString().get() << ") id{" | 3503 os << "INLINE (" << shared->DebugName()->ToCString().get() << ") id{" |
3538 << info()->optimization_id() << "," << id << "} AS " << inline_id | 3504 << info()->optimization_id() << "," << id << "} AS " << inline_id |
3539 << " AT " << position << std::endl; | 3505 << " AT " << position << std::endl; |
3540 } | 3506 } |
3541 | 3507 |
3542 return inline_id; | 3508 return inline_id; |
3543 } | 3509 } |
3544 | 3510 |
3545 | 3511 |
3546 int HGraph::SourcePositionToScriptPosition(HSourcePosition pos) { | 3512 int HGraph::SourcePositionToScriptPosition(HSourcePosition pos) { |
3547 if (!FLAG_hydrogen_track_positions || pos.IsUnknown()) { | 3513 if (!FLAG_hydrogen_track_positions || pos.IsUnknown()) { |
3548 return pos.raw(); | 3514 return pos.raw(); |
3549 } | 3515 } |
3550 | 3516 |
3551 const int id = inlining_id_to_function_id_[pos.inlining_id()]; | 3517 const int id = info()->inlining_id_to_function_id()->at(pos.inlining_id()); |
3552 return inlined_functions_[id].start_position() + pos.position(); | 3518 return info()->inlined_function_infos()->at(id).start_position() + |
3519 pos.position(); | |
3553 } | 3520 } |
3554 | 3521 |
3555 | 3522 |
3556 // Block ordering was implemented with two mutually recursive methods, | 3523 // Block ordering was implemented with two mutually recursive methods, |
3557 // HGraph::Postorder and HGraph::PostorderLoopBlocks. | 3524 // HGraph::Postorder and HGraph::PostorderLoopBlocks. |
3558 // The recursion could lead to stack overflow so the algorithm has been | 3525 // The recursion could lead to stack overflow so the algorithm has been |
3559 // implemented iteratively. | 3526 // implemented iteratively. |
3560 // At a high level the algorithm looks like this: | 3527 // At a high level the algorithm looks like this: |
3561 // | 3528 // |
3562 // Postorder(block, loop_header) : { | 3529 // Postorder(block, loop_header) : { |
(...skipping 9951 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
13514 if (ShouldProduceTraceOutput()) { | 13481 if (ShouldProduceTraceOutput()) { |
13515 isolate()->GetHTracer()->TraceHydrogen(name(), graph_); | 13482 isolate()->GetHTracer()->TraceHydrogen(name(), graph_); |
13516 } | 13483 } |
13517 | 13484 |
13518 #ifdef DEBUG | 13485 #ifdef DEBUG |
13519 graph_->Verify(false); // No full verify. | 13486 graph_->Verify(false); // No full verify. |
13520 #endif | 13487 #endif |
13521 } | 13488 } |
13522 | 13489 |
13523 } } // namespace v8::internal | 13490 } } // namespace v8::internal |
OLD | NEW |