OLD | NEW |
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/identity-map.h" | 11 #include "src/identity-map.h" |
12 #include "src/interpreter/bytecodes.h" | 12 #include "src/interpreter/bytecodes.h" |
13 #include "src/zone.h" | 13 #include "src/zone.h" |
14 #include "src/zone-containers.h" | 14 #include "src/zone-containers.h" |
15 | 15 |
16 namespace v8 { | 16 namespace v8 { |
17 namespace internal { | 17 namespace internal { |
18 | 18 |
19 class Isolate; | 19 class Isolate; |
20 | 20 |
21 namespace interpreter { | 21 namespace interpreter { |
22 | 22 |
23 class BytecodeLabel; | 23 class BytecodeLabel; |
24 class Register; | 24 class Register; |
25 | 25 |
| 26 // TODO(rmcilroy): Unify this with CreateArgumentsParameters::Type in Turbofan |
| 27 // when rest parameters implementation has settled down. |
| 28 enum class CreateArgumentsType { kMappedArguments, kUnmappedArguments }; |
| 29 |
26 class BytecodeArrayBuilder { | 30 class BytecodeArrayBuilder { |
27 public: | 31 public: |
28 BytecodeArrayBuilder(Isolate* isolate, Zone* zone); | 32 BytecodeArrayBuilder(Isolate* isolate, Zone* zone); |
29 Handle<BytecodeArray> ToBytecodeArray(); | 33 Handle<BytecodeArray> ToBytecodeArray(); |
30 | 34 |
31 // Set the number of parameters expected by function. | 35 // Set the number of parameters expected by function. |
32 void set_parameter_count(int number_of_params); | 36 void set_parameter_count(int number_of_params); |
33 int parameter_count() const { | 37 int parameter_count() const { |
34 DCHECK_GE(parameter_count_, 0); | 38 DCHECK_GE(parameter_count_, 0); |
35 return parameter_count_; | 39 return parameter_count_; |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
104 BytecodeArrayBuilder& StoreNamedProperty(Register object, size_t name_index, | 108 BytecodeArrayBuilder& StoreNamedProperty(Register object, size_t name_index, |
105 int feedback_slot, | 109 int feedback_slot, |
106 LanguageMode language_mode); | 110 LanguageMode language_mode); |
107 BytecodeArrayBuilder& StoreKeyedProperty(Register object, Register key, | 111 BytecodeArrayBuilder& StoreKeyedProperty(Register object, Register key, |
108 int feedback_slot, | 112 int feedback_slot, |
109 LanguageMode language_mode); | 113 LanguageMode language_mode); |
110 | 114 |
111 // Create a new closure for the SharedFunctionInfo in the accumulator. | 115 // Create a new closure for the SharedFunctionInfo in the accumulator. |
112 BytecodeArrayBuilder& CreateClosure(PretenureFlag tenured); | 116 BytecodeArrayBuilder& CreateClosure(PretenureFlag tenured); |
113 | 117 |
| 118 // Create a new arguments object in the accumulator. |
| 119 BytecodeArrayBuilder& CreateArguments(CreateArgumentsType type); |
| 120 |
114 // Literals creation. Constant elements should be in the accumulator. | 121 // Literals creation. Constant elements should be in the accumulator. |
115 BytecodeArrayBuilder& CreateRegExpLiteral(int literal_index, Register flags); | 122 BytecodeArrayBuilder& CreateRegExpLiteral(int literal_index, Register flags); |
116 BytecodeArrayBuilder& CreateArrayLiteral(int literal_index, int flags); | 123 BytecodeArrayBuilder& CreateArrayLiteral(int literal_index, int flags); |
117 BytecodeArrayBuilder& CreateObjectLiteral(int literal_index, int flags); | 124 BytecodeArrayBuilder& CreateObjectLiteral(int literal_index, int flags); |
118 | 125 |
119 // Push the context in accumulator as the new context, and store in register | 126 // Push the context in accumulator as the new context, and store in register |
120 // |context|. | 127 // |context|. |
121 BytecodeArrayBuilder& PushContext(Register context); | 128 BytecodeArrayBuilder& PushContext(Register context); |
122 | 129 |
123 // Pop the current context and replace with |context|. | 130 // Pop the current context and replace with |context|. |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
191 | 198 |
192 static Bytecode BytecodeForBinaryOperation(Token::Value op); | 199 static Bytecode BytecodeForBinaryOperation(Token::Value op); |
193 static Bytecode BytecodeForCountOperation(Token::Value op); | 200 static Bytecode BytecodeForCountOperation(Token::Value op); |
194 static Bytecode BytecodeForCompareOperation(Token::Value op); | 201 static Bytecode BytecodeForCompareOperation(Token::Value op); |
195 static Bytecode BytecodeForLoadIC(LanguageMode language_mode); | 202 static Bytecode BytecodeForLoadIC(LanguageMode language_mode); |
196 static Bytecode BytecodeForKeyedLoadIC(LanguageMode language_mode); | 203 static Bytecode BytecodeForKeyedLoadIC(LanguageMode language_mode); |
197 static Bytecode BytecodeForStoreIC(LanguageMode language_mode); | 204 static Bytecode BytecodeForStoreIC(LanguageMode language_mode); |
198 static Bytecode BytecodeForKeyedStoreIC(LanguageMode language_mode); | 205 static Bytecode BytecodeForKeyedStoreIC(LanguageMode language_mode); |
199 static Bytecode BytecodeForLoadGlobal(LanguageMode language_mode); | 206 static Bytecode BytecodeForLoadGlobal(LanguageMode language_mode); |
200 static Bytecode BytecodeForStoreGlobal(LanguageMode language_mode); | 207 static Bytecode BytecodeForStoreGlobal(LanguageMode language_mode); |
| 208 static Bytecode BytecodeForCreateArguments(CreateArgumentsType type); |
201 | 209 |
202 static bool FitsInIdx8Operand(int value); | 210 static bool FitsInIdx8Operand(int value); |
203 static bool FitsInIdx8Operand(size_t value); | 211 static bool FitsInIdx8Operand(size_t value); |
204 static bool FitsInImm8Operand(int value); | 212 static bool FitsInImm8Operand(int value); |
205 static bool FitsInIdx16Operand(int value); | 213 static bool FitsInIdx16Operand(int value); |
206 | 214 |
207 static Bytecode GetJumpWithConstantOperand(Bytecode jump_with_smi8_operand); | 215 static Bytecode GetJumpWithConstantOperand(Bytecode jump_with_smi8_operand); |
208 | 216 |
209 template <size_t N> | 217 template <size_t N> |
210 INLINE(void Output(Bytecode bytecode, uint32_t(&oprands)[N])); | 218 INLINE(void Output(Bytecode bytecode, uint32_t(&oprands)[N])); |
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
320 | 328 |
321 DISALLOW_COPY_AND_ASSIGN(TemporaryRegisterScope); | 329 DISALLOW_COPY_AND_ASSIGN(TemporaryRegisterScope); |
322 }; | 330 }; |
323 | 331 |
324 | 332 |
325 } // namespace interpreter | 333 } // namespace interpreter |
326 } // namespace internal | 334 } // namespace internal |
327 } // namespace v8 | 335 } // namespace v8 |
328 | 336 |
329 #endif // V8_INTERPRETER_BYTECODE_ARRAY_BUILDER_H_ | 337 #endif // V8_INTERPRETER_BYTECODE_ARRAY_BUILDER_H_ |
OLD | NEW |