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

Unified Diff: src/interpreter/bytecode-array-builder.cc

Issue 1373903005: [Interpreter] Add for/while/do support to the bytecode generator. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Rebase. Created 5 years, 3 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/interpreter/bytecode-array-builder.h ('k') | src/interpreter/bytecode-generator.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/interpreter/bytecode-array-builder.cc
diff --git a/src/interpreter/bytecode-array-builder.cc b/src/interpreter/bytecode-array-builder.cc
index 9c6b5905ccf19ecb436b9689b5f0ba6a93762c13..f138e68b0c6c1d1da534846aa5c0173046fc6f25 100644
--- a/src/interpreter/bytecode-array-builder.cc
+++ b/src/interpreter/bytecode-array-builder.cc
@@ -10,6 +10,7 @@ namespace interpreter {
BytecodeArrayBuilder::BytecodeArrayBuilder(Isolate* isolate, Zone* zone)
: isolate_(isolate),
+ zone_(zone),
bytecodes_(zone),
bytecode_generated_(false),
last_block_end_(0),
@@ -314,11 +315,14 @@ BytecodeArrayBuilder& BytecodeArrayBuilder::Bind(BytecodeLabel* label) {
}
-// static
-bool BytecodeArrayBuilder::IsJumpWithImm8Operand(Bytecode jump_bytecode) {
- return jump_bytecode == Bytecode::kJump ||
- jump_bytecode == Bytecode::kJumpIfTrue ||
- jump_bytecode == Bytecode::kJumpIfFalse;
+BytecodeArrayBuilder& BytecodeArrayBuilder::Bind(const BytecodeLabel& target,
+ BytecodeLabel* label) {
+ DCHECK_EQ(label->is_bound(), false);
+ DCHECK_EQ(target.is_bound(), true);
+ PatchJump(bytecodes()->begin() + target.offset(),
+ bytecodes()->begin() + label->offset());
+ label->bind_to(target.offset());
+ return *this;
}
@@ -345,9 +349,9 @@ void BytecodeArrayBuilder::PatchJump(
Bytecode jump_bytecode = Bytecodes::FromByte(*jump_location);
int delta = static_cast<int>(jump_target - jump_location);
- DCHECK(IsJumpWithImm8Operand(jump_bytecode));
+ DCHECK(Bytecodes::IsJump(jump_bytecode));
DCHECK_EQ(Bytecodes::Size(jump_bytecode), 2);
- DCHECK_GE(delta, 0);
+ DCHECK_NE(delta, 0);
if (FitsInImm8Operand(delta)) {
// Just update the operand
@@ -357,8 +361,8 @@ void BytecodeArrayBuilder::PatchJump(
// Update the jump type and operand
size_t entry = GetConstantPoolEntry(handle(Smi::FromInt(delta), isolate()));
if (FitsInIdxOperand(entry)) {
- *jump_location++ =
- Bytecodes::ToByte(GetJumpWithConstantOperand(jump_bytecode));
+ jump_bytecode = GetJumpWithConstantOperand(jump_bytecode);
+ *jump_location++ = Bytecodes::ToByte(jump_bytecode);
*jump_location = static_cast<uint8_t>(entry);
} else {
// TODO(oth): OutputJump should reserve a constant pool entry
« no previous file with comments | « src/interpreter/bytecode-array-builder.h ('k') | src/interpreter/bytecode-generator.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698