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 10463 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
10474 view, nullptr, | 10474 view, nullptr, |
10475 FieldIndex::ForInObjectOffset(JSTypedArray::kLengthOffset))); | 10475 FieldIndex::ForInObjectOffset(JSTypedArray::kLengthOffset))); |
10476 } | 10476 } |
10477 | 10477 |
10478 | 10478 |
10479 void HOptimizedGraphBuilder::VisitCallRuntime(CallRuntime* expr) { | 10479 void HOptimizedGraphBuilder::VisitCallRuntime(CallRuntime* expr) { |
10480 DCHECK(!HasStackOverflow()); | 10480 DCHECK(!HasStackOverflow()); |
10481 DCHECK(current_block() != NULL); | 10481 DCHECK(current_block() != NULL); |
10482 DCHECK(current_block()->HasPredecessor()); | 10482 DCHECK(current_block()->HasPredecessor()); |
10483 if (expr->is_jsruntime()) { | 10483 if (expr->is_jsruntime()) { |
| 10484 // Crankshaft always specializes to the native context, so we can just grab |
| 10485 // the constant function from the current native context and embed that into |
| 10486 // the code object. |
| 10487 Handle<JSFunction> known_function( |
| 10488 JSFunction::cast( |
| 10489 current_info()->native_context()->get(expr->context_index())), |
| 10490 isolate()); |
| 10491 |
10484 // The callee and the receiver both have to be pushed onto the operand stack | 10492 // The callee and the receiver both have to be pushed onto the operand stack |
10485 // before arguments are being evaluated. | 10493 // before arguments are being evaluated. |
10486 HValue* function = AddLoadJSBuiltin(expr->context_index()); | 10494 HConstant* function = Add<HConstant>(known_function); |
10487 HValue* receiver = graph()->GetConstantUndefined(); | 10495 HValue* receiver = ImplicitReceiverFor(function, known_function); |
10488 Push(function); | 10496 Push(function); |
10489 Push(receiver); | 10497 Push(receiver); |
10490 | 10498 |
10491 int argument_count = expr->arguments()->length() + 1; // Count receiver. | 10499 int argument_count = expr->arguments()->length() + 1; // Count receiver. |
10492 CHECK_ALIVE(VisitExpressions(expr->arguments())); | 10500 CHECK_ALIVE(VisitExpressions(expr->arguments())); |
10493 PushArgumentsFromEnvironment(argument_count); | 10501 PushArgumentsFromEnvironment(argument_count); |
10494 HInstruction* call = NewCallFunction(function, argument_count, | 10502 HInstruction* call = NewCallConstantFunction(known_function, argument_count, |
10495 ConvertReceiverMode::kNullOrUndefined, | 10503 TailCallMode::kDisallow); |
10496 TailCallMode::kDisallow); | |
10497 Drop(1); // Function | 10504 Drop(1); // Function |
10498 return ast_context()->ReturnInstruction(call, expr->id()); | 10505 return ast_context()->ReturnInstruction(call, expr->id()); |
10499 } | 10506 } |
10500 | 10507 |
10501 const Runtime::Function* function = expr->function(); | 10508 const Runtime::Function* function = expr->function(); |
10502 DCHECK(function != NULL); | 10509 DCHECK(function != NULL); |
10503 switch (function->function_id) { | 10510 switch (function->function_id) { |
10504 #define CALL_INTRINSIC_GENERATOR(Name) \ | 10511 #define CALL_INTRINSIC_GENERATOR(Name) \ |
10505 case Runtime::kInline##Name: \ | 10512 case Runtime::kInline##Name: \ |
10506 return Generate##Name(expr); | 10513 return Generate##Name(expr); |
(...skipping 3006 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
13513 isolate()->GetHTracer()->TraceHydrogen(name(), graph_); | 13520 isolate()->GetHTracer()->TraceHydrogen(name(), graph_); |
13514 } | 13521 } |
13515 | 13522 |
13516 #ifdef DEBUG | 13523 #ifdef DEBUG |
13517 graph_->Verify(false); // No full verify. | 13524 graph_->Verify(false); // No full verify. |
13518 #endif | 13525 #endif |
13519 } | 13526 } |
13520 | 13527 |
13521 } // namespace internal | 13528 } // namespace internal |
13522 } // namespace v8 | 13529 } // namespace v8 |
OLD | NEW |