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

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

Issue 1294793002: [Interpreter] Add implementations for load immediate bytecodes. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@interpreter_accum
Patch Set: Created 5 years, 4 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/compiler.h" 7 #include "src/compiler.h"
8 #include "src/compiler/interpreter-assembler.h" 8 #include "src/compiler/interpreter-assembler.h"
9 #include "src/factory.h" 9 #include "src/factory.h"
10 #include "src/interpreter/bytecodes.h" 10 #include "src/interpreter/bytecodes.h"
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
60 Handle<FixedArray> handler_table) { 60 Handle<FixedArray> handler_table) {
61 DCHECK(handler_table->length() == static_cast<int>(Bytecode::kLast) + 1); 61 DCHECK(handler_table->length() == static_cast<int>(Bytecode::kLast) + 1);
62 return handler_table->get(0) != isolate_->heap()->undefined_value(); 62 return handler_table->get(0) != isolate_->heap()->undefined_value();
63 } 63 }
64 64
65 65
66 // LdaZero 66 // LdaZero
67 // 67 //
68 // Load literal '0' into the accumulator. 68 // Load literal '0' into the accumulator.
69 void Interpreter::DoLdaZero(compiler::InterpreterAssembler* assembler) { 69 void Interpreter::DoLdaZero(compiler::InterpreterAssembler* assembler) {
70 // TODO(rmcilroy) Implement. 70 __ SetAccumulator(__ NumberConstant(0.0));
71 __ Dispatch(); 71 __ Dispatch();
72 } 72 }
73 73
74 74
75 // LdaSmi8 <imm8> 75 // LdaSmi8 <imm8>
76 // 76 //
77 // Load an 8-bit integer literal into the accumulator as a Smi. 77 // Load an 8-bit integer literal into the accumulator as a Smi.
78 void Interpreter::DoLdaSmi8(compiler::InterpreterAssembler* assembler) { 78 void Interpreter::DoLdaSmi8(compiler::InterpreterAssembler* assembler) {
79 // TODO(rmcilroy) Implement 8-bit integer to SMI promotion. 79 Node* raw_int = __ BytecodeOperandImm8(0);
80 __ SetAccumulator(__ SmiTag(raw_int));
80 __ Dispatch(); 81 __ Dispatch();
81 } 82 }
82 83
83 84
84 // LdaUndefined 85 // LdaUndefined
85 // 86 //
86 // Load Undefined into the accumulator. 87 // Load Undefined into the accumulator.
87 void Interpreter::DoLdaUndefined(compiler::InterpreterAssembler* assembler) { 88 void Interpreter::DoLdaUndefined(compiler::InterpreterAssembler* assembler) {
88 // TODO(rmcilroy) Implement. 89 __ SetAccumulator(__ HeapConstant(Unique<HeapObject>::CreateImmovable(
90 isolate_->factory()->undefined_value())));
89 __ Dispatch(); 91 __ Dispatch();
90 } 92 }
91 93
92 94
93 // LdaNull 95 // LdaNull
94 // 96 //
95 // Load Null into the accumulator. 97 // Load Null into the accumulator.
96 void Interpreter::DoLdaNull(compiler::InterpreterAssembler* assembler) { 98 void Interpreter::DoLdaNull(compiler::InterpreterAssembler* assembler) {
97 // TODO(rmcilroy) Implement. 99 __ SetAccumulator(__ HeapConstant(
100 Unique<HeapObject>::CreateImmovable(isolate_->factory()->null_value())));
98 __ Dispatch(); 101 __ Dispatch();
99 } 102 }
100 103
101 104
102 // LdaTheHole 105 // LdaTheHole
103 // 106 //
104 // Load TheHole into the accumulator. 107 // Load TheHole into the accumulator.
105 void Interpreter::DoLdaTheHole(compiler::InterpreterAssembler* assembler) { 108 void Interpreter::DoLdaTheHole(compiler::InterpreterAssembler* assembler) {
106 // TODO(rmcilroy) Implement. 109 __ SetAccumulator(__ HeapConstant(Unique<HeapObject>::CreateImmovable(
110 isolate_->factory()->the_hole_value())));
107 __ Dispatch(); 111 __ Dispatch();
108 } 112 }
109 113
110 114
111 // LdaTrue 115 // LdaTrue
112 // 116 //
113 // Load True into the accumulator. 117 // Load True into the accumulator.
114 void Interpreter::DoLdaTrue(compiler::InterpreterAssembler* assembler) { 118 void Interpreter::DoLdaTrue(compiler::InterpreterAssembler* assembler) {
115 // TODO(rmcilroy) Implement. 119 __ SetAccumulator(__ HeapConstant(
120 Unique<HeapObject>::CreateImmovable(isolate_->factory()->true_value())));
116 __ Dispatch(); 121 __ Dispatch();
117 } 122 }
118 123
119 124
120 // LdaFalse 125 // LdaFalse
121 // 126 //
122 // Load False into the accumulator. 127 // Load False into the accumulator.
123 void Interpreter::DoLdaFalse(compiler::InterpreterAssembler* assembler) { 128 void Interpreter::DoLdaFalse(compiler::InterpreterAssembler* assembler) {
124 // TODO(rmcilroy) Implement. 129 __ SetAccumulator(__ HeapConstant(
130 Unique<HeapObject>::CreateImmovable(isolate_->factory()->false_value())));
125 __ Dispatch(); 131 __ Dispatch();
126 } 132 }
127 133
128 134
129 // Ldar <src> 135 // Ldar <src>
130 // 136 //
131 // Load accumulator with value from register <src>. 137 // Load accumulator with value from register <src>.
132 void Interpreter::DoLdar(compiler::InterpreterAssembler* assembler) { 138 void Interpreter::DoLdar(compiler::InterpreterAssembler* assembler) {
133 // TODO(rmcilroy) Implement. 139 Node* value = __ LoadRegister(__ BytecodeOperandReg(0));
140 __ SetAccumulator(value);
134 __ Dispatch(); 141 __ Dispatch();
135 } 142 }
136 143
137 144
138 // Star <dst> 145 // Star <dst>
139 // 146 //
140 // Store accumulator to register <dst>. 147 // Store accumulator to register <dst>.
141 void Interpreter::DoStar(compiler::InterpreterAssembler* assembler) { 148 void Interpreter::DoStar(compiler::InterpreterAssembler* assembler) {
142 // TODO(rmcilroy) Implement. 149 __ StoreRegister(__ GetAccumulator(), __ BytecodeOperandReg(0));
Michael Starzinger 2015/08/17 08:22:34 This pattern looks dangerous, note that C++ does n
rmcilroy 2015/08/18 13:06:22 Yeah good point. Note, in this case it doesn't mat
143 __ Dispatch(); 150 __ Dispatch();
144 } 151 }
145 152
146 153
147 // Add <src> 154 // Add <src>
148 // 155 //
149 // Add register <src> to accumulator. 156 // Add register <src> to accumulator.
150 void Interpreter::DoAdd(compiler::InterpreterAssembler* assembler) { 157 void Interpreter::DoAdd(compiler::InterpreterAssembler* assembler) {
151 // TODO(rmcilroy) Implement. 158 // TODO(rmcilroy) Implement.
152 __ Dispatch(); 159 __ Dispatch();
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
184 // 191 //
185 // Return the value in register 0. 192 // Return the value in register 0.
186 void Interpreter::DoReturn(compiler::InterpreterAssembler* assembler) { 193 void Interpreter::DoReturn(compiler::InterpreterAssembler* assembler) {
187 __ Return(); 194 __ Return();
188 } 195 }
189 196
190 197
191 } // namespace interpreter 198 } // namespace interpreter
192 } // namespace internal 199 } // namespace internal
193 } // namespace v8 200 } // namespace v8
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698