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

Side by Side Diff: src/interpreter/bytecode-generator.cc

Issue 1321663003: [Interpreter] Add support for loading literals from the constant pool. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@int_const_pool_1
Patch Set: Review comments Created 5 years, 3 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/bytecode-array-builder.cc ('k') | src/interpreter/bytecodes.h » ('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/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/objects.h" 10 #include "src/objects.h"
11 #include "src/scopes.h" 11 #include "src/scopes.h"
12 #include "src/token.h" 12 #include "src/token.h"
13 13
14 namespace v8 { 14 namespace v8 {
15 namespace internal { 15 namespace internal {
16 namespace interpreter { 16 namespace interpreter {
17 17
18 BytecodeGenerator::BytecodeGenerator(Isolate* isolate, Zone* zone) 18 BytecodeGenerator::BytecodeGenerator(Isolate* isolate, Zone* zone)
19 : builder_(isolate) { 19 : builder_(isolate, zone) {
20 InitializeAstVisitor(isolate, zone); 20 InitializeAstVisitor(isolate, zone);
21 } 21 }
22 22
23 23
24 BytecodeGenerator::~BytecodeGenerator() {} 24 BytecodeGenerator::~BytecodeGenerator() {}
25 25
26 26
27 Handle<BytecodeArray> BytecodeGenerator::MakeBytecode(CompilationInfo* info) { 27 Handle<BytecodeArray> BytecodeGenerator::MakeBytecode(CompilationInfo* info) {
28 set_scope(info->scope()); 28 set_scope(info->scope());
29 29
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after
194 void BytecodeGenerator::VisitNativeFunctionLiteral( 194 void BytecodeGenerator::VisitNativeFunctionLiteral(
195 NativeFunctionLiteral* node) { 195 NativeFunctionLiteral* node) {
196 UNIMPLEMENTED(); 196 UNIMPLEMENTED();
197 } 197 }
198 198
199 199
200 void BytecodeGenerator::VisitConditional(Conditional* node) { UNIMPLEMENTED(); } 200 void BytecodeGenerator::VisitConditional(Conditional* node) { UNIMPLEMENTED(); }
201 201
202 202
203 void BytecodeGenerator::VisitLiteral(Literal* expr) { 203 void BytecodeGenerator::VisitLiteral(Literal* expr) {
204 if (expr->IsPropertyName()) {
205 UNIMPLEMENTED();
206 }
207
208 Handle<Object> value = expr->value(); 204 Handle<Object> value = expr->value();
209 if (value->IsSmi()) { 205 if (value->IsSmi()) {
210 builder().LoadLiteral(Smi::cast(*value)); 206 builder().LoadLiteral(Smi::cast(*value));
211 } else if (value->IsUndefined()) { 207 } else if (value->IsUndefined()) {
212 builder().LoadUndefined(); 208 builder().LoadUndefined();
213 } else if (value->IsTrue()) { 209 } else if (value->IsTrue()) {
214 builder().LoadTrue(); 210 builder().LoadTrue();
215 } else if (value->IsFalse()) { 211 } else if (value->IsFalse()) {
216 builder().LoadFalse(); 212 builder().LoadFalse();
217 } else if (value->IsNull()) { 213 } else if (value->IsNull()) {
218 builder().LoadNull(); 214 builder().LoadNull();
219 } else if (value->IsTheHole()) { 215 } else if (value->IsTheHole()) {
220 builder().LoadTheHole(); 216 builder().LoadTheHole();
221 } else { 217 } else {
222 UNIMPLEMENTED(); 218 builder().LoadLiteral(value);
223 } 219 }
224 } 220 }
225 221
226 222
227 void BytecodeGenerator::VisitRegExpLiteral(RegExpLiteral* node) { 223 void BytecodeGenerator::VisitRegExpLiteral(RegExpLiteral* node) {
228 UNIMPLEMENTED(); 224 UNIMPLEMENTED();
229 } 225 }
230 226
231 227
232 void BytecodeGenerator::VisitObjectLiteral(ObjectLiteral* node) { 228 void BytecodeGenerator::VisitObjectLiteral(ObjectLiteral* node) {
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after
371 367
372 Visit(left); 368 Visit(left);
373 builder().StoreAccumulatorInRegister(temporary); 369 builder().StoreAccumulatorInRegister(temporary);
374 Visit(right); 370 Visit(right);
375 builder().BinaryOperation(op, temporary); 371 builder().BinaryOperation(op, temporary);
376 } 372 }
377 373
378 } // namespace interpreter 374 } // namespace interpreter
379 } // namespace internal 375 } // namespace internal
380 } // namespace v8 376 } // namespace v8
OLDNEW
« no previous file with comments | « src/interpreter/bytecode-array-builder.cc ('k') | src/interpreter/bytecodes.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698