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

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

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

Powered by Google App Engine
This is Rietveld 408576698