Chromium Code Reviews| 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 #include "src/interpreter/bytecode-array-builder.h" | 5 #include "src/interpreter/bytecode-array-builder.h" |
| 6 | 6 |
| 7 #include "src/compiler.h" | 7 #include "src/compiler.h" |
| 8 #include "src/globals.h" | 8 #include "src/globals.h" |
| 9 #include "src/interpreter/bytecode-array-writer.h" | 9 #include "src/interpreter/bytecode-array-writer.h" |
| 10 #include "src/interpreter/bytecode-dead-code-optimizer.h" | 10 #include "src/interpreter/bytecode-dead-code-optimizer.h" |
| (...skipping 12 matching lines...) Expand all Loading... | |
| 23 FunctionLiteral* literal) | 23 FunctionLiteral* literal) |
| 24 : isolate_(isolate), | 24 : isolate_(isolate), |
| 25 zone_(zone), | 25 zone_(zone), |
| 26 bytecode_generated_(false), | 26 bytecode_generated_(false), |
| 27 constant_array_builder_(isolate, zone), | 27 constant_array_builder_(isolate, zone), |
| 28 handler_table_builder_(isolate, zone), | 28 handler_table_builder_(isolate, zone), |
| 29 return_seen_in_block_(false), | 29 return_seen_in_block_(false), |
| 30 parameter_count_(parameter_count), | 30 parameter_count_(parameter_count), |
| 31 local_register_count_(locals_count), | 31 local_register_count_(locals_count), |
| 32 context_register_count_(context_count), | 32 context_register_count_(context_count), |
| 33 literal_(literal), | |
| 33 temporary_allocator_(zone, fixed_register_count()), | 34 temporary_allocator_(zone, fixed_register_count()), |
| 34 bytecode_array_writer_(isolate, zone, &constant_array_builder_), | 35 bytecode_array_writer_(isolate, zone, &constant_array_builder_), |
| 35 pipeline_(&bytecode_array_writer_) { | 36 pipeline_(&bytecode_array_writer_) { |
| 36 DCHECK_GE(parameter_count_, 0); | 37 DCHECK_GE(parameter_count_, 0); |
| 37 DCHECK_GE(context_register_count_, 0); | 38 DCHECK_GE(context_register_count_, 0); |
| 38 DCHECK_GE(local_register_count_, 0); | 39 DCHECK_GE(local_register_count_, 0); |
| 39 | 40 |
| 40 if (FLAG_ignition_deadcode) { | 41 if (FLAG_ignition_deadcode) { |
| 41 pipeline_ = new (zone) BytecodeDeadCodeOptimizer(pipeline_); | 42 pipeline_ = new (zone) BytecodeDeadCodeOptimizer(pipeline_); |
| 42 } | 43 } |
| 43 | 44 |
| 44 if (FLAG_ignition_peephole) { | 45 if (FLAG_ignition_peephole) { |
| 45 pipeline_ = new (zone) | 46 pipeline_ = new (zone) |
| 46 BytecodePeepholeOptimizer(&constant_array_builder_, pipeline_); | 47 BytecodePeepholeOptimizer(&constant_array_builder_, pipeline_); |
| 47 } | 48 } |
| 48 | 49 |
| 49 if (FLAG_ignition_reo) { | 50 if (FLAG_ignition_reo) { |
| 50 pipeline_ = new (zone) BytecodeRegisterOptimizer( | 51 pipeline_ = new (zone) BytecodeRegisterOptimizer( |
| 51 zone, &temporary_allocator_, parameter_count, pipeline_); | 52 zone, &temporary_allocator_, parameter_count, pipeline_); |
| 52 } | 53 } |
| 53 | |
| 54 return_position_ = | |
| 55 literal ? std::max(literal->start_position(), literal->end_position() - 1) | |
| 56 : kNoSourcePosition; | |
| 57 } | 54 } |
| 58 | 55 |
| 59 Register BytecodeArrayBuilder::first_context_register() const { | 56 Register BytecodeArrayBuilder::first_context_register() const { |
| 60 DCHECK_GT(context_register_count_, 0); | 57 DCHECK_GT(context_register_count_, 0); |
| 61 return Register(local_register_count_); | 58 return Register(local_register_count_); |
| 62 } | 59 } |
| 63 | 60 |
| 64 Register BytecodeArrayBuilder::last_context_register() const { | 61 Register BytecodeArrayBuilder::last_context_register() const { |
| 65 DCHECK_GT(context_register_count_, 0); | 62 DCHECK_GT(context_register_count_, 0); |
| 66 return Register(local_register_count_ + context_register_count_ - 1); | 63 return Register(local_register_count_ + context_register_count_ - 1); |
| (...skipping 558 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 625 LanguageMode language_mode) { | 622 LanguageMode language_mode) { |
| 626 Output(BytecodeForDelete(language_mode), RegisterOperand(object)); | 623 Output(BytecodeForDelete(language_mode), RegisterOperand(object)); |
| 627 return *this; | 624 return *this; |
| 628 } | 625 } |
| 629 | 626 |
| 630 size_t BytecodeArrayBuilder::GetConstantPoolEntry(Handle<Object> object) { | 627 size_t BytecodeArrayBuilder::GetConstantPoolEntry(Handle<Object> object) { |
| 631 return constant_array_builder()->Insert(object); | 628 return constant_array_builder()->Insert(object); |
| 632 } | 629 } |
| 633 | 630 |
| 634 void BytecodeArrayBuilder::SetReturnPosition() { | 631 void BytecodeArrayBuilder::SetReturnPosition() { |
| 635 if (return_position_ == kNoSourcePosition) return; | 632 if (literal_ == nullptr) return; |
| 636 latest_source_info_.MakeStatementPosition(return_position_); | 633 int position = |
| 634 std::max(literal_->start_position(), literal_->end_position() - 1); | |
| 635 latest_source_info_.MakeStatementPosition(position); | |
|
Dan Ehrenberg
2016/07/07 00:25:41
What does this change have to do with the other pa
Yang
2016/07/07 04:00:47
Since we now store the function literal anyways, w
| |
| 637 } | 636 } |
| 638 | 637 |
| 639 void BytecodeArrayBuilder::SetStatementPosition(Statement* stmt) { | 638 void BytecodeArrayBuilder::SetStatementPosition(Statement* stmt) { |
| 640 if (stmt->position() == kNoSourcePosition) return; | 639 if (stmt->position() == kNoSourcePosition) return; |
| 641 latest_source_info_.MakeStatementPosition(stmt->position()); | 640 latest_source_info_.MakeStatementPosition(stmt->position()); |
| 642 } | 641 } |
| 643 | 642 |
| 644 void BytecodeArrayBuilder::SetExpressionPosition(Expression* expr) { | 643 void BytecodeArrayBuilder::SetExpressionPosition(Expression* expr) { |
| 645 if (expr->position() == kNoSourcePosition) return; | 644 if (expr->position() == kNoSourcePosition) return; |
| 646 if (!latest_source_info_.is_statement()) { | 645 if (!latest_source_info_.is_statement()) { |
| (...skipping 284 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 931 return Bytecode::kTailCall; | 930 return Bytecode::kTailCall; |
| 932 default: | 931 default: |
| 933 UNREACHABLE(); | 932 UNREACHABLE(); |
| 934 } | 933 } |
| 935 return Bytecode::kIllegal; | 934 return Bytecode::kIllegal; |
| 936 } | 935 } |
| 937 | 936 |
| 938 } // namespace interpreter | 937 } // namespace interpreter |
| 939 } // namespace internal | 938 } // namespace internal |
| 940 } // namespace v8 | 939 } // namespace v8 |
| OLD | NEW |