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

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

Issue 1400753003: [Interpreter] Add array literal support. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@int_literal
Patch Set: Rebase 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
« no previous file with comments | « src/interpreter/bytecodes.h ('k') | test/cctest/interpreter/test-bytecode-generator.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 329 matching lines...) Expand 10 before | Expand all | Expand 10 after
340 // Calls the strict mode KeyStoreIC at FeedBackVector slot <slot> for <object> 340 // Calls the strict mode KeyStoreIC at FeedBackVector slot <slot> for <object>
341 // and the key <key> with the value in the accumulator. 341 // and the key <key> with the value in the accumulator.
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>
351 //
352 // Calls the generic KeyStoreIC for <object> and the key <key> with the value in
353 // the accumulator.
354 void Interpreter::DoKeyedStoreICGeneric(
355 compiler::InterpreterAssembler* assembler) {
356 Callable ic =
357 CodeFactory::KeyedStoreICInOptimizedCode(isolate_, SLOPPY, MEGAMORPHIC);
358 Node* code_target = __ HeapConstant(ic.code());
359 Node* object_reg_index = __ BytecodeOperandReg8(0);
360 Node* object = __ LoadRegister(object_reg_index);
361 Node* name_reg_index = __ BytecodeOperandReg8(1);
362 Node* name = __ LoadRegister(name_reg_index);
363 Node* value = __ GetAccumulator();
364 Node* result = __ CallIC(ic.descriptor(), code_target, object, name, value);
365 __ SetAccumulator(result);
366 __ Dispatch();
367 }
368
369
350 // PushContext <context> 370 // PushContext <context>
351 // 371 //
352 // Pushes the accumulator as the current context, and saves it in <context> 372 // Pushes the accumulator as the current context, and saves it in <context>
353 void Interpreter::DoPushContext(compiler::InterpreterAssembler* assembler) { 373 void Interpreter::DoPushContext(compiler::InterpreterAssembler* assembler) {
354 Node* reg_index = __ BytecodeOperandReg8(0); 374 Node* reg_index = __ BytecodeOperandReg8(0);
355 Node* context = __ GetAccumulator(); 375 Node* context = __ GetAccumulator();
356 __ SetContext(context); 376 __ SetContext(context);
357 __ StoreRegister(context, reg_index); 377 __ StoreRegister(context, reg_index);
358 __ Dispatch(); 378 __ Dispatch();
359 } 379 }
(...skipping 343 matching lines...) Expand 10 before | Expand all | Expand 10 after
703 compiler::InterpreterAssembler* assembler) { 723 compiler::InterpreterAssembler* assembler) {
704 Node* accumulator = __ GetAccumulator(); 724 Node* accumulator = __ GetAccumulator();
705 Node* index = __ BytecodeOperandIdx8(0); 725 Node* index = __ BytecodeOperandIdx8(0);
706 Node* constant = __ LoadConstantPoolEntry(index); 726 Node* constant = __ LoadConstantPoolEntry(index);
707 Node* relative_jump = __ SmiUntag(constant); 727 Node* relative_jump = __ SmiUntag(constant);
708 Node* false_value = __ BooleanConstant(false); 728 Node* false_value = __ BooleanConstant(false);
709 __ JumpIfWordEqual(accumulator, false_value, relative_jump); 729 __ JumpIfWordEqual(accumulator, false_value, relative_jump);
710 } 730 }
711 731
712 732
733 // CreateArrayLiteral <idx> <flags>
734 //
735 // Creates an array literal for literal index <idx> with flags <flags> and
736 // constant elements in the accumulator.
737 void Interpreter::DoCreateArrayLiteral(
738 compiler::InterpreterAssembler* assembler) {
739 Node* constant_elements = __ GetAccumulator();
740 Node* literal_index_raw = __ BytecodeOperandIdx8(0);
741 Node* literal_index = __ SmiTag(literal_index_raw);
742 Node* flags_raw = __ BytecodeOperandImm8(1);
743 Node* flags = __ SmiTag(flags_raw);
744 Node* closure = __ LoadRegister(Register::function_closure());
745 Node* literals_array =
746 __ LoadObjectField(closure, JSFunction::kLiteralsOffset);
747 Node* result = __ CallRuntime(Runtime::kCreateArrayLiteral, literals_array,
748 literal_index, constant_elements, flags);
749 __ SetAccumulator(result);
750 __ Dispatch();
751 }
752
753
713 // CreateClosure <tenured> 754 // CreateClosure <tenured>
714 // 755 //
715 // Creates a new closure for SharedFunctionInfo in the accumulator with the 756 // Creates a new closure for SharedFunctionInfo in the accumulator with the
716 // PretenureFlag <tenured>. 757 // PretenureFlag <tenured>.
717 void Interpreter::DoCreateClosure(compiler::InterpreterAssembler* assembler) { 758 void Interpreter::DoCreateClosure(compiler::InterpreterAssembler* assembler) {
718 // TODO(rmcilroy): Possibly call FastNewClosureStub when possible instead of 759 // TODO(rmcilroy): Possibly call FastNewClosureStub when possible instead of
719 // calling into the runtime. 760 // calling into the runtime.
720 Node* shared = __ GetAccumulator(); 761 Node* shared = __ GetAccumulator();
721 Node* tenured_raw = __ BytecodeOperandImm8(0); 762 Node* tenured_raw = __ BytecodeOperandImm8(0);
722 Node* tenured = __ SmiTag(tenured_raw); 763 Node* tenured = __ SmiTag(tenured_raw);
723 Node* result = 764 Node* result =
724 __ CallRuntime(Runtime::kInterpreterNewClosure, shared, tenured); 765 __ CallRuntime(Runtime::kInterpreterNewClosure, shared, tenured);
725 __ SetAccumulator(result); 766 __ SetAccumulator(result);
726 __ Dispatch(); 767 __ Dispatch();
727 } 768 }
728 769
729 770
730 // Return 771 // Return
731 // 772 //
732 // Return the value in the accumulator. 773 // Return the value in the accumulator.
733 void Interpreter::DoReturn(compiler::InterpreterAssembler* assembler) { 774 void Interpreter::DoReturn(compiler::InterpreterAssembler* assembler) {
734 __ Return(); 775 __ Return();
735 } 776 }
736 777
737 778
738 } // namespace interpreter 779 } // namespace interpreter
739 } // namespace internal 780 } // namespace internal
740 } // namespace v8 781 } // namespace v8
OLDNEW
« no previous file with comments | « src/interpreter/bytecodes.h ('k') | test/cctest/interpreter/test-bytecode-generator.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698