Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(194)

Side by Side Diff: src/interpreter/bytecode-array-writer.cc

Issue 2641443002: [ignition] Use absolute values for jump offsets (Closed)
Patch Set: Fix build Created 3 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 264 matching lines...) Expand 10 before | Expand all | Expand 10 after
275 } 275 }
276 276
277 void BytecodeArrayWriter::EmitJump(BytecodeNode* node, BytecodeLabel* label) { 277 void BytecodeArrayWriter::EmitJump(BytecodeNode* node, BytecodeLabel* label) {
278 DCHECK(Bytecodes::IsJump(node->bytecode())); 278 DCHECK(Bytecodes::IsJump(node->bytecode()));
279 DCHECK_EQ(0u, node->operand(0)); 279 DCHECK_EQ(0u, node->operand(0));
280 280
281 size_t current_offset = bytecodes()->size(); 281 size_t current_offset = bytecodes()->size();
282 282
283 if (label->is_bound()) { 283 if (label->is_bound()) {
284 CHECK_GE(current_offset, label->offset()); 284 CHECK_GE(current_offset, label->offset());
285 CHECK_LE(current_offset, static_cast<size_t>(kMaxInt)); 285 CHECK_LE(current_offset, static_cast<size_t>(kMaxUInt32));
286 // Label has been bound already so this is a backwards jump. 286 // Label has been bound already so this is a backwards jump.
287 size_t abs_delta = current_offset - label->offset(); 287 uint32_t delta = static_cast<uint32_t>(current_offset - label->offset());
288 int delta = -static_cast<int>(abs_delta); 288 OperandScale operand_scale = Bytecodes::ScaleForUnsignedOperand(delta);
289 OperandScale operand_scale = Bytecodes::ScaleForSignedOperand(delta);
290 if (operand_scale > OperandScale::kSingle) { 289 if (operand_scale > OperandScale::kSingle) {
291 // Adjust for scaling byte prefix for wide jump offset. 290 // Adjust for scaling byte prefix for wide jump offset.
292 DCHECK_LE(delta, 0); 291 delta += 1;
293 delta -= 1;
294 } 292 }
295 DCHECK_EQ(Bytecode::kJumpLoop, node->bytecode()); 293 DCHECK_EQ(Bytecode::kJumpLoop, node->bytecode());
296 node->update_operand0(delta); 294 node->update_operand0(delta);
297 } else { 295 } else {
298 // The label has not yet been bound so this is a forward reference 296 // The label has not yet been bound so this is a forward reference
299 // that will be patched when the label is bound. We create a 297 // that will be patched when the label is bound. We create a
300 // reservation in the constant pool so the jump can be patched 298 // reservation in the constant pool so the jump can be patched
301 // when the label is bound. The reservation means the maximum size 299 // when the label is bound. The reservation means the maximum size
302 // of the operand for the constant is known and the jump can 300 // of the operand for the constant is known and the jump can
303 // be emitted into the bytecode stream with space for the operand. 301 // be emitted into the bytecode stream with space for the operand.
(...skipping 16 matching lines...) Expand all
320 node->update_operand0(k32BitJumpPlaceholder); 318 node->update_operand0(k32BitJumpPlaceholder);
321 break; 319 break;
322 } 320 }
323 } 321 }
324 EmitBytecode(node); 322 EmitBytecode(node);
325 } 323 }
326 324
327 } // namespace interpreter 325 } // namespace interpreter
328 } // namespace internal 326 } // namespace internal
329 } // namespace v8 327 } // namespace v8
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698