| OLD | NEW | 
|     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/v8.h" |     5 #include "src/v8.h" | 
|     6  |     6  | 
|     7 #include "src/compiler.h" |     7 #include "src/compiler.h" | 
|     8 #include "src/interpreter/bytecode-array-iterator.h" |     8 #include "src/interpreter/bytecode-array-iterator.h" | 
|     9 #include "src/interpreter/bytecode-generator.h" |     9 #include "src/interpreter/bytecode-generator.h" | 
|    10 #include "src/interpreter/interpreter.h" |    10 #include "src/interpreter/interpreter.h" | 
| (...skipping 4669 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  4680        {B(LdaUndefined), B(Return)}, |  4680        {B(LdaUndefined), B(Return)}, | 
|  4681        0}, |  4681        0}, | 
|  4682       {"for (var p in undefined) {}", |  4682       {"for (var p in undefined) {}", | 
|  4683        2 * kPointerSize, |  4683        2 * kPointerSize, | 
|  4684        1, |  4684        1, | 
|  4685        2, |  4685        2, | 
|  4686        {B(LdaUndefined), B(Return)}, |  4686        {B(LdaUndefined), B(Return)}, | 
|  4687        0}, |  4687        0}, | 
|  4688       {"var x = 'potatoes';\n" |  4688       {"var x = 'potatoes';\n" | 
|  4689        "for (var p in x) { return p; }", |  4689        "for (var p in x) { return p; }", | 
|  4690        5 * kPointerSize, |  4690        8 * kPointerSize, | 
|  4691        1, |  4691        1, | 
|  4692        46, |  4692        49, | 
|  4693        { |  4693        { | 
|  4694            B(LdaConstant), U8(0),                                             // |  4694            B(LdaConstant), U8(0),                                             // | 
|  4695            B(Star), R(1),                                                     // |  4695            B(Star), R(1),                                                     // | 
|  4696            B(JumpIfUndefined), U8(40),                                        // |  4696            B(JumpIfUndefined), U8(43),                                        // | 
|  4697            B(JumpIfNull), U8(38),                                             // |  4697            B(JumpIfNull), U8(41),                                             // | 
|  4698            B(ToObject),                                                       // |  4698            B(ToObject),                                                       // | 
|  4699            B(Star), R(3),                                                     // |  4699            B(Star), R(3),                                                     // | 
|  4700            B(CallRuntime), U16(Runtime::kGetPropertyNamesFast), R(3), U8(1),  // |  4700            B(CallRuntime), U16(Runtime::kGetPropertyNamesFast), R(3), U8(1),  // | 
|  4701            B(ForInPrepare), R(3),                                             // |  4701            B(ForInPrepare), R(3), R(4), R(5), R(6),                           // | 
|  4702            B(JumpIfUndefined), U8(26),                                        // |  4702            B(JumpIfUndefined), U8(26),                                        // | 
|  4703            B(Star), R(4),                                                     // |  | 
|  4704            B(LdaZero),                                                        // |  4703            B(LdaZero),                                                        // | 
|  4705            B(Star), R(3),                                                     // |  4704            B(Star), R(7),                                                     // | 
|  4706            B(ForInDone), R(4),                                                // |  4705            B(ForInDone), R(7), R(6),                                          // | 
|  4707            B(JumpIfTrue), U8(17),                                             // |  4706            B(JumpIfTrue), U8(18),                                             // | 
|  4708            B(ForInNext), R(4), R(3),                                          // |  4707            B(ForInNext), R(3), R(4), R(5), R(7),                              // | 
|  4709            B(JumpIfUndefined), U8(7),                                         // |  4708            B(JumpIfUndefined), U8(7),                                         // | 
|  4710            B(Star), R(0),                                                     // |  4709            B(Star), R(0),                                                     // | 
|  4711            B(Star), R(2),                                                     // |  4710            B(Star), R(2),                                                     // | 
|  4712            B(Return),                                                         // |  4711            B(Return),                                                         // | 
|  4713            B(Ldar), R(3),                                                     // |  4712            B(ForInStep), R(7),                                                // | 
|  4714            B(Inc),                                                            // |  | 
|  4715            B(Jump), U8(-19),                                                  // |  4713            B(Jump), U8(-19),                                                  // | 
|  4716            B(LdaUndefined),                                                   // |  4714            B(LdaUndefined),                                                   // | 
|  4717            B(Return),                                                         // |  4715            B(Return),                                                         // | 
|  4718        }, |  4716        }, | 
|  4719        1, |  4717        1, | 
|  4720        {InstanceType::ONE_BYTE_INTERNALIZED_STRING_TYPE}}, |  4718        {InstanceType::ONE_BYTE_INTERNALIZED_STRING_TYPE}}, | 
|  4721       {"var x = 0;\n" |  4719       {"var x = 0;\n" | 
|  4722        "for (var p in [1,2,3]) { x += p; }", |  4720        "for (var p in [1,2,3]) { x += p; }", | 
|  4723        5 * kPointerSize, |  4721        8 * kPointerSize, | 
|  4724        1, |  4722        1, | 
|  4725        52, |  4723        55, | 
|  4726        { |  4724        { | 
|  4727            B(LdaZero),                                                        // |  4725            B(LdaZero),                                                        // | 
|  4728            B(Star), R(1),                                                     // |  4726            B(Star), R(1),                                                     // | 
|  4729            B(CreateArrayLiteral), U8(0), U8(0), U8(simple_flags),             // |  4727            B(CreateArrayLiteral), U8(0), U8(0), U8(3),                        // | 
|  4730            B(JumpIfUndefined), U8(43),                                        // |  4728            B(JumpIfUndefined), U8(46),                                        // | 
|  4731            B(JumpIfNull), U8(41),                                             // |  4729            B(JumpIfNull), U8(44),                                             // | 
|  4732            B(ToObject),                                                       // |  4730            B(ToObject),                                                       // | 
|  4733            B(Star), R(3),                                                     // |  4731            B(Star), R(3),                                                     // | 
|  4734            B(CallRuntime), U16(Runtime::kGetPropertyNamesFast), R(3), U8(1),  // |  4732            B(CallRuntime), U16(Runtime::kGetPropertyNamesFast), R(3), U8(1),  // | 
|  4735            B(ForInPrepare), R(3),                                             // |  4733            B(ForInPrepare), R(3), R(4), R(5), R(6),                           // | 
|  4736            B(JumpIfUndefined), U8(29),                                        // |  4734            B(JumpIfUndefined), U8(29),                                        // | 
|  4737            B(Star), R(4),                                                     // |  | 
|  4738            B(LdaZero),                                                        // |  4735            B(LdaZero),                                                        // | 
|  4739            B(Star), R(3),                                                     // |  4736            B(Star), R(7),                                                     // | 
|  4740            B(ForInDone), R(4),                                                // |  4737            B(ForInDone), R(7), R(6),                                          // | 
|  4741            B(JumpIfTrue), U8(20),                                             // |  4738            B(JumpIfTrue), U8(21),                                             // | 
|  4742            B(ForInNext), R(4), R(3),                                          // |  4739            B(ForInNext), R(3), R(4), R(5), R(7),                              // | 
|  4743            B(JumpIfUndefined), U8(10),                                        // |  4740            B(JumpIfUndefined), U8(10),                                        // | 
|  4744            B(Star), R(0),                                                     // |  4741            B(Star), R(0),                                                     // | 
|  4745            B(Star), R(2),                                                     // |  4742            B(Star), R(2),                                                     // | 
|  4746            B(Add), R(1),                                                      // |  4743            B(Add), R(1),                                                      // | 
|  4747            B(Star), R(1),                                                     // |  4744            B(Star), R(1),                                                     // | 
|  4748            B(Ldar), R(3),                                                     // |  4745            B(ForInStep), R(7),                                                // | 
|  4749            B(Inc),                                                            // |  | 
|  4750            B(Jump), U8(-22),                                                  // |  4746            B(Jump), U8(-22),                                                  // | 
|  4751            B(LdaUndefined),                                                   // |  4747            B(LdaUndefined),                                                   // | 
|  4752            B(Return),                                                         // |  4748            B(Return),                                                         // | 
|  4753        }, |  4749        }, | 
|  4754        1, |  4750        1, | 
|  4755        {InstanceType::FIXED_ARRAY_TYPE}}, |  4751        {InstanceType::FIXED_ARRAY_TYPE}}, | 
|  4756       {"var x = { 'a': 1, 'b': 2 };\n" |  4752       {"var x = { 'a': 1, 'b': 2 };\n" | 
|  4757        "for (x['a'] in [10, 20, 30]) {\n" |  4753        "for (x['a'] in [10, 20, 30]) {\n" | 
|  4758        "  if (x['a'] == 10) continue;\n" |  4754        "  if (x['a'] == 10) continue;\n" | 
|  4759        "  if (x['a'] == 20) break;\n" |  4755        "  if (x['a'] == 20) break;\n" | 
|  4760        "}", |  4756        "}", | 
|  4761        4 * kPointerSize, |  4757        7 * kPointerSize, | 
|  4762        1, |  4758        1, | 
|  4763        81, |  4759        84, | 
|  4764        { |  4760        { | 
|  4765            B(CreateObjectLiteral), U8(0), U8(0), U8(deep_elements_flags),     // |  4761            B(CreateObjectLiteral), U8(0), U8(0), U8(deep_elements_flags),     // | 
|  4766            B(Star), R(0),                                                     // |  4762            B(Star), R(0),                                                     // | 
|  4767            B(CreateArrayLiteral), U8(1), U8(1), U8(simple_flags),             // |  4763            B(CreateArrayLiteral), U8(1), U8(1), U8(simple_flags),             // | 
|  4768            B(JumpIfUndefined), U8(69),                                        // |  4764            B(JumpIfUndefined), U8(72),                                        // | 
|  4769            B(JumpIfNull), U8(67),                                             // |  4765            B(JumpIfNull), U8(70),                                             // | 
|  4770            B(ToObject),                                                       // |  4766            B(ToObject),                                                       // | 
|  4771            B(Star), R(1),                                                     // |  4767            B(Star), R(1),                                                     // | 
|  4772            B(CallRuntime), U16(Runtime::kGetPropertyNamesFast), R(1), U8(1),  // |  4768            B(CallRuntime), U16(Runtime::kGetPropertyNamesFast), R(1), U8(1),  // | 
|  4773            B(ForInPrepare), R(1),                                             // |  4769            B(ForInPrepare), R(1), R(2), R(3), R(4),                           // | 
|  4774            B(JumpIfUndefined), U8(55),                                        // |  4770            B(JumpIfUndefined), U8(55),                                        // | 
|  4775            B(Star), R(2),                                                     // |  | 
|  4776            B(LdaZero),                                                        // |  4771            B(LdaZero),                                                        // | 
|  4777            B(Star), R(1),                                                     // |  4772            B(Star), R(5),                                                     // | 
|  4778            B(ForInDone), R(2),                                                // |  4773            B(ForInDone), R(5), R(4),                                          // | 
|  4779            B(JumpIfTrue), U8(46),                                             // |  4774            B(JumpIfTrue), U8(47),                                             // | 
|  4780            B(ForInNext), R(2), R(1),                                          // |  4775            B(ForInNext), R(1), R(2), R(3), R(5),                              // | 
|  4781            B(JumpIfUndefined), U8(36),                                        // |  4776            B(JumpIfUndefined), U8(36),                                        // | 
|  4782            B(Star), R(3),                                                     // |  4777            B(Star), R(6),                                                     // | 
|  4783            B(StoreICSloppy), R(0), U8(2), U8(vector->GetIndex(slot4)),        // |  4778            B(StoreICSloppy), R(0), U8(2), U8(vector->GetIndex(slot4)),        // | 
|  4784            B(LoadICSloppy), R(0), U8(2), U8(vector->GetIndex(slot2)),         // |  4779            B(LoadICSloppy), R(0), U8(2), U8(vector->GetIndex(slot2)),         // | 
|  4785            B(Star), R(3),                                                     // |  4780            B(Star), R(6),                                                     // | 
|  4786            B(LdaSmi8), U8(10),                                                // |  4781            B(LdaSmi8), U8(10),                                                // | 
|  4787            B(TestEqual), R(3),                                                // |  4782            B(TestEqual), R(6),                                                // | 
|  4788            B(JumpIfFalse), U8(4),                                             // |  4783            B(JumpIfFalse), U8(4),                                             // | 
|  4789            B(Jump), U8(16),                                                   // |  4784            B(Jump), U8(16),                                                   // | 
|  4790            B(LoadICSloppy), R(0), U8(2), U8(vector->GetIndex(slot3)),         // |  4785            B(LoadICSloppy), R(0), U8(2), U8(vector->GetIndex(slot3)),         // | 
|  4791            B(Star), R(3),                                                     // |  4786            B(Star), R(6),                                                     // | 
|  4792            B(LdaSmi8), U8(20),                                                // |  4787            B(LdaSmi8), U8(20),                                                // | 
|  4793            B(TestEqual), R(3),                                                // |  4788            B(TestEqual), R(6),                                                // | 
|  4794            B(JumpIfFalse), U8(4),                                             // |  4789            B(JumpIfFalse), U8(4),                                             // | 
|  4795            B(Jump), U8(7),                                                    // |  4790            B(Jump), U8(6),                                                    // | 
|  4796            B(Ldar), R(1),                                                     // |  4791            B(ForInStep), R(5),                                                // | 
|  4797            B(Inc),                                                            // |  | 
|  4798            B(Jump), U8(-48),                                                  // |  4792            B(Jump), U8(-48),                                                  // | 
|  4799            B(LdaUndefined),                                                   // |  4793            B(LdaUndefined),                                                   // | 
|  4800            B(Return),                                                         // |  4794            B(Return),                                                         // | 
|  4801        }, |  4795        }, | 
|  4802        3, |  4796        3, | 
|  4803        {InstanceType::FIXED_ARRAY_TYPE, InstanceType::FIXED_ARRAY_TYPE, |  4797        {InstanceType::FIXED_ARRAY_TYPE, InstanceType::FIXED_ARRAY_TYPE, | 
|  4804         InstanceType::ONE_BYTE_INTERNALIZED_STRING_TYPE}}, |  4798         InstanceType::ONE_BYTE_INTERNALIZED_STRING_TYPE}}, | 
|  4805       {"var x = [ 10, 11, 12 ] ;\n" |  4799       {"var x = [ 10, 11, 12 ] ;\n" | 
|  4806        "for (x[0] in [1,2,3]) { return x[3]; }", |  4800        "for (x[0] in [1,2,3]) { return x[3]; }", | 
|  4807        5 * kPointerSize, |  4801        8 * kPointerSize, | 
|  4808        1, |  4802        1, | 
|  4809        64, |  4803        67, | 
|  4810        { |  4804        { | 
|  4811            B(CreateArrayLiteral), U8(0), U8(0), U8(simple_flags),             // |  4805            B(CreateArrayLiteral), U8(0), U8(0), U8(simple_flags),             // | 
|  4812            B(Star), R(0),                                                     // |  4806            B(Star), R(0),                                                     // | 
|  4813            B(CreateArrayLiteral), U8(1), U8(1), U8(simple_flags),             // |  4807            B(CreateArrayLiteral), U8(1), U8(1), U8(simple_flags),             // | 
|  4814            B(JumpIfUndefined), U8(52),                                        // |  4808            B(JumpIfUndefined), U8(55),                                        // | 
|  4815            B(JumpIfNull), U8(50),                                             // |  4809            B(JumpIfNull), U8(53),                                             // | 
|  4816            B(ToObject),                                                       // |  4810            B(ToObject),                                                       // | 
|  4817            B(Star), R(1),                                                     // |  4811            B(Star), R(1),                                                     // | 
|  4818            B(CallRuntime), U16(Runtime::kGetPropertyNamesFast), R(1), U8(1),  // |  4812            B(CallRuntime), U16(Runtime::kGetPropertyNamesFast), R(1), U8(1),  // | 
|  4819            B(ForInPrepare), R(1),                                             // |  4813            B(ForInPrepare), R(1), R(2), R(3), R(4),                           // | 
|  4820            B(JumpIfUndefined), U8(38),                                        // |  4814            B(JumpIfUndefined), U8(38),                                        // | 
|  4821            B(Star), R(2),                                                     // |  | 
|  4822            B(LdaZero),                                                        // |  4815            B(LdaZero),                                                        // | 
|  4823            B(Star), R(1),                                                     // |  4816            B(Star), R(5),                                                     // | 
|  4824            B(ForInDone), R(2),                                                // |  4817            B(ForInDone), R(5), R(4),                                          // | 
|  4825            B(JumpIfTrue), U8(29),                                             // |  4818            B(JumpIfTrue), U8(30),                                             // | 
|  4826            B(ForInNext), R(2), R(1),                                          // |  4819            B(ForInNext), R(1), R(2), R(3), R(5),                              // | 
|  4827            B(JumpIfUndefined), U8(19),                                        // |  4820            B(JumpIfUndefined), U8(19),                                        // | 
|  4828            B(Star), R(3),                                                     // |  4821            B(Star), R(6),                                                     // | 
|  4829            B(LdaZero),                                                        // |  4822            B(LdaZero),                                                        // | 
|  4830            B(Star), R(4),                                                     // |  4823            B(Star), R(7),                                                     // | 
|  4831            B(Ldar), R(3),                                                     // |  4824            B(Ldar), R(6),                                                     // | 
|  4832            B(KeyedStoreICSloppy), R(0), R(4), U8(vector->GetIndex(slot3)),    // |  4825            B(KeyedStoreICSloppy), R(0), R(7), U8(vector->GetIndex(slot3)),    // | 
|  4833            B(LdaSmi8), U8(3),                                                 // |  4826            B(LdaSmi8), U8(3),                                                 // | 
|  4834            B(KeyedLoadICSloppy), R(0), U8(vector->GetIndex(slot2)),           // |  4827            B(KeyedLoadICSloppy), R(0), U8(vector->GetIndex(slot2)),           // | 
|  4835            B(Return),                                                         // |  4828            B(Return),                                                         // | 
|  4836            B(Ldar), R(1),                                                     // |  4829            B(ForInStep), R(5),                                                // | 
|  4837            B(Inc),                                                            // |  | 
|  4838            B(Jump), U8(-31),                                                  // |  4830            B(Jump), U8(-31),                                                  // | 
|  4839            B(LdaUndefined),                                                   // |  4831            B(LdaUndefined),                                                   // | 
|  4840            B(Return),                                                         // |  4832            B(Return),                                                         // | 
|  4841        }, |  4833        }, | 
|  4842        2, |  4834        2, | 
|  4843        {InstanceType::FIXED_ARRAY_TYPE, InstanceType::FIXED_ARRAY_TYPE}}, |  4835        {InstanceType::FIXED_ARRAY_TYPE, InstanceType::FIXED_ARRAY_TYPE}}, | 
|  4844   }; |  4836   }; | 
|  4845  |  4837  | 
|  4846   for (size_t i = 0; i < arraysize(snippets); i++) { |  4838   for (size_t i = 0; i < arraysize(snippets); i++) { | 
|  4847     Handle<BytecodeArray> bytecode_array = |  4839     Handle<BytecodeArray> bytecode_array = | 
| (...skipping 782 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  5630   for (size_t i = 0; i < arraysize(snippets); i++) { |  5622   for (size_t i = 0; i < arraysize(snippets); i++) { | 
|  5631     Handle<BytecodeArray> bytecode_array = |  5623     Handle<BytecodeArray> bytecode_array = | 
|  5632         helper.MakeBytecodeForFunctionBody(snippets[i].code_snippet); |  5624         helper.MakeBytecodeForFunctionBody(snippets[i].code_snippet); | 
|  5633     CheckBytecodeArrayEqual(snippets[i], bytecode_array); |  5625     CheckBytecodeArrayEqual(snippets[i], bytecode_array); | 
|  5634   } |  5626   } | 
|  5635 } |  5627 } | 
|  5636  |  5628  | 
|  5637 }  // namespace interpreter |  5629 }  // namespace interpreter | 
|  5638 }  // namespace internal |  5630 }  // namespace internal | 
|  5639 }  // namespace v8 |  5631 }  // namespace v8 | 
| OLD | NEW |