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

Side by Side Diff: src/interpreter/bytecode-array-builder.h

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/compiler/interpreter-assembler.cc ('k') | src/interpreter/bytecode-array-builder.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 #ifndef V8_INTERPRETER_BYTECODE_ARRAY_BUILDER_H_ 5 #ifndef V8_INTERPRETER_BYTECODE_ARRAY_BUILDER_H_
6 #define V8_INTERPRETER_BYTECODE_ARRAY_BUILDER_H_ 6 #define V8_INTERPRETER_BYTECODE_ARRAY_BUILDER_H_
7 7
8 #include <vector> 8 #include <vector>
9 9
10 #include "src/ast.h" 10 #include "src/ast.h"
11 #include "src/frames.h" 11 #include "src/frames.h"
12 #include "src/identity-map.h"
12 #include "src/interpreter/bytecodes.h" 13 #include "src/interpreter/bytecodes.h"
14 #include "src/zone.h"
15 #include "src/zone-containers.h"
13 16
14 namespace v8 { 17 namespace v8 {
15 namespace internal { 18 namespace internal {
16 19
17 class Isolate; 20 class Isolate;
18 21
19 namespace interpreter { 22 namespace interpreter {
20 23
21 class Register; 24 class Register;
22 25
23 class BytecodeArrayBuilder { 26 class BytecodeArrayBuilder {
24 public: 27 public:
25 explicit BytecodeArrayBuilder(Isolate* isolate); 28 BytecodeArrayBuilder(Isolate* isolate, Zone* zone);
26 Handle<BytecodeArray> ToBytecodeArray(); 29 Handle<BytecodeArray> ToBytecodeArray();
27 30
28 // Set number of parameters expected by function. 31 // Set number of parameters expected by function.
29 void set_parameter_count(int number_of_params); 32 void set_parameter_count(int number_of_params);
30 int parameter_count() const; 33 int parameter_count() const;
31 34
32 // Set number of locals required for bytecode array. 35 // Set number of locals required for bytecode array.
33 void set_locals_count(int number_of_locals); 36 void set_locals_count(int number_of_locals);
34 int locals_count() const; 37 int locals_count() const;
35 38
36 Register Parameter(int parameter_index); 39 Register Parameter(int parameter_index);
37 40
38 // Constant loads to accumulator. 41 // Constant loads to accumulator.
39 BytecodeArrayBuilder& LoadLiteral(v8::internal::Smi* value); 42 BytecodeArrayBuilder& LoadLiteral(v8::internal::Smi* value);
43 BytecodeArrayBuilder& LoadLiteral(Handle<Object> object);
40 BytecodeArrayBuilder& LoadUndefined(); 44 BytecodeArrayBuilder& LoadUndefined();
41 BytecodeArrayBuilder& LoadNull(); 45 BytecodeArrayBuilder& LoadNull();
42 BytecodeArrayBuilder& LoadTheHole(); 46 BytecodeArrayBuilder& LoadTheHole();
43 BytecodeArrayBuilder& LoadTrue(); 47 BytecodeArrayBuilder& LoadTrue();
44 BytecodeArrayBuilder& LoadFalse(); 48 BytecodeArrayBuilder& LoadFalse();
45 49
46 // Register-accumulator transfers. 50 // Register-accumulator transfers.
47 BytecodeArrayBuilder& LoadAccumulatorWithRegister(Register reg); 51 BytecodeArrayBuilder& LoadAccumulatorWithRegister(Register reg);
48 BytecodeArrayBuilder& StoreAccumulatorInRegister(Register reg); 52 BytecodeArrayBuilder& StoreAccumulatorInRegister(Register reg);
49 53
(...skipping 10 matching lines...) Expand all
60 static Bytecode BytecodeForBinaryOperation(Token::Value op); 64 static Bytecode BytecodeForBinaryOperation(Token::Value op);
61 65
62 void Output(Bytecode bytecode, uint8_t r0, uint8_t r1, uint8_t r2); 66 void Output(Bytecode bytecode, uint8_t r0, uint8_t r1, uint8_t r2);
63 void Output(Bytecode bytecode, uint8_t r0, uint8_t r1); 67 void Output(Bytecode bytecode, uint8_t r0, uint8_t r1);
64 void Output(Bytecode bytecode, uint8_t r0); 68 void Output(Bytecode bytecode, uint8_t r0);
65 void Output(Bytecode bytecode); 69 void Output(Bytecode bytecode);
66 70
67 bool OperandIsValid(Bytecode bytecode, int operand_index, 71 bool OperandIsValid(Bytecode bytecode, int operand_index,
68 uint8_t operand_value) const; 72 uint8_t operand_value) const;
69 73
74 size_t GetConstantPoolEntry(Handle<Object> object);
75
70 int BorrowTemporaryRegister(); 76 int BorrowTemporaryRegister();
71 void ReturnTemporaryRegister(int reg_index); 77 void ReturnTemporaryRegister(int reg_index);
72 78
73 Isolate* isolate_; 79 Isolate* isolate_;
74 std::vector<uint8_t> bytecodes_; 80 ZoneVector<uint8_t> bytecodes_;
75 bool bytecode_generated_; 81 bool bytecode_generated_;
76 82
83 IdentityMap<size_t> constants_map_;
84 ZoneVector<Handle<Object>> constants_;
85
77 int parameter_count_; 86 int parameter_count_;
78 int local_register_count_; 87 int local_register_count_;
79 int temporary_register_count_; 88 int temporary_register_count_;
80 int temporary_register_next_; 89 int temporary_register_next_;
81 90
82 friend class TemporaryRegisterScope; 91 friend class TemporaryRegisterScope;
83 DISALLOW_IMPLICIT_CONSTRUCTORS(BytecodeArrayBuilder); 92 DISALLOW_IMPLICIT_CONSTRUCTORS(BytecodeArrayBuilder);
84 }; 93 };
85 94
86 // An interpreter register which is located in the function's register file 95 // An interpreter register which is located in the function's register file
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
127 136
128 DISALLOW_COPY_AND_ASSIGN(TemporaryRegisterScope); 137 DISALLOW_COPY_AND_ASSIGN(TemporaryRegisterScope);
129 }; 138 };
130 139
131 140
132 } // namespace interpreter 141 } // namespace interpreter
133 } // namespace internal 142 } // namespace internal
134 } // namespace v8 143 } // namespace v8
135 144
136 #endif // V8_INTERPRETER_BYTECODE_ARRAY_BUILDER_H_ 145 #endif // V8_INTERPRETER_BYTECODE_ARRAY_BUILDER_H_
OLDNEW
« no previous file with comments | « src/compiler/interpreter-assembler.cc ('k') | src/interpreter/bytecode-array-builder.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698