| 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/constant-array-builder.h" | 5 #include "src/interpreter/constant-array-builder.h" |
| 6 | 6 |
| 7 #include "src/isolate.h" | 7 #include "src/isolate.h" |
| 8 #include "src/objects-inl.h" | 8 #include "src/objects-inl.h" |
| 9 | 9 |
| 10 namespace v8 { | 10 namespace v8 { |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 51 ConstantArrayBuilder::k16BitCapacity; | 51 ConstantArrayBuilder::k16BitCapacity; |
| 52 STATIC_CONST_MEMBER_DEFINITION const size_t | 52 STATIC_CONST_MEMBER_DEFINITION const size_t |
| 53 ConstantArrayBuilder::k32BitCapacity; | 53 ConstantArrayBuilder::k32BitCapacity; |
| 54 | 54 |
| 55 ConstantArrayBuilder::ConstantArrayBuilder(Isolate* isolate, Zone* zone) | 55 ConstantArrayBuilder::ConstantArrayBuilder(Isolate* isolate, Zone* zone) |
| 56 : isolate_(isolate), constants_map_(isolate->heap(), zone) { | 56 : isolate_(isolate), constants_map_(isolate->heap(), zone) { |
| 57 idx_slice_[0] = | 57 idx_slice_[0] = |
| 58 new (zone) ConstantArraySlice(zone, 0, k8BitCapacity, OperandSize::kByte); | 58 new (zone) ConstantArraySlice(zone, 0, k8BitCapacity, OperandSize::kByte); |
| 59 idx_slice_[1] = new (zone) ConstantArraySlice( | 59 idx_slice_[1] = new (zone) ConstantArraySlice( |
| 60 zone, k8BitCapacity, k16BitCapacity, OperandSize::kShort); | 60 zone, k8BitCapacity, k16BitCapacity, OperandSize::kShort); |
| 61 idx_slice_[2] = new (zone) ConstantArraySlice( |
| 62 zone, k16BitCapacity, k32BitCapacity, OperandSize::kQuad); |
| 61 } | 63 } |
| 62 | 64 |
| 63 size_t ConstantArrayBuilder::size() const { | 65 size_t ConstantArrayBuilder::size() const { |
| 64 size_t i = arraysize(idx_slice_); | 66 size_t i = arraysize(idx_slice_); |
| 65 while (i > 0) { | 67 while (i > 0) { |
| 66 ConstantArraySlice* slice = idx_slice_[--i]; | 68 ConstantArraySlice* slice = idx_slice_[--i]; |
| 67 if (slice->size() > 0) { | 69 if (slice->size() > 0) { |
| 68 return slice->start_index() + slice->size(); | 70 return slice->start_index() + slice->size(); |
| 69 } | 71 } |
| 70 } | 72 } |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 157 switch (operand_size) { | 159 switch (operand_size) { |
| 158 case OperandSize::kNone: | 160 case OperandSize::kNone: |
| 159 UNREACHABLE(); | 161 UNREACHABLE(); |
| 160 break; | 162 break; |
| 161 case OperandSize::kByte: | 163 case OperandSize::kByte: |
| 162 slice = idx_slice_[0]; | 164 slice = idx_slice_[0]; |
| 163 break; | 165 break; |
| 164 case OperandSize::kShort: | 166 case OperandSize::kShort: |
| 165 slice = idx_slice_[1]; | 167 slice = idx_slice_[1]; |
| 166 break; | 168 break; |
| 169 case OperandSize::kQuad: |
| 170 slice = idx_slice_[2]; |
| 171 break; |
| 167 } | 172 } |
| 168 DCHECK(slice->operand_size() == operand_size); | 173 DCHECK(slice->operand_size() == operand_size); |
| 169 return slice; | 174 return slice; |
| 170 } | 175 } |
| 171 | 176 |
| 172 size_t ConstantArrayBuilder::CommitReservedEntry(OperandSize operand_size, | 177 size_t ConstantArrayBuilder::CommitReservedEntry(OperandSize operand_size, |
| 173 Handle<Object> object) { | 178 Handle<Object> object) { |
| 174 DiscardReservedEntry(operand_size); | 179 DiscardReservedEntry(operand_size); |
| 175 size_t index; | 180 size_t index; |
| 176 index_t* entry = constants_map()->Find(object); | 181 index_t* entry = constants_map()->Find(object); |
| (...skipping 12 matching lines...) Expand all Loading... |
| 189 return index; | 194 return index; |
| 190 } | 195 } |
| 191 | 196 |
| 192 void ConstantArrayBuilder::DiscardReservedEntry(OperandSize operand_size) { | 197 void ConstantArrayBuilder::DiscardReservedEntry(OperandSize operand_size) { |
| 193 OperandSizeToSlice(operand_size)->Unreserve(); | 198 OperandSizeToSlice(operand_size)->Unreserve(); |
| 194 } | 199 } |
| 195 | 200 |
| 196 } // namespace interpreter | 201 } // namespace interpreter |
| 197 } // namespace internal | 202 } // namespace internal |
| 198 } // namespace v8 | 203 } // namespace v8 |
| OLD | NEW |