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

Side by Side Diff: src/interpreter/bytecode-generator.cc

Issue 1396693003: [Interpreter] Add function literal support. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@int_newcontext
Patch Set: Make CreateClosure a bytecode Created 5 years, 2 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 2015 the V8 project authors. All rights reserved. 1 // Copyright 2015 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/interpreter/bytecode-generator.h" 5 #include "src/interpreter/bytecode-generator.h"
6 6
7 #include <stack> 7 #include <stack>
8 8
9 #include "src/compiler.h" 9 #include "src/compiler.h"
10 #include "src/interpreter/control-flow-builders.h" 10 #include "src/interpreter/control-flow-builders.h"
(...skipping 427 matching lines...) Expand 10 before | Expand all | Expand 10 after
438 UNIMPLEMENTED(); 438 UNIMPLEMENTED();
439 } 439 }
440 440
441 441
442 void BytecodeGenerator::VisitDebuggerStatement(DebuggerStatement* stmt) { 442 void BytecodeGenerator::VisitDebuggerStatement(DebuggerStatement* stmt) {
443 UNIMPLEMENTED(); 443 UNIMPLEMENTED();
444 } 444 }
445 445
446 446
447 void BytecodeGenerator::VisitFunctionLiteral(FunctionLiteral* expr) { 447 void BytecodeGenerator::VisitFunctionLiteral(FunctionLiteral* expr) {
448 UNIMPLEMENTED(); 448 // Find or build a shared function info.
449 Handle<SharedFunctionInfo> shared_info =
450 Compiler::GetSharedFunctionInfo(expr, info()->script(), info());
451 CHECK(!shared_info.is_null()); // TODO(rmcilroy): Set stack overflow?
Michael Starzinger 2015/10/09 13:19:00 Yeah, that same check in the AstGraphBuilder bothe
rmcilroy 2015/10/12 17:00:15 Yeah I've never seen this myself. I'll let you kno
452
453 builder()
454 ->LoadLiteral(shared_info)
455 .CreateClosure(expr->pretenure() ? TENURED : NOT_TENURED);
449 } 456 }
450 457
451 458
452 void BytecodeGenerator::VisitClassLiteral(ClassLiteral* expr) { 459 void BytecodeGenerator::VisitClassLiteral(ClassLiteral* expr) {
453 UNIMPLEMENTED(); 460 UNIMPLEMENTED();
454 } 461 }
455 462
456 463
457 void BytecodeGenerator::VisitNativeFunctionLiteral( 464 void BytecodeGenerator::VisitNativeFunctionLiteral(
458 NativeFunctionLiteral* expr) { 465 NativeFunctionLiteral* expr) {
(...skipping 264 matching lines...) Expand 10 before | Expand all | Expand 10 after
723 } 730 }
724 case Call::GLOBAL_CALL: { 731 case Call::GLOBAL_CALL: {
725 // Receiver is undefined for global calls. 732 // Receiver is undefined for global calls.
726 builder()->LoadUndefined().StoreAccumulatorInRegister(receiver); 733 builder()->LoadUndefined().StoreAccumulatorInRegister(receiver);
727 // Load callee as a global variable. 734 // Load callee as a global variable.
728 VariableProxy* proxy = callee_expr->AsVariableProxy(); 735 VariableProxy* proxy = callee_expr->AsVariableProxy();
729 VisitVariableLoad(proxy->var(), proxy->VariableFeedbackSlot()); 736 VisitVariableLoad(proxy->var(), proxy->VariableFeedbackSlot());
730 builder()->StoreAccumulatorInRegister(callee); 737 builder()->StoreAccumulatorInRegister(callee);
731 break; 738 break;
732 } 739 }
740 case Call::OTHER_CALL: {
741 Visit(callee_expr);
742 builder()->StoreAccumulatorInRegister(callee);
743 builder()->LoadUndefined().StoreAccumulatorInRegister(receiver);
Michael Starzinger 2015/10/09 13:19:00 nit: I don't think it matters much, since we don't
Michael Starzinger 2015/10/09 13:28:01 Actually, I just checked again and we already in f
rmcilroy 2015/10/12 17:00:15 It doesn't actually matter which way round this go
744 break;
745 }
733 case Call::LOOKUP_SLOT_CALL: 746 case Call::LOOKUP_SLOT_CALL:
734 case Call::SUPER_CALL: 747 case Call::SUPER_CALL:
735 case Call::POSSIBLY_EVAL_CALL: 748 case Call::POSSIBLY_EVAL_CALL:
736 case Call::OTHER_CALL:
737 UNIMPLEMENTED(); 749 UNIMPLEMENTED();
738 } 750 }
739 751
740 // Evaluate all arguments to the function call and store in sequential 752 // Evaluate all arguments to the function call and store in sequential
741 // registers. 753 // registers.
742 ZoneList<Expression*>* args = expr->arguments(); 754 ZoneList<Expression*>* args = expr->arguments();
743 for (int i = 0; i < args->length(); ++i) { 755 for (int i = 0; i < args->length(); ++i) {
744 Visit(args->at(i)); 756 Visit(args->at(i));
745 Register arg = temporary_register_scope.NewRegister(); 757 Register arg = temporary_register_scope.NewRegister();
746 DCHECK(arg.index() - i == receiver.index() + 1); 758 DCHECK(arg.index() - i == receiver.index() + 1);
(...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after
938 } 950 }
939 951
940 952
941 int BytecodeGenerator::feedback_index(FeedbackVectorSlot slot) const { 953 int BytecodeGenerator::feedback_index(FeedbackVectorSlot slot) const {
942 return info()->feedback_vector()->GetIndex(slot); 954 return info()->feedback_vector()->GetIndex(slot);
943 } 955 }
944 956
945 } // namespace interpreter 957 } // namespace interpreter
946 } // namespace internal 958 } // namespace internal
947 } // namespace v8 959 } // namespace v8
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698