OLD | NEW |
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 376 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
387 UNIMPLEMENTED(); | 387 UNIMPLEMENTED(); |
388 } | 388 } |
389 | 389 |
390 | 390 |
391 void BytecodeGenerator::VisitDebuggerStatement(DebuggerStatement* stmt) { | 391 void BytecodeGenerator::VisitDebuggerStatement(DebuggerStatement* stmt) { |
392 UNIMPLEMENTED(); | 392 UNIMPLEMENTED(); |
393 } | 393 } |
394 | 394 |
395 | 395 |
396 void BytecodeGenerator::VisitFunctionLiteral(FunctionLiteral* expr) { | 396 void BytecodeGenerator::VisitFunctionLiteral(FunctionLiteral* expr) { |
397 UNIMPLEMENTED(); | 397 // Find or build a shared function info. |
| 398 Handle<SharedFunctionInfo> shared_info = |
| 399 Compiler::GetSharedFunctionInfo(expr, info()->script(), info()); |
| 400 CHECK(!shared_info.is_null()); // TODO(rmcilroy): Set stack overflow? |
| 401 |
| 402 builder() |
| 403 ->LoadLiteral(shared_info) |
| 404 .CreateClosure(expr->pretenure() ? TENURED : NOT_TENURED); |
398 } | 405 } |
399 | 406 |
400 | 407 |
401 void BytecodeGenerator::VisitClassLiteral(ClassLiteral* expr) { | 408 void BytecodeGenerator::VisitClassLiteral(ClassLiteral* expr) { |
402 UNIMPLEMENTED(); | 409 UNIMPLEMENTED(); |
403 } | 410 } |
404 | 411 |
405 | 412 |
406 void BytecodeGenerator::VisitNativeFunctionLiteral( | 413 void BytecodeGenerator::VisitNativeFunctionLiteral( |
407 NativeFunctionLiteral* expr) { | 414 NativeFunctionLiteral* expr) { |
(...skipping 264 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
672 } | 679 } |
673 case Call::GLOBAL_CALL: { | 680 case Call::GLOBAL_CALL: { |
674 // Receiver is undefined for global calls. | 681 // Receiver is undefined for global calls. |
675 builder()->LoadUndefined().StoreAccumulatorInRegister(receiver); | 682 builder()->LoadUndefined().StoreAccumulatorInRegister(receiver); |
676 // Load callee as a global variable. | 683 // Load callee as a global variable. |
677 VariableProxy* proxy = callee_expr->AsVariableProxy(); | 684 VariableProxy* proxy = callee_expr->AsVariableProxy(); |
678 VisitVariableLoad(proxy->var(), proxy->VariableFeedbackSlot()); | 685 VisitVariableLoad(proxy->var(), proxy->VariableFeedbackSlot()); |
679 builder()->StoreAccumulatorInRegister(callee); | 686 builder()->StoreAccumulatorInRegister(callee); |
680 break; | 687 break; |
681 } | 688 } |
| 689 case Call::OTHER_CALL: { |
| 690 builder()->LoadUndefined().StoreAccumulatorInRegister(receiver); |
| 691 Visit(callee_expr); |
| 692 builder()->StoreAccumulatorInRegister(callee); |
| 693 break; |
| 694 } |
682 case Call::LOOKUP_SLOT_CALL: | 695 case Call::LOOKUP_SLOT_CALL: |
683 case Call::SUPER_CALL: | 696 case Call::SUPER_CALL: |
684 case Call::POSSIBLY_EVAL_CALL: | 697 case Call::POSSIBLY_EVAL_CALL: |
685 case Call::OTHER_CALL: | |
686 UNIMPLEMENTED(); | 698 UNIMPLEMENTED(); |
687 } | 699 } |
688 | 700 |
689 // Evaluate all arguments to the function call and store in sequential | 701 // Evaluate all arguments to the function call and store in sequential |
690 // registers. | 702 // registers. |
691 ZoneList<Expression*>* args = expr->arguments(); | 703 ZoneList<Expression*>* args = expr->arguments(); |
692 for (int i = 0; i < args->length(); ++i) { | 704 for (int i = 0; i < args->length(); ++i) { |
693 Visit(args->at(i)); | 705 Visit(args->at(i)); |
694 Register arg = temporary_register_scope.NewRegister(); | 706 Register arg = temporary_register_scope.NewRegister(); |
695 DCHECK(arg.index() - i == receiver.index() + 1); | 707 DCHECK(arg.index() - i == receiver.index() + 1); |
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
855 int BytecodeGenerator::feedback_index(FeedbackVectorSlot slot) const { | 867 int BytecodeGenerator::feedback_index(FeedbackVectorSlot slot) const { |
856 return info()->feedback_vector()->GetIndex(slot); | 868 return info()->feedback_vector()->GetIndex(slot); |
857 } | 869 } |
858 | 870 |
859 | 871 |
860 Register BytecodeGenerator::current_context() const { return current_context_; } | 872 Register BytecodeGenerator::current_context() const { return current_context_; } |
861 | 873 |
862 } // namespace interpreter | 874 } // namespace interpreter |
863 } // namespace internal | 875 } // namespace internal |
864 } // namespace v8 | 876 } // namespace v8 |
OLD | NEW |