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

Side by Side Diff: src/interpreter/interpreter.cc

Issue 1386313005: [Interpreter] Adds Object literal support. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@int_literal_2
Patch Set: 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/interpreter.h" 5 #include "src/interpreter/interpreter.h"
6 6
7 #include "src/code-factory.h" 7 #include "src/code-factory.h"
8 #include "src/compiler.h" 8 #include "src/compiler.h"
9 #include "src/compiler/interpreter-assembler.h" 9 #include "src/compiler/interpreter-assembler.h"
10 #include "src/factory.h" 10 #include "src/factory.h"
(...skipping 331 matching lines...) Expand 10 before | Expand all | Expand 10 after
342 void Interpreter::DoKeyedStoreICStrict( 342 void Interpreter::DoKeyedStoreICStrict(
343 compiler::InterpreterAssembler* assembler) { 343 compiler::InterpreterAssembler* assembler) {
344 Callable ic = 344 Callable ic =
345 CodeFactory::KeyedStoreICInOptimizedCode(isolate_, STRICT, UNINITIALIZED); 345 CodeFactory::KeyedStoreICInOptimizedCode(isolate_, STRICT, UNINITIALIZED);
346 DoPropertyStoreIC(ic, assembler); 346 DoPropertyStoreIC(ic, assembler);
347 } 347 }
348 348
349 349
350 // KeyedStoreICGeneric <object> <key> 350 // KeyedStoreICGeneric <object> <key>
351 // 351 //
352 // Calls the generic KeyStoreIC for <object> and the key <key> with the value in 352 // Calls the generic KeyedStoreIC for <object> and the key <key> with the value
353 // the accumulator. 353 // in the accumulator.
354 void Interpreter::DoKeyedStoreICGeneric( 354 void Interpreter::DoKeyedStoreICGeneric(
355 compiler::InterpreterAssembler* assembler) { 355 compiler::InterpreterAssembler* assembler) {
356 Callable ic = 356 Callable ic =
357 CodeFactory::KeyedStoreICInOptimizedCode(isolate_, SLOPPY, MEGAMORPHIC); 357 CodeFactory::KeyedStoreICInOptimizedCode(isolate_, SLOPPY, MEGAMORPHIC);
358 Node* code_target = __ HeapConstant(ic.code()); 358 Node* code_target = __ HeapConstant(ic.code());
359 Node* object_reg_index = __ BytecodeOperandReg8(0); 359 Node* object_reg_index = __ BytecodeOperandReg8(0);
360 Node* object = __ LoadRegister(object_reg_index); 360 Node* object = __ LoadRegister(object_reg_index);
361 Node* name_reg_index = __ BytecodeOperandReg8(1); 361 Node* name_reg_index = __ BytecodeOperandReg8(1);
362 Node* name = __ LoadRegister(name_reg_index); 362 Node* name = __ LoadRegister(name_reg_index);
363 Node* value = __ GetAccumulator(); 363 Node* value = __ GetAccumulator();
(...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after
591 // 591 //
592 // Cast the object referenced by the accumulator to a boolean. 592 // Cast the object referenced by the accumulator to a boolean.
593 void Interpreter::DoToBoolean(compiler::InterpreterAssembler* assembler) { 593 void Interpreter::DoToBoolean(compiler::InterpreterAssembler* assembler) {
594 Node* accumulator = __ GetAccumulator(); 594 Node* accumulator = __ GetAccumulator();
595 Node* result = __ CallRuntime(Runtime::kInterpreterToBoolean, accumulator); 595 Node* result = __ CallRuntime(Runtime::kInterpreterToBoolean, accumulator);
596 __ SetAccumulator(result); 596 __ SetAccumulator(result);
597 __ Dispatch(); 597 __ Dispatch();
598 } 598 }
599 599
600 600
601 // ToName
602 //
603 // Cast the object referenced by the accumulator to a name.
604 void Interpreter::DoToName(compiler::InterpreterAssembler* assembler) {
605 Node* accumulator = __ GetAccumulator();
606 Node* result = __ CallRuntime(Runtime::kToName, accumulator);
607 __ SetAccumulator(result);
608 __ Dispatch();
609 }
610
611
601 // Jump <imm8> 612 // Jump <imm8>
602 // 613 //
603 // Jump by number of bytes represented by the immediate operand |imm8|. 614 // Jump by number of bytes represented by the immediate operand |imm8|.
604 void Interpreter::DoJump(compiler::InterpreterAssembler* assembler) { 615 void Interpreter::DoJump(compiler::InterpreterAssembler* assembler) {
605 Node* relative_jump = __ BytecodeOperandImm8(0); 616 Node* relative_jump = __ BytecodeOperandImm8(0);
606 __ Jump(relative_jump); 617 __ Jump(relative_jump);
607 } 618 }
608 619
609 620
610 // JumpConstant <idx> 621 // JumpConstant <idx>
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
665 compiler::InterpreterAssembler* assembler) { 676 compiler::InterpreterAssembler* assembler) {
666 Node* accumulator = __ GetAccumulator(); 677 Node* accumulator = __ GetAccumulator();
667 Node* index = __ BytecodeOperandIdx8(0); 678 Node* index = __ BytecodeOperandIdx8(0);
668 Node* constant = __ LoadConstantPoolEntry(index); 679 Node* constant = __ LoadConstantPoolEntry(index);
669 Node* relative_jump = __ SmiUntag(constant); 680 Node* relative_jump = __ SmiUntag(constant);
670 Node* false_value = __ BooleanConstant(false); 681 Node* false_value = __ BooleanConstant(false);
671 __ JumpIfWordEqual(accumulator, false_value, relative_jump); 682 __ JumpIfWordEqual(accumulator, false_value, relative_jump);
672 } 683 }
673 684
674 685
675 // CreateArrayLiteral <idx> <flags> 686 void Interpreter::DoCreateLiteral(Runtime::FunctionId function_id,
676 // 687 compiler::InterpreterAssembler* assembler) {
677 // Creates an array literal for literal index <idx> with flags <flags> and
678 // constant elements in the accumulator.
679 void Interpreter::DoCreateArrayLiteral(
680 compiler::InterpreterAssembler* assembler) {
681 Node* constant_elements = __ GetAccumulator(); 688 Node* constant_elements = __ GetAccumulator();
682 Node* literal_index_raw = __ BytecodeOperandIdx8(0); 689 Node* literal_index_raw = __ BytecodeOperandIdx8(0);
683 Node* literal_index = __ SmiTag(literal_index_raw); 690 Node* literal_index = __ SmiTag(literal_index_raw);
684 Node* flags_raw = __ BytecodeOperandImm8(1); 691 Node* flags_raw = __ BytecodeOperandImm8(1);
685 Node* flags = __ SmiTag(flags_raw); 692 Node* flags = __ SmiTag(flags_raw);
686 Node* closure = __ LoadRegister(Register::function_closure()); 693 Node* closure = __ LoadRegister(Register::function_closure());
687 Node* literals_array = 694 Node* literals_array =
688 __ LoadObjectField(closure, JSFunction::kLiteralsOffset); 695 __ LoadObjectField(closure, JSFunction::kLiteralsOffset);
689 Node* result = __ CallRuntime(Runtime::kCreateArrayLiteral, literals_array, 696 Node* result = __ CallRuntime(function_id, literals_array, literal_index,
690 literal_index, constant_elements, flags); 697 constant_elements, flags);
691 __ SetAccumulator(result); 698 __ SetAccumulator(result);
692 __ Dispatch(); 699 __ Dispatch();
693 } 700 }
694 701
695 702
703 // CreateArrayLiteral <idx> <flags>
704 //
705 // Creates an array literal for literal index <idx> with flags <flags> and
706 // constant elements in the accumulator.
707 void Interpreter::DoCreateArrayLiteral(
708 compiler::InterpreterAssembler* assembler) {
709 DoCreateLiteral(Runtime::kCreateArrayLiteral, assembler);
710 }
711
712
713 // CreateObjectLiteral <idx> <flags>
714 //
715 // Creates an object literal for literal index <idx> with flags <flags> and
716 // constant elements in the accumulator.
717 void Interpreter::DoCreateObjectLiteral(
718 compiler::InterpreterAssembler* assembler) {
719 DoCreateLiteral(Runtime::kCreateObjectLiteral, assembler);
720 }
721
722
696 // CreateClosure <tenured> 723 // CreateClosure <tenured>
697 // 724 //
698 // Creates a new closure for SharedFunctionInfo in the accumulator with the 725 // Creates a new closure for SharedFunctionInfo in the accumulator with the
699 // PretenureFlag <tenured>. 726 // PretenureFlag <tenured>.
700 void Interpreter::DoCreateClosure(compiler::InterpreterAssembler* assembler) { 727 void Interpreter::DoCreateClosure(compiler::InterpreterAssembler* assembler) {
701 // TODO(rmcilroy): Possibly call FastNewClosureStub when possible instead of 728 // TODO(rmcilroy): Possibly call FastNewClosureStub when possible instead of
702 // calling into the runtime. 729 // calling into the runtime.
703 Node* shared = __ GetAccumulator(); 730 Node* shared = __ GetAccumulator();
704 Node* tenured_raw = __ BytecodeOperandImm8(0); 731 Node* tenured_raw = __ BytecodeOperandImm8(0);
705 Node* tenured = __ SmiTag(tenured_raw); 732 Node* tenured = __ SmiTag(tenured_raw);
706 Node* result = 733 Node* result =
707 __ CallRuntime(Runtime::kInterpreterNewClosure, shared, tenured); 734 __ CallRuntime(Runtime::kInterpreterNewClosure, shared, tenured);
708 __ SetAccumulator(result); 735 __ SetAccumulator(result);
709 __ Dispatch(); 736 __ Dispatch();
710 } 737 }
711 738
712 739
713 // Return 740 // Return
714 // 741 //
715 // Return the value in the accumulator. 742 // Return the value in the accumulator.
716 void Interpreter::DoReturn(compiler::InterpreterAssembler* assembler) { 743 void Interpreter::DoReturn(compiler::InterpreterAssembler* assembler) {
717 __ Return(); 744 __ Return();
718 } 745 }
719 746
720 747
721 } // namespace interpreter 748 } // namespace interpreter
722 } // namespace internal 749 } // namespace internal
723 } // namespace v8 750 } // namespace v8
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698