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 "src/ast/ast.h" | 8 #include "src/ast/ast.h" |
9 #include "src/base/compiler-specific.h" | 9 #include "src/base/compiler-specific.h" |
10 #include "src/globals.h" | 10 #include "src/globals.h" |
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
153 // up to |depth| in that context chain. | 153 // up to |depth| in that context chain. |
154 BytecodeArrayBuilder& LoadLookupGlobalSlot(const Handle<String> name, | 154 BytecodeArrayBuilder& LoadLookupGlobalSlot(const Handle<String> name, |
155 TypeofMode typeof_mode, | 155 TypeofMode typeof_mode, |
156 int feedback_slot, int depth); | 156 int feedback_slot, int depth); |
157 | 157 |
158 // Store value in the accumulator into the variable with |name|. | 158 // Store value in the accumulator into the variable with |name|. |
159 BytecodeArrayBuilder& StoreLookupSlot(const Handle<String> name, | 159 BytecodeArrayBuilder& StoreLookupSlot(const Handle<String> name, |
160 LanguageMode language_mode); | 160 LanguageMode language_mode); |
161 | 161 |
162 // Create a new closure for a SharedFunctionInfo which will be inserted at | 162 // Create a new closure for a SharedFunctionInfo which will be inserted at |
163 // constant pool index |entry|. | 163 // constant pool index |shared_function_info_entry|. |
164 BytecodeArrayBuilder& CreateClosure(size_t entry, int slot, int flags); | 164 BytecodeArrayBuilder& CreateClosure(size_t shared_function_info_entry, |
| 165 int slot, int flags); |
165 | 166 |
166 // Create a new local context for a |scope_info| and a closure which should be | 167 // Create a new local context for a |scope_info| and a closure which should be |
167 // in the accumulator. | 168 // in the accumulator. |
168 BytecodeArrayBuilder& CreateBlockContext(Handle<ScopeInfo> scope_info); | 169 BytecodeArrayBuilder& CreateBlockContext(Handle<ScopeInfo> scope_info); |
169 | 170 |
170 // Create a new context for a catch block with |exception|, |name|, | 171 // Create a new context for a catch block with |exception|, |name|, |
171 // |scope_info|, and the closure in the accumulator. | 172 // |scope_info|, and the closure in the accumulator. |
172 BytecodeArrayBuilder& CreateCatchContext(Register exception, | 173 BytecodeArrayBuilder& CreateCatchContext(Register exception, |
173 Handle<String> name, | 174 Handle<String> name, |
174 Handle<ScopeInfo> scope_info); | 175 Handle<ScopeInfo> scope_info); |
175 | 176 |
176 // Create a new context with size |slots|. | 177 // Create a new context with size |slots|. |
177 BytecodeArrayBuilder& CreateFunctionContext(int slots); | 178 BytecodeArrayBuilder& CreateFunctionContext(int slots); |
178 | 179 |
179 // Create a new eval context with size |slots|. | 180 // Create a new eval context with size |slots|. |
180 BytecodeArrayBuilder& CreateEvalContext(int slots); | 181 BytecodeArrayBuilder& CreateEvalContext(int slots); |
181 | 182 |
182 // Creates a new context with the given |scope_info| for a with-statement | 183 // Creates a new context with the given |scope_info| for a with-statement |
183 // with the |object| in a register and the closure in the accumulator. | 184 // with the |object| in a register and the closure in the accumulator. |
184 BytecodeArrayBuilder& CreateWithContext(Register object, | 185 BytecodeArrayBuilder& CreateWithContext(Register object, |
185 Handle<ScopeInfo> scope_info); | 186 Handle<ScopeInfo> scope_info); |
186 | 187 |
187 // Create a new arguments object in the accumulator. | 188 // Create a new arguments object in the accumulator. |
188 BytecodeArrayBuilder& CreateArguments(CreateArgumentsType type); | 189 BytecodeArrayBuilder& CreateArguments(CreateArgumentsType type); |
189 | 190 |
190 // Literals creation. Constant elements should be in the accumulator. | 191 // Literals creation. Constant elements should be in the accumulator. |
191 BytecodeArrayBuilder& CreateRegExpLiteral(Handle<String> pattern, | 192 BytecodeArrayBuilder& CreateRegExpLiteral(Handle<String> pattern, |
192 int literal_index, int flags); | 193 int literal_index, int flags); |
193 BytecodeArrayBuilder& CreateArrayLiteral( | 194 BytecodeArrayBuilder& CreateArrayLiteral(size_t constant_elements_entry, |
194 Handle<ConstantElementsPair> constant_elements, int literal_index, | 195 int literal_index, int flags); |
195 int flags); | 196 BytecodeArrayBuilder& CreateObjectLiteral(size_t constant_properties_entry, |
196 BytecodeArrayBuilder& CreateObjectLiteral( | 197 int literal_index, int flags, |
197 Handle<FixedArray> constant_properties, int literal_index, int flags, | 198 Register output); |
198 Register output); | |
199 | 199 |
200 // Push the context in accumulator as the new context, and store in register | 200 // Push the context in accumulator as the new context, and store in register |
201 // |context|. | 201 // |context|. |
202 BytecodeArrayBuilder& PushContext(Register context); | 202 BytecodeArrayBuilder& PushContext(Register context); |
203 | 203 |
204 // Pop the current context and replace with |context|. | 204 // Pop the current context and replace with |context|. |
205 BytecodeArrayBuilder& PopContext(Register context); | 205 BytecodeArrayBuilder& PopContext(Register context); |
206 | 206 |
207 // Call a JS function. The JSFunction or Callable to be called should be in | 207 // Call a JS function. The JSFunction or Callable to be called should be in |
208 // |callable|. The arguments should be in |args|, with the receiver in | 208 // |callable|. The arguments should be in |args|, with the receiver in |
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
321 // Exception handling. | 321 // Exception handling. |
322 BytecodeArrayBuilder& MarkHandler(int handler_id, | 322 BytecodeArrayBuilder& MarkHandler(int handler_id, |
323 HandlerTable::CatchPrediction will_catch); | 323 HandlerTable::CatchPrediction will_catch); |
324 BytecodeArrayBuilder& MarkTryBegin(int handler_id, Register context); | 324 BytecodeArrayBuilder& MarkTryBegin(int handler_id, Register context); |
325 BytecodeArrayBuilder& MarkTryEnd(int handler_id); | 325 BytecodeArrayBuilder& MarkTryEnd(int handler_id); |
326 | 326 |
327 // Creates a new handler table entry and returns a {hander_id} identifying the | 327 // Creates a new handler table entry and returns a {hander_id} identifying the |
328 // entry, so that it can be referenced by above exception handling support. | 328 // entry, so that it can be referenced by above exception handling support. |
329 int NewHandlerEntry() { return handler_table_builder()->NewHandlerEntry(); } | 329 int NewHandlerEntry() { return handler_table_builder()->NewHandlerEntry(); } |
330 | 330 |
| 331 // Gets a constant pool entry for the |object|. |
| 332 size_t GetConstantPoolEntry(Handle<Object> object); |
331 // Allocates a slot in the constant pool which can later be inserted. | 333 // Allocates a slot in the constant pool which can later be inserted. |
332 size_t AllocateConstantPoolEntry(); | 334 size_t AllocateConstantPoolEntry(); |
333 // Inserts a entry into an allocated constant pool entry. | 335 // Inserts a entry into an allocated constant pool entry. |
334 void InsertConstantPoolEntryAt(size_t entry, Handle<Object> object); | 336 void InsertConstantPoolEntryAt(size_t entry, Handle<Object> object); |
335 | 337 |
336 void InitializeReturnPosition(FunctionLiteral* literal); | 338 void InitializeReturnPosition(FunctionLiteral* literal); |
337 | 339 |
338 void SetStatementPosition(Statement* stmt) { | 340 void SetStatementPosition(Statement* stmt) { |
339 if (stmt->position() == kNoSourcePosition) return; | 341 if (stmt->position() == kNoSourcePosition) return; |
340 latest_source_info_.MakeStatementPosition(stmt->position()); | 342 latest_source_info_.MakeStatementPosition(stmt->position()); |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
387 INLINE(void Output##Name(BytecodeLabel* label, Operands... operands)); | 389 INLINE(void Output##Name(BytecodeLabel* label, Operands... operands)); |
388 BYTECODE_LIST(DECLARE_BYTECODE_OUTPUT) | 390 BYTECODE_LIST(DECLARE_BYTECODE_OUTPUT) |
389 #undef DECLARE_OPERAND_TYPE_INFO | 391 #undef DECLARE_OPERAND_TYPE_INFO |
390 | 392 |
391 bool RegisterIsValid(Register reg) const; | 393 bool RegisterIsValid(Register reg) const; |
392 bool RegisterListIsValid(RegisterList reg_list) const; | 394 bool RegisterListIsValid(RegisterList reg_list) const; |
393 | 395 |
394 // Set position for return. | 396 // Set position for return. |
395 void SetReturnPosition(); | 397 void SetReturnPosition(); |
396 | 398 |
397 // Gets a constant pool entry for the |object|. | |
398 size_t GetConstantPoolEntry(Handle<Object> object); | |
399 | |
400 // Not implemented as the illegal bytecode is used inside internally | 399 // Not implemented as the illegal bytecode is used inside internally |
401 // to indicate a bytecode field is not valid or an error has occured | 400 // to indicate a bytecode field is not valid or an error has occured |
402 // during bytecode generation. | 401 // during bytecode generation. |
403 BytecodeArrayBuilder& Illegal(); | 402 BytecodeArrayBuilder& Illegal(); |
404 | 403 |
405 template <Bytecode bytecode, AccumulatorUse accumulator_use> | 404 template <Bytecode bytecode, AccumulatorUse accumulator_use> |
406 void PrepareToOutputBytecode(); | 405 void PrepareToOutputBytecode(); |
407 | 406 |
408 void LeaveBasicBlock() { return_seen_in_block_ = false; } | 407 void LeaveBasicBlock() { return_seen_in_block_ = false; } |
409 | 408 |
(...skipping 29 matching lines...) Expand all Loading... |
439 static int const kNoFeedbackSlot = 0; | 438 static int const kNoFeedbackSlot = 0; |
440 | 439 |
441 DISALLOW_COPY_AND_ASSIGN(BytecodeArrayBuilder); | 440 DISALLOW_COPY_AND_ASSIGN(BytecodeArrayBuilder); |
442 }; | 441 }; |
443 | 442 |
444 } // namespace interpreter | 443 } // namespace interpreter |
445 } // namespace internal | 444 } // namespace internal |
446 } // namespace v8 | 445 } // namespace v8 |
447 | 446 |
448 #endif // V8_INTERPRETER_BYTECODE_ARRAY_BUILDER_H_ | 447 #endif // V8_INTERPRETER_BYTECODE_ARRAY_BUILDER_H_ |
OLD | NEW |