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 #include "src/compiler.h" | 6 #include "src/compiler.h" |
7 #include "src/interpreter/interpreter-intrinsics.h" | 7 #include "src/interpreter/interpreter-intrinsics.h" |
8 | 8 |
9 namespace v8 { | 9 namespace v8 { |
10 namespace internal { | 10 namespace internal { |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
89 Bytecode bytecode_; | 89 Bytecode bytecode_; |
90 size_t previous_bytecode_start_; | 90 size_t previous_bytecode_start_; |
91 | 91 |
92 DISALLOW_COPY_AND_ASSIGN(PreviousBytecodeHelper); | 92 DISALLOW_COPY_AND_ASSIGN(PreviousBytecodeHelper); |
93 }; | 93 }; |
94 | 94 |
95 BytecodeArrayBuilder::BytecodeArrayBuilder(Isolate* isolate, Zone* zone, | 95 BytecodeArrayBuilder::BytecodeArrayBuilder(Isolate* isolate, Zone* zone, |
96 int parameter_count, | 96 int parameter_count, |
97 int context_count, int locals_count, | 97 int context_count, int locals_count, |
98 FunctionLiteral* literal) | 98 FunctionLiteral* literal) |
99 : isolate_(isolate), | 99 : generator_resume_points(0, zone), |
100 isolate_(isolate), | |
100 zone_(zone), | 101 zone_(zone), |
101 bytecodes_(zone), | 102 bytecodes_(zone), |
102 bytecode_generated_(false), | 103 bytecode_generated_(false), |
103 constant_array_builder_(isolate, zone), | 104 constant_array_builder_(isolate, zone), |
104 handler_table_builder_(isolate, zone), | 105 handler_table_builder_(isolate, zone), |
105 source_position_table_builder_(isolate, zone), | 106 source_position_table_builder_(isolate, zone), |
106 last_block_end_(0), | 107 last_block_end_(0), |
107 last_bytecode_start_(~0), | 108 last_bytecode_start_(~0), |
108 exit_seen_in_block_(false), | 109 exit_seen_in_block_(false), |
109 unbound_jumps_(0), | 110 unbound_jumps_(0), |
110 parameter_count_(parameter_count), | 111 parameter_count_(parameter_count), |
111 local_register_count_(locals_count), | 112 local_register_count_(locals_count), |
112 context_register_count_(context_count), | 113 context_register_count_(context_count), |
113 temporary_allocator_(zone, fixed_register_count()) { | 114 temporary_allocator_(zone, fixed_register_count()), |
115 generator_yields_seen_(0) { | |
114 DCHECK_GE(parameter_count_, 0); | 116 DCHECK_GE(parameter_count_, 0); |
115 DCHECK_GE(context_register_count_, 0); | 117 DCHECK_GE(context_register_count_, 0); |
116 DCHECK_GE(local_register_count_, 0); | 118 DCHECK_GE(local_register_count_, 0); |
117 return_position_ = | 119 return_position_ = |
118 literal ? std::max(literal->start_position(), literal->end_position() - 1) | 120 literal ? std::max(literal->start_position(), literal->end_position() - 1) |
119 : RelocInfo::kNoPosition; | 121 : RelocInfo::kNoPosition; |
120 LOG_CODE_EVENT(isolate_, CodeStartLinePosInfoRecordEvent( | 122 LOG_CODE_EVENT(isolate_, CodeStartLinePosInfoRecordEvent( |
121 source_position_table_builder())); | 123 source_position_table_builder())); |
122 } | 124 } |
123 | 125 |
(...skipping 744 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
868 BytecodeArrayBuilder& BytecodeArrayBuilder::StackCheck() { | 870 BytecodeArrayBuilder& BytecodeArrayBuilder::StackCheck() { |
869 Output(Bytecode::kStackCheck); | 871 Output(Bytecode::kStackCheck); |
870 return *this; | 872 return *this; |
871 } | 873 } |
872 | 874 |
873 BytecodeArrayBuilder& BytecodeArrayBuilder::JumpIfNotHole( | 875 BytecodeArrayBuilder& BytecodeArrayBuilder::JumpIfNotHole( |
874 BytecodeLabel* label) { | 876 BytecodeLabel* label) { |
875 return OutputJump(Bytecode::kJumpIfNotHole, label); | 877 return OutputJump(Bytecode::kJumpIfNotHole, label); |
876 } | 878 } |
877 | 879 |
880 | |
881 BytecodeArrayBuilder& BytecodeArrayBuilder::IndexedJump( | |
rmcilroy
2016/04/19 09:30:03
As mentioned in a comment below, I think this shou
neis
2016/04/19 11:02:15
Ack. I thought my IndexedJump would fit well next
| |
882 Register index, int min, size_t size, ZoneVector<BytecodeLabel>& targets) { | |
883 // TODO(neis): Optimize this by using a proper jump table. | |
884 for (int i = min; i < min + size; i++) { | |
885 DCHECK(0 <= i && i < targets.size()); | |
886 LoadLiteral(Smi::FromInt(static_cast<int>(i))); | |
887 CompareOperation(Token::Value::EQ_STRICT, index); | |
888 JumpIfTrue(&(targets[i])); | |
889 } | |
890 Illegal(); // Should never get here. | |
891 return *this; | |
892 } | |
893 | |
894 | |
878 BytecodeArrayBuilder& BytecodeArrayBuilder::Throw() { | 895 BytecodeArrayBuilder& BytecodeArrayBuilder::Throw() { |
879 Output(Bytecode::kThrow); | 896 Output(Bytecode::kThrow); |
880 exit_seen_in_block_ = true; | 897 exit_seen_in_block_ = true; |
881 return *this; | 898 return *this; |
882 } | 899 } |
883 | 900 |
884 | 901 |
885 BytecodeArrayBuilder& BytecodeArrayBuilder::ReThrow() { | 902 BytecodeArrayBuilder& BytecodeArrayBuilder::ReThrow() { |
886 Output(Bytecode::kReThrow); | 903 Output(Bytecode::kReThrow); |
887 exit_seen_in_block_ = true; | 904 exit_seen_in_block_ = true; |
(...skipping 601 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1489 } | 1506 } |
1490 | 1507 |
1491 uint32_t BytecodeArrayBuilder::UnsignedOperand(size_t value) { | 1508 uint32_t BytecodeArrayBuilder::UnsignedOperand(size_t value) { |
1492 DCHECK_LE(value, kMaxUInt32); | 1509 DCHECK_LE(value, kMaxUInt32); |
1493 return static_cast<uint32_t>(value); | 1510 return static_cast<uint32_t>(value); |
1494 } | 1511 } |
1495 | 1512 |
1496 } // namespace interpreter | 1513 } // namespace interpreter |
1497 } // namespace internal | 1514 } // namespace internal |
1498 } // namespace v8 | 1515 } // namespace v8 |
OLD | NEW |