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

Side by Side Diff: src/compiler/ast-graph-builder.cc

Issue 1306993003: Call JS functions via native context instead of js builtins object. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: separated context slot lookup Created 5 years, 3 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 2014 the V8 project authors. All rights reserved. 1 // Copyright 2014 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/compiler/ast-graph-builder.h" 5 #include "src/compiler/ast-graph-builder.h"
6 6
7 #include "src/compiler.h" 7 #include "src/compiler.h"
8 #include "src/compiler/ast-loop-assignment-analyzer.h" 8 #include "src/compiler/ast-loop-assignment-analyzer.h"
9 #include "src/compiler/control-builders.h" 9 #include "src/compiler/control-builders.h"
10 #include "src/compiler/js-type-feedback.h" 10 #include "src/compiler/js-type-feedback.h"
(...skipping 2520 matching lines...) Expand 10 before | Expand all | Expand 10 after
2531 2531
2532 // Create node to perform the construct call. 2532 // Create node to perform the construct call.
2533 const Operator* call = javascript()->CallConstruct(args->length() + 2); 2533 const Operator* call = javascript()->CallConstruct(args->length() + 2);
2534 Node* value = ProcessArguments(call, args->length() + 2); 2534 Node* value = ProcessArguments(call, args->length() + 2);
2535 PrepareFrameState(value, expr->id(), ast_context()->GetStateCombine()); 2535 PrepareFrameState(value, expr->id(), ast_context()->GetStateCombine());
2536 ast_context()->ProduceValue(value); 2536 ast_context()->ProduceValue(value);
2537 } 2537 }
2538 2538
2539 2539
2540 void AstGraphBuilder::VisitCallJSRuntime(CallRuntime* expr) { 2540 void AstGraphBuilder::VisitCallJSRuntime(CallRuntime* expr) {
2541 Handle<String> name = expr->name();
2542
2543 // The callee and the receiver both have to be pushed onto the operand stack 2541 // The callee and the receiver both have to be pushed onto the operand stack
2544 // before arguments are being evaluated. 2542 // before arguments are being evaluated.
2545 CallFunctionFlags flags = NO_CALL_FUNCTION_FLAGS; 2543 CallFunctionFlags flags = NO_CALL_FUNCTION_FLAGS;
2546 Node* receiver_value = BuildLoadBuiltinsObject(); 2544 Node* global = BuildLoadGlobalObject();
2547 VectorSlotPair pair = CreateVectorSlotPair(expr->CallRuntimeFeedbackSlot()); 2545 Node* native_context =
2548 // TODO(jarin): bailout ids for runtime calls. 2546 BuildLoadObjectField(global, GlobalObject::kNativeContextOffset);
2549 FrameStateBeforeAndAfter states(this, BailoutId::None()); 2547 Node* callee_value =
2550 Node* callee_value = BuildNamedLoad(receiver_value, name, pair); 2548 NewNode(javascript()->LoadContext(0, expr->context_index(), true),
2551 states.AddToNode(callee_value, BailoutId::None(), 2549 native_context);
2552 OutputFrameStateCombine::Push()); 2550
2553 environment()->Push(callee_value); 2551 environment()->Push(callee_value);
2554 environment()->Push(receiver_value); 2552 environment()->Push(jsgraph()->UndefinedConstant());
Michael Starzinger 2015/08/26 09:43:21 nit: Let's add a trailing "// receiver" comment, o
Yang 2015/08/26 10:27:30 Done.
2555 2553
2556 // Evaluate all arguments to the JS runtime call. 2554 // Evaluate all arguments to the JS runtime call.
2557 ZoneList<Expression*>* args = expr->arguments(); 2555 ZoneList<Expression*>* args = expr->arguments();
2558 VisitForValues(args); 2556 VisitForValues(args);
2559 2557
2560 // Create node to perform the JS runtime call. 2558 // Create node to perform the JS runtime call.
2561 const Operator* call = 2559 const Operator* call =
2562 javascript()->CallFunction(args->length() + 2, flags, language_mode()); 2560 javascript()->CallFunction(args->length() + 2, flags, language_mode());
2563 Node* value = ProcessArguments(call, args->length() + 2); 2561 Node* value = ProcessArguments(call, args->length() + 2);
2564 PrepareFrameState(value, expr->id(), ast_context()->GetStateCombine()); 2562 PrepareFrameState(value, expr->id(), ast_context()->GetStateCombine());
2565 ast_context()->ProduceValue(value); 2563 ast_context()->ProduceValue(value);
2566 } 2564 }
2567 2565
2568 2566
2569 void AstGraphBuilder::VisitCallRuntime(CallRuntime* expr) { 2567 void AstGraphBuilder::VisitCallRuntime(CallRuntime* expr) {
2570 const Runtime::Function* function = expr->function();
2571
2572 // Handle calls to runtime functions implemented in JavaScript separately as 2568 // Handle calls to runtime functions implemented in JavaScript separately as
2573 // the call follows JavaScript ABI and the callee is statically unknown. 2569 // the call follows JavaScript ABI and the callee is statically unknown.
2574 if (expr->is_jsruntime()) { 2570 if (expr->is_jsruntime()) {
2575 DCHECK(function == NULL && expr->name()->length() > 0);
2576 return VisitCallJSRuntime(expr); 2571 return VisitCallJSRuntime(expr);
2577 } 2572 }
2578 2573
2574 const Runtime::Function* function = expr->function();
2575
2579 // TODO(mstarzinger): This bailout is a gigantic hack, the owner is ashamed. 2576 // TODO(mstarzinger): This bailout is a gigantic hack, the owner is ashamed.
2580 if (function->function_id == Runtime::kInlineGeneratorNext || 2577 if (function->function_id == Runtime::kInlineGeneratorNext ||
2581 function->function_id == Runtime::kInlineGeneratorThrow) { 2578 function->function_id == Runtime::kInlineGeneratorThrow) {
2582 ast_context()->ProduceValue(jsgraph()->TheHoleConstant()); 2579 ast_context()->ProduceValue(jsgraph()->TheHoleConstant());
2583 return SetStackOverflow(); 2580 return SetStackOverflow();
2584 } 2581 }
2585 2582
2586 // Evaluate all arguments to the runtime call. 2583 // Evaluate all arguments to the runtime call.
2587 ZoneList<Expression*>* args = expr->arguments(); 2584 ZoneList<Expression*>* args = expr->arguments();
2588 VisitForValues(args); 2585 VisitForValues(args);
(...skipping 1713 matching lines...) Expand 10 before | Expand all | Expand 10 after
4302 // Phi does not exist yet, introduce one. 4299 // Phi does not exist yet, introduce one.
4303 value = NewPhi(inputs, value, control); 4300 value = NewPhi(inputs, value, control);
4304 value->ReplaceInput(inputs - 1, other); 4301 value->ReplaceInput(inputs - 1, other);
4305 } 4302 }
4306 return value; 4303 return value;
4307 } 4304 }
4308 4305
4309 } // namespace compiler 4306 } // namespace compiler
4310 } // namespace internal 4307 } // namespace internal
4311 } // namespace v8 4308 } // namespace v8
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698