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

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: 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 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 285 matching lines...) Expand 10 before | Expand all | Expand 10 after
645 compiler::InterpreterAssembler* assembler) { 665 compiler::InterpreterAssembler* assembler) {
646 Node* accumulator = __ GetAccumulator(); 666 Node* accumulator = __ GetAccumulator();
647 Node* index = __ BytecodeOperandIdx8(0); 667 Node* index = __ BytecodeOperandIdx8(0);
648 Node* constant = __ LoadConstantPoolEntry(index); 668 Node* constant = __ LoadConstantPoolEntry(index);
649 Node* relative_jump = __ SmiUntag(constant); 669 Node* relative_jump = __ SmiUntag(constant);
650 Node* false_value = __ BooleanConstant(false); 670 Node* false_value = __ BooleanConstant(false);
651 __ JumpIfWordEqual(accumulator, false_value, relative_jump); 671 __ JumpIfWordEqual(accumulator, false_value, relative_jump);
652 } 672 }
653 673
654 674
675 // CreateArrayLiteral <idx> <flags>
676 //
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();
682 Node* literal_index_raw = __ BytecodeOperandIdx8(0);
683 Node* literal_index = __ SmiTag(literal_index_raw);
684 Node* flags_raw = __ BytecodeOperandImm8(1);
685 Node* flags = __ SmiTag(flags_raw);
686 Node* closure = __ LoadRegister(Register::function_closure());
687 Node* literals_array =
688 __ LoadObjectField(closure, JSFunction::kLiteralsOffset);
689 Node* result = __ CallRuntime(Runtime::kCreateArrayLiteral, literals_array,
690 literal_index, constant_elements, flags);
691 __ SetAccumulator(result);
692 __ Dispatch();
693 }
694
695
655 // Return 696 // Return
656 // 697 //
657 // Return the value in the accumulator. 698 // Return the value in the accumulator.
658 void Interpreter::DoReturn(compiler::InterpreterAssembler* assembler) { 699 void Interpreter::DoReturn(compiler::InterpreterAssembler* assembler) {
659 __ Return(); 700 __ Return();
660 } 701 }
661 702
662 703
663 } // namespace interpreter 704 } // namespace interpreter
664 } // namespace internal 705 } // namespace internal
665 } // namespace v8 706 } // namespace v8
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698