Commit 06fe8afe authored by bmeurer's avatar bmeurer Committed by Commit bot

[interpreter] ToObject never yields null.

We don't need to compare the result of ToObject against null, since
ToObject will always yield a proper receiver (or throw a TypeError).

R=rmcilroy@chromium.org

Review URL: https://codereview.chromium.org/1736233002

Cr-Commit-Position: refs/heads/master@{#34318}
parent 7f11fba7
...@@ -1099,7 +1099,7 @@ void BytecodeGenerator::VisitForInStatement(ForInStatement* stmt) { ...@@ -1099,7 +1099,7 @@ void BytecodeGenerator::VisitForInStatement(ForInStatement* stmt) {
} }
LoopBuilder loop_builder(builder()); LoopBuilder loop_builder(builder());
BytecodeLabel subject_null_label, subject_undefined_label, not_object_label; BytecodeLabel subject_null_label, subject_undefined_label;
// Prepare the state for executing ForIn. // Prepare the state for executing ForIn.
VisitForAccumulatorValue(stmt->subject()); VisitForAccumulatorValue(stmt->subject());
...@@ -1107,7 +1107,6 @@ void BytecodeGenerator::VisitForInStatement(ForInStatement* stmt) { ...@@ -1107,7 +1107,6 @@ void BytecodeGenerator::VisitForInStatement(ForInStatement* stmt) {
builder()->JumpIfNull(&subject_null_label); builder()->JumpIfNull(&subject_null_label);
Register receiver = register_allocator()->NewRegister(); Register receiver = register_allocator()->NewRegister();
builder()->CastAccumulatorToJSObject(); builder()->CastAccumulatorToJSObject();
builder()->JumpIfNull(&not_object_label);
builder()->StoreAccumulatorInRegister(receiver); builder()->StoreAccumulatorInRegister(receiver);
register_allocator()->PrepareForConsecutiveAllocations(3); register_allocator()->PrepareForConsecutiveAllocations(3);
...@@ -1138,7 +1137,6 @@ void BytecodeGenerator::VisitForInStatement(ForInStatement* stmt) { ...@@ -1138,7 +1137,6 @@ void BytecodeGenerator::VisitForInStatement(ForInStatement* stmt) {
builder()->StoreAccumulatorInRegister(index); builder()->StoreAccumulatorInRegister(index);
loop_builder.JumpToHeader(); loop_builder.JumpToHeader();
loop_builder.EndLoop(); loop_builder.EndLoop();
builder()->Bind(&not_object_label);
builder()->Bind(&subject_null_label); builder()->Bind(&subject_null_label);
builder()->Bind(&subject_undefined_label); builder()->Bind(&subject_undefined_label);
} }
......
...@@ -65,15 +65,14 @@ snippet: " ...@@ -65,15 +65,14 @@ snippet: "
" "
frame size: 8 frame size: 8
parameter count: 1 parameter count: 1
bytecode array length: 46 bytecode array length: 44
bytecodes: [ bytecodes: [
B(StackCheck), B(StackCheck),
B(LdaConstant), U8(0), B(LdaConstant), U8(0),
B(Star), R(1), B(Star), R(1),
B(JumpIfUndefined), U8(39), B(JumpIfUndefined), U8(37),
B(JumpIfNull), U8(37), B(JumpIfNull), U8(35),
B(ToObject), B(ToObject),
B(JumpIfNull), U8(34),
B(Star), R(3), B(Star), R(3),
B(ForInPrepare), R(4), B(ForInPrepare), R(4),
B(LdaZero), B(LdaZero),
...@@ -106,16 +105,15 @@ snippet: " ...@@ -106,16 +105,15 @@ snippet: "
" "
frame size: 9 frame size: 9
parameter count: 1 parameter count: 1
bytecode array length: 58 bytecode array length: 56
bytecodes: [ bytecodes: [
B(StackCheck), B(StackCheck),
B(LdaZero), B(LdaZero),
B(Star), R(1), B(Star), R(1),
B(CreateArrayLiteral), U8(0), U8(0), U8(3), B(CreateArrayLiteral), U8(0), U8(0), U8(3),
B(JumpIfUndefined), U8(48), B(JumpIfUndefined), U8(46),
B(JumpIfNull), U8(46), B(JumpIfNull), U8(44),
B(ToObject), B(ToObject),
B(JumpIfNull), U8(43),
B(Star), R(3), B(Star), R(3),
B(ForInPrepare), R(4), B(ForInPrepare), R(4),
B(LdaZero), B(LdaZero),
...@@ -155,17 +153,16 @@ snippet: " ...@@ -155,17 +153,16 @@ snippet: "
" "
frame size: 8 frame size: 8
parameter count: 1 parameter count: 1
bytecode array length: 95 bytecode array length: 93
bytecodes: [ bytecodes: [
B(StackCheck), B(StackCheck),
B(CreateObjectLiteral), U8(0), U8(0), U8(9), B(CreateObjectLiteral), U8(0), U8(0), U8(9),
B(Star), R(1), B(Star), R(1),
B(Star), R(0), B(Star), R(0),
B(CreateArrayLiteral), U8(1), U8(1), U8(3), B(CreateArrayLiteral), U8(1), U8(1), U8(3),
B(JumpIfUndefined), U8(80), B(JumpIfUndefined), U8(78),
B(JumpIfNull), U8(78), B(JumpIfNull), U8(76),
B(ToObject), B(ToObject),
B(JumpIfNull), U8(75),
B(Star), R(1), B(Star), R(1),
B(ForInPrepare), R(2), B(ForInPrepare), R(2),
B(LdaZero), B(LdaZero),
...@@ -217,16 +214,15 @@ snippet: " ...@@ -217,16 +214,15 @@ snippet: "
" "
frame size: 9 frame size: 9
parameter count: 1 parameter count: 1
bytecode array length: 70 bytecode array length: 68
bytecodes: [ bytecodes: [
B(StackCheck), B(StackCheck),
B(CreateArrayLiteral), U8(0), U8(0), U8(3), B(CreateArrayLiteral), U8(0), U8(0), U8(3),
B(Star), R(0), B(Star), R(0),
B(CreateArrayLiteral), U8(1), U8(1), U8(3), B(CreateArrayLiteral), U8(1), U8(1), U8(3),
B(JumpIfUndefined), U8(57), B(JumpIfUndefined), U8(55),
B(JumpIfNull), U8(55), B(JumpIfNull), U8(53),
B(ToObject), B(ToObject),
B(JumpIfNull), U8(52),
B(Star), R(1), B(Star), R(1),
B(ForInPrepare), R(2), B(ForInPrepare), R(2),
B(LdaZero), B(LdaZero),
......
...@@ -1125,7 +1125,7 @@ snippet: " ...@@ -1125,7 +1125,7 @@ snippet: "
" "
frame size: 167 frame size: 167
parameter count: 1 parameter count: 1
bytecode array length: 111 bytecode array length: 109
bytecodes: [ bytecodes: [
B(StackCheck), B(StackCheck),
B(LdaConstant), U8(0), B(LdaConstant), U8(0),
...@@ -1133,10 +1133,9 @@ bytecodes: [ ...@@ -1133,10 +1133,9 @@ bytecodes: [
B(LdaZero), B(LdaZero),
B(Star), R(1), B(Star), R(1),
B(Ldar), R(0), B(Ldar), R(0),
B(JumpIfUndefined), U8(98), B(JumpIfUndefined), U8(96),
B(JumpIfNull), U8(96), B(JumpIfNull), U8(94),
B(ToObject), B(ToObject),
B(JumpIfNull), U8(93),
B(Star), R(125), B(Star), R(125),
B(MovWide), R16(125), R16(161), B(MovWide), R16(125), R16(161),
B(ForInPrepareWide), R16(162), B(ForInPrepareWide), R16(162),
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment