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

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

Issue 2542903003: [Interpreter] Templatize AccumulatorUsage and OperandType for bytecode creation. (Closed)
Patch Set: Rebase Created 4 years 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 272 matching lines...) Expand 10 before | Expand all | Expand 10 after
283 // Label has been bound already so this is a backwards jump. 283 // Label has been bound already so this is a backwards jump.
284 size_t abs_delta = current_offset - label->offset(); 284 size_t abs_delta = current_offset - label->offset();
285 int delta = -static_cast<int>(abs_delta); 285 int delta = -static_cast<int>(abs_delta);
286 OperandScale operand_scale = Bytecodes::ScaleForSignedOperand(delta); 286 OperandScale operand_scale = Bytecodes::ScaleForSignedOperand(delta);
287 if (operand_scale > OperandScale::kSingle) { 287 if (operand_scale > OperandScale::kSingle) {
288 // Adjust for scaling byte prefix for wide jump offset. 288 // Adjust for scaling byte prefix for wide jump offset.
289 DCHECK_LE(delta, 0); 289 DCHECK_LE(delta, 0);
290 delta -= 1; 290 delta -= 1;
291 } 291 }
292 DCHECK_EQ(Bytecode::kJumpLoop, node->bytecode()); 292 DCHECK_EQ(Bytecode::kJumpLoop, node->bytecode());
293 node->set_bytecode(node->bytecode(), delta, node->operand(1)); 293 node->update_operand0(delta);
294 } else { 294 } else {
295 // The label has not yet been bound so this is a forward reference 295 // The label has not yet been bound so this is a forward reference
296 // that will be patched when the label is bound. We create a 296 // that will be patched when the label is bound. We create a
297 // reservation in the constant pool so the jump can be patched 297 // reservation in the constant pool so the jump can be patched
298 // when the label is bound. The reservation means the maximum size 298 // when the label is bound. The reservation means the maximum size
299 // of the operand for the constant is known and the jump can 299 // of the operand for the constant is known and the jump can
300 // be emitted into the bytecode stream with space for the operand. 300 // be emitted into the bytecode stream with space for the operand.
301 unbound_jumps_++; 301 unbound_jumps_++;
302 label->set_referrer(current_offset); 302 label->set_referrer(current_offset);
303 OperandSize reserved_operand_size = 303 OperandSize reserved_operand_size =
304 constant_array_builder()->CreateReservedEntry(); 304 constant_array_builder()->CreateReservedEntry();
305 DCHECK_NE(Bytecode::kJumpLoop, node->bytecode()); 305 DCHECK_NE(Bytecode::kJumpLoop, node->bytecode());
306 switch (reserved_operand_size) { 306 switch (reserved_operand_size) {
307 case OperandSize::kNone: 307 case OperandSize::kNone:
308 UNREACHABLE(); 308 UNREACHABLE();
309 break; 309 break;
310 case OperandSize::kByte: 310 case OperandSize::kByte:
311 node->set_bytecode(node->bytecode(), k8BitJumpPlaceholder); 311 node->update_operand0(k8BitJumpPlaceholder);
312 break; 312 break;
313 case OperandSize::kShort: 313 case OperandSize::kShort:
314 node->set_bytecode(node->bytecode(), k16BitJumpPlaceholder); 314 node->update_operand0(k16BitJumpPlaceholder);
315 break; 315 break;
316 case OperandSize::kQuad: 316 case OperandSize::kQuad:
317 node->set_bytecode(node->bytecode(), k32BitJumpPlaceholder); 317 node->update_operand0(k32BitJumpPlaceholder);
318 break; 318 break;
319 } 319 }
320 } 320 }
321 EmitBytecode(node); 321 EmitBytecode(node);
322 } 322 }
323 323
324 } // namespace interpreter 324 } // namespace interpreter
325 } // namespace internal 325 } // namespace internal
326 } // namespace v8 326 } // namespace v8
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698