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-writer.h" | 5 #include "src/interpreter/bytecode-array-writer.h" |
6 | 6 |
7 #include "src/api.h" | 7 #include "src/api.h" |
8 #include "src/interpreter/bytecode-label.h" | 8 #include "src/interpreter/bytecode-label.h" |
9 #include "src/interpreter/bytecode-register.h" | 9 #include "src/interpreter/bytecode-register.h" |
10 #include "src/interpreter/constant-array-builder.h" | 10 #include "src/interpreter/constant-array-builder.h" |
(...skipping 339 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
350 CHECK_LE(current_offset, static_cast<size_t>(kMaxInt)); | 350 CHECK_LE(current_offset, static_cast<size_t>(kMaxInt)); |
351 // Label has been bound already so this is a backwards jump. | 351 // Label has been bound already so this is a backwards jump. |
352 size_t abs_delta = current_offset - label->offset(); | 352 size_t abs_delta = current_offset - label->offset(); |
353 int delta = -static_cast<int>(abs_delta); | 353 int delta = -static_cast<int>(abs_delta); |
354 OperandSize operand_size = Bytecodes::SizeForSignedOperand(delta); | 354 OperandSize operand_size = Bytecodes::SizeForSignedOperand(delta); |
355 if (operand_size > OperandSize::kByte) { | 355 if (operand_size > OperandSize::kByte) { |
356 // Adjust for scaling byte prefix for wide jump offset. | 356 // Adjust for scaling byte prefix for wide jump offset. |
357 DCHECK_LE(delta, 0); | 357 DCHECK_LE(delta, 0); |
358 delta -= 1; | 358 delta -= 1; |
359 } | 359 } |
360 node->set_bytecode(node->bytecode(), delta); | 360 if (node->bytecode() == Bytecode::kJumpLoop) { |
361 node->set_bytecode(node->bytecode(), delta, node->operand(1)); | |
rmcilroy
2016/09/13 10:47:34
Do we ever have label's bound which don't have Byt
Michael Starzinger
2016/09/13 12:01:46
Done. Just the unit-tests, adapted the tests.
| |
362 } else { | |
363 node->set_bytecode(node->bytecode(), delta); | |
364 } | |
361 } else { | 365 } else { |
362 // The label has not yet been bound so this is a forward reference | 366 // The label has not yet been bound so this is a forward reference |
rmcilroy
2016/09/13 10:47:34
Could you add a DCHECK that this is not Bytecode::
Michael Starzinger
2016/09/13 12:01:46
Done.
| |
363 // that will be patched when the label is bound. We create a | 367 // that will be patched when the label is bound. We create a |
364 // reservation in the constant pool so the jump can be patched | 368 // reservation in the constant pool so the jump can be patched |
365 // when the label is bound. The reservation means the maximum size | 369 // when the label is bound. The reservation means the maximum size |
366 // of the operand for the constant is known and the jump can | 370 // of the operand for the constant is known and the jump can |
367 // be emitted into the bytecode stream with space for the operand. | 371 // be emitted into the bytecode stream with space for the operand. |
368 unbound_jumps_++; | 372 unbound_jumps_++; |
369 label->set_referrer(current_offset); | 373 label->set_referrer(current_offset); |
370 OperandSize reserved_operand_size = | 374 OperandSize reserved_operand_size = |
371 constant_array_builder()->CreateReservedEntry(); | 375 constant_array_builder()->CreateReservedEntry(); |
372 switch (reserved_operand_size) { | 376 switch (reserved_operand_size) { |
(...skipping 10 matching lines...) Expand all Loading... | |
383 node->set_bytecode(node->bytecode(), k32BitJumpPlaceholder); | 387 node->set_bytecode(node->bytecode(), k32BitJumpPlaceholder); |
384 break; | 388 break; |
385 } | 389 } |
386 } | 390 } |
387 EmitBytecode(node); | 391 EmitBytecode(node); |
388 } | 392 } |
389 | 393 |
390 } // namespace interpreter | 394 } // namespace interpreter |
391 } // namespace internal | 395 } // namespace internal |
392 } // namespace v8 | 396 } // namespace v8 |
OLD | NEW |