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 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
66 | 66 |
67 // Returns the number of fixed and temporary registers. | 67 // Returns the number of fixed and temporary registers. |
68 int total_register_count() const { | 68 int total_register_count() const { |
69 DCHECK_LE(fixed_register_count(), | 69 DCHECK_LE(fixed_register_count(), |
70 register_allocator()->maximum_register_count()); | 70 register_allocator()->maximum_register_count()); |
71 return register_allocator()->maximum_register_count(); | 71 return register_allocator()->maximum_register_count(); |
72 } | 72 } |
73 | 73 |
74 Register Parameter(int parameter_index) const; | 74 Register Parameter(int parameter_index) const; |
75 | 75 |
| 76 // Same as Parameter(0), but indicates intent |
| 77 inline Register Receiver() const { return Parameter(0); } |
| 78 |
76 // Constant loads to accumulator. | 79 // Constant loads to accumulator. |
77 BytecodeArrayBuilder& LoadConstantPoolEntry(size_t entry); | 80 BytecodeArrayBuilder& LoadConstantPoolEntry(size_t entry); |
78 BytecodeArrayBuilder& LoadLiteral(v8::internal::Smi* value); | 81 BytecodeArrayBuilder& LoadLiteral(v8::internal::Smi* value); |
79 BytecodeArrayBuilder& LoadLiteral(Handle<Object> object); | 82 BytecodeArrayBuilder& LoadLiteral(Handle<Object> object); |
80 BytecodeArrayBuilder& LoadUndefined(); | 83 BytecodeArrayBuilder& LoadUndefined(); |
81 BytecodeArrayBuilder& LoadNull(); | 84 BytecodeArrayBuilder& LoadNull(); |
82 BytecodeArrayBuilder& LoadTheHole(); | 85 BytecodeArrayBuilder& LoadTheHole(); |
83 BytecodeArrayBuilder& LoadTrue(); | 86 BytecodeArrayBuilder& LoadTrue(); |
84 BytecodeArrayBuilder& LoadFalse(); | 87 BytecodeArrayBuilder& LoadFalse(); |
85 | 88 |
(...skipping 249 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
335 | 338 |
336 // Gets a constant pool entry for the |object|. | 339 // Gets a constant pool entry for the |object|. |
337 size_t GetConstantPoolEntry(Handle<Object> object); | 340 size_t GetConstantPoolEntry(Handle<Object> object); |
338 // Allocates a slot in the constant pool which can later be inserted. | 341 // Allocates a slot in the constant pool which can later be inserted. |
339 size_t AllocateConstantPoolEntry(); | 342 size_t AllocateConstantPoolEntry(); |
340 // Inserts a entry into an allocated constant pool entry. | 343 // Inserts a entry into an allocated constant pool entry. |
341 void InsertConstantPoolEntryAt(size_t entry, Handle<Object> object); | 344 void InsertConstantPoolEntryAt(size_t entry, Handle<Object> object); |
342 | 345 |
343 void InitializeReturnPosition(FunctionLiteral* literal); | 346 void InitializeReturnPosition(FunctionLiteral* literal); |
344 | 347 |
345 void SetStatementPosition(Statement* stmt) { | 348 inline void SetStatementPosition(Statement* stmt) { |
346 if (stmt->position() == kNoSourcePosition) return; | 349 SetStatementPosition(stmt->position()); |
347 latest_source_info_.MakeStatementPosition(stmt->position()); | |
348 } | 350 } |
349 | 351 |
350 void SetExpressionPosition(Expression* expr) { | 352 void SetStatementPosition(int position) { |
351 if (expr->position() == kNoSourcePosition) return; | 353 if (position == kNoSourcePosition) return; |
| 354 latest_source_info_.MakeStatementPosition(position); |
| 355 } |
| 356 |
| 357 inline void SetExpressionPosition(Expression* expr) { |
| 358 SetExpressionPosition(expr->position()); |
| 359 } |
| 360 |
| 361 void SetExpressionPosition(int position) { |
| 362 if (position == kNoSourcePosition) return; |
352 if (!latest_source_info_.is_statement()) { | 363 if (!latest_source_info_.is_statement()) { |
353 // Ensure the current expression position is overwritten with the | 364 // Ensure the current expression position is overwritten with the |
354 // latest value. | 365 // latest value. |
355 latest_source_info_.MakeExpressionPosition(expr->position()); | 366 latest_source_info_.MakeExpressionPosition(position); |
356 } | 367 } |
357 } | 368 } |
358 | 369 |
359 void SetExpressionAsStatementPosition(Expression* expr) { | 370 void SetExpressionAsStatementPosition(Expression* expr) { |
360 if (expr->position() == kNoSourcePosition) return; | 371 if (expr->position() == kNoSourcePosition) return; |
361 latest_source_info_.MakeStatementPosition(expr->position()); | 372 latest_source_info_.MakeStatementPosition(expr->position()); |
362 } | 373 } |
363 | 374 |
364 bool RequiresImplicitReturn() const { return !return_seen_in_block_; } | 375 bool RequiresImplicitReturn() const { return !return_seen_in_block_; } |
365 | 376 |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
443 static int const kNoFeedbackSlot = 0; | 454 static int const kNoFeedbackSlot = 0; |
444 | 455 |
445 DISALLOW_COPY_AND_ASSIGN(BytecodeArrayBuilder); | 456 DISALLOW_COPY_AND_ASSIGN(BytecodeArrayBuilder); |
446 }; | 457 }; |
447 | 458 |
448 } // namespace interpreter | 459 } // namespace interpreter |
449 } // namespace internal | 460 } // namespace internal |
450 } // namespace v8 | 461 } // namespace v8 |
451 | 462 |
452 #endif // V8_INTERPRETER_BYTECODE_ARRAY_BUILDER_H_ | 463 #endif // V8_INTERPRETER_BYTECODE_ARRAY_BUILDER_H_ |
OLD | NEW |