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 5231 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5242 {"for (var p in undefined) {}", | 5242 {"for (var p in undefined) {}", |
5243 2 * kPointerSize, | 5243 2 * kPointerSize, |
5244 1, | 5244 1, |
5245 2, | 5245 2, |
5246 {B(LdaUndefined), B(Return)}, | 5246 {B(LdaUndefined), B(Return)}, |
5247 0}, | 5247 0}, |
5248 {"var x = 'potatoes';\n" | 5248 {"var x = 'potatoes';\n" |
5249 "for (var p in x) { return p; }", | 5249 "for (var p in x) { return p; }", |
5250 8 * kPointerSize, | 5250 8 * kPointerSize, |
5251 1, | 5251 1, |
5252 45, | 5252 42, |
5253 { | 5253 { |
5254 B(LdaConstant), U8(0), // | 5254 B(LdaConstant), U8(0), // |
5255 B(Star), R(1), // | 5255 B(Star), R(1), // |
5256 B(JumpIfUndefined), U8(39), // | 5256 B(JumpIfUndefined), U8(36), // |
5257 B(JumpIfNull), U8(37), // | 5257 B(JumpIfNull), U8(34), // |
5258 B(ToObject), // | 5258 B(ToObject), // |
5259 B(JumpIfNull), U8(34), // | 5259 B(JumpIfNull), U8(31), // |
5260 B(Star), R(3), // | 5260 B(Star), R(3), // |
5261 B(ForInPrepare), R(4), R(5), R(6), // | 5261 B(ForInPrepare), R(4), // |
5262 B(LdaZero), // | 5262 B(LdaZero), // |
5263 B(Star), R(7), // | 5263 B(Star), R(7), // |
5264 B(ForInDone), R(7), R(6), // | 5264 B(ForInDone), R(7), R(6), // |
5265 B(JumpIfTrue), U8(20), // | 5265 B(JumpIfTrue), U8(19), // |
5266 B(ForInNext), R(3), R(4), R(5), R(7), // | 5266 B(ForInNext), R(3), R(7), R(4), // |
5267 B(JumpIfUndefined), U8(7), // | 5267 B(JumpIfUndefined), U8(7), // |
5268 B(Star), R(0), // | 5268 B(Star), R(0), // |
5269 B(Star), R(2), // | 5269 B(Star), R(2), // |
5270 B(Return), // | 5270 B(Return), // |
5271 B(ForInStep), R(7), // | 5271 B(ForInStep), R(7), // |
5272 B(Star), R(7), // | 5272 B(Star), R(7), // |
5273 B(Jump), U8(-21), // | 5273 B(Jump), U8(-20), // |
5274 B(LdaUndefined), // | 5274 B(LdaUndefined), // |
5275 B(Return), // | 5275 B(Return), // |
5276 }, | 5276 }, |
5277 1, | 5277 1, |
5278 {InstanceType::ONE_BYTE_INTERNALIZED_STRING_TYPE}}, | 5278 {InstanceType::ONE_BYTE_INTERNALIZED_STRING_TYPE}}, |
5279 {"var x = 0;\n" | 5279 {"var x = 0;\n" |
5280 "for (var p in [1,2,3]) { x += p; }", | 5280 "for (var p in [1,2,3]) { x += p; }", |
5281 9 * kPointerSize, | 5281 9 * kPointerSize, |
5282 1, | 5282 1, |
5283 57, | 5283 54, |
5284 { | 5284 { |
5285 B(LdaZero), // | 5285 B(LdaZero), // |
5286 B(Star), R(1), // | 5286 B(Star), R(1), // |
5287 B(CreateArrayLiteral), U8(0), U8(0), U8(3), // | 5287 B(CreateArrayLiteral), U8(0), U8(0), U8(3), // |
5288 B(JumpIfUndefined), U8(48), // | 5288 B(JumpIfUndefined), U8(45), // |
5289 B(JumpIfNull), U8(46), // | 5289 B(JumpIfNull), U8(43), // |
5290 B(ToObject), // | 5290 B(ToObject), // |
5291 B(JumpIfNull), U8(43), // | 5291 B(JumpIfNull), U8(40), // |
5292 B(Star), R(3), // | 5292 B(Star), R(3), // |
5293 B(ForInPrepare), R(4), R(5), R(6), // | 5293 B(ForInPrepare), R(4), // |
5294 B(LdaZero), // | 5294 B(LdaZero), // |
5295 B(Star), R(7), // | 5295 B(Star), R(7), // |
5296 B(ForInDone), R(7), R(6), // | 5296 B(ForInDone), R(7), R(6), // |
5297 B(JumpIfTrue), U8(29), // | 5297 B(JumpIfTrue), U8(28), // |
5298 B(ForInNext), R(3), R(4), R(5), R(7), // | 5298 B(ForInNext), R(3), R(7), R(4), // |
5299 B(JumpIfUndefined), U8(16), // | 5299 B(JumpIfUndefined), U8(16), // |
5300 B(Star), R(0), // | 5300 B(Star), R(0), // |
5301 B(Star), R(2), // | 5301 B(Star), R(2), // |
5302 B(Ldar), R(1), // | 5302 B(Ldar), R(1), // |
5303 B(Star), R(8), // | 5303 B(Star), R(8), // |
5304 B(Ldar), R(2), // | 5304 B(Ldar), R(2), // |
5305 B(Add), R(8), // | 5305 B(Add), R(8), // |
5306 B(Star), R(1), // | 5306 B(Star), R(1), // |
5307 B(ForInStep), R(7), // | 5307 B(ForInStep), R(7), // |
5308 B(Star), R(7), // | 5308 B(Star), R(7), // |
5309 B(Jump), U8(-30), // | 5309 B(Jump), U8(-29), // |
5310 B(LdaUndefined), // | 5310 B(LdaUndefined), // |
5311 B(Return), // | 5311 B(Return), // |
5312 }, | 5312 }, |
5313 1, | 5313 1, |
5314 {InstanceType::FIXED_ARRAY_TYPE}}, | 5314 {InstanceType::FIXED_ARRAY_TYPE}}, |
5315 {"var x = { 'a': 1, 'b': 2 };\n" | 5315 {"var x = { 'a': 1, 'b': 2 };\n" |
5316 "for (x['a'] in [10, 20, 30]) {\n" | 5316 "for (x['a'] in [10, 20, 30]) {\n" |
5317 " if (x['a'] == 10) continue;\n" | 5317 " if (x['a'] == 10) continue;\n" |
5318 " if (x['a'] == 20) break;\n" | 5318 " if (x['a'] == 20) break;\n" |
5319 "}", | 5319 "}", |
5320 8 * kPointerSize, | 5320 8 * kPointerSize, |
5321 1, | 5321 1, |
5322 94, | 5322 91, |
5323 { | 5323 { |
5324 B(CreateObjectLiteral), U8(0), U8(0), U8(deep_elements_flags), // | 5324 B(CreateObjectLiteral), U8(0), U8(0), U8(deep_elements_flags), // |
5325 B(Star), R(0), // | 5325 B(Star), R(0), // |
5326 B(CreateArrayLiteral), U8(1), U8(1), U8(simple_flags), // | 5326 B(CreateArrayLiteral), U8(1), U8(1), U8(simple_flags), // |
5327 B(JumpIfUndefined), U8(82), // | 5327 B(JumpIfUndefined), U8(79), // |
5328 B(JumpIfNull), U8(80), // | 5328 B(JumpIfNull), U8(77), // |
5329 B(ToObject), // | 5329 B(ToObject), // |
5330 B(JumpIfNull), U8(77), // | 5330 B(JumpIfNull), U8(74), // |
5331 B(Star), R(1), // | 5331 B(Star), R(1), // |
5332 B(ForInPrepare), R(2), R(3), R(4), // | 5332 B(ForInPrepare), R(2), // |
5333 B(LdaZero), // | 5333 B(LdaZero), // |
5334 B(Star), R(5), // | 5334 B(Star), R(5), // |
5335 B(ForInDone), R(5), R(4), // | 5335 B(ForInDone), R(5), R(4), // |
5336 B(JumpIfTrue), U8(63), // | 5336 B(JumpIfTrue), U8(62), // |
5337 B(ForInNext), R(1), R(2), R(3), R(5), // | 5337 B(ForInNext), R(1), R(5), R(2), // |
5338 B(JumpIfUndefined), U8(50), // | 5338 B(JumpIfUndefined), U8(50), // |
5339 B(Star), R(6), // | 5339 B(Star), R(6), // |
5340 B(Ldar), R(0), // | 5340 B(Ldar), R(0), // |
5341 B(Star), R(7), // | 5341 B(Star), R(7), // |
5342 B(Ldar), R(6), // | 5342 B(Ldar), R(6), // |
5343 B(StoreICSloppy), R(7), U8(2), U8(vector->GetIndex(slot4)), // | 5343 B(StoreICSloppy), R(7), U8(2), U8(vector->GetIndex(slot4)), // |
5344 B(Ldar), R(0), // | 5344 B(Ldar), R(0), // |
5345 B(Star), R(6), // | 5345 B(Star), R(6), // |
5346 B(LoadICSloppy), R(6), U8(2), U8(vector->GetIndex(slot2)), // | 5346 B(LoadICSloppy), R(6), U8(2), U8(vector->GetIndex(slot2)), // |
5347 B(Star), R(7), // | 5347 B(Star), R(7), // |
5348 B(LdaSmi8), U8(10), // | 5348 B(LdaSmi8), U8(10), // |
5349 B(TestEqual), R(7), // | 5349 B(TestEqual), R(7), // |
5350 B(JumpIfFalse), U8(4), // | 5350 B(JumpIfFalse), U8(4), // |
5351 B(Jump), U8(20), // | 5351 B(Jump), U8(20), // |
5352 B(Ldar), R(0), // | 5352 B(Ldar), R(0), // |
5353 B(Star), R(6), // | 5353 B(Star), R(6), // |
5354 B(LoadICSloppy), R(6), U8(2), U8(vector->GetIndex(slot3)), // | 5354 B(LoadICSloppy), R(6), U8(2), U8(vector->GetIndex(slot3)), // |
5355 B(Star), R(7), // | 5355 B(Star), R(7), // |
5356 B(LdaSmi8), U8(20), // | 5356 B(LdaSmi8), U8(20), // |
5357 B(TestEqual), R(7), // | 5357 B(TestEqual), R(7), // |
5358 B(JumpIfFalse), U8(4), // | 5358 B(JumpIfFalse), U8(4), // |
5359 B(Jump), U8(8), // | 5359 B(Jump), U8(8), // |
5360 B(ForInStep), R(5), // | 5360 B(ForInStep), R(5), // |
5361 B(Star), R(5), // | 5361 B(Star), R(5), // |
5362 B(Jump), U8(-64), // | 5362 B(Jump), U8(-63), // |
5363 B(LdaUndefined), // | 5363 B(LdaUndefined), // |
5364 B(Return), // | 5364 B(Return), // |
5365 }, | 5365 }, |
5366 3, | 5366 3, |
5367 {InstanceType::FIXED_ARRAY_TYPE, InstanceType::FIXED_ARRAY_TYPE, | 5367 {InstanceType::FIXED_ARRAY_TYPE, InstanceType::FIXED_ARRAY_TYPE, |
5368 InstanceType::ONE_BYTE_INTERNALIZED_STRING_TYPE}}, | 5368 InstanceType::ONE_BYTE_INTERNALIZED_STRING_TYPE}}, |
5369 {"var x = [ 10, 11, 12 ] ;\n" | 5369 {"var x = [ 10, 11, 12 ] ;\n" |
5370 "for (x[0] in [1,2,3]) { return x[3]; }", | 5370 "for (x[0] in [1,2,3]) { return x[3]; }", |
5371 9 * kPointerSize, | 5371 9 * kPointerSize, |
5372 1, | 5372 1, |
5373 71, | 5373 68, |
5374 { | 5374 { |
5375 B(CreateArrayLiteral), U8(0), U8(0), U8(simple_flags), // | 5375 B(CreateArrayLiteral), U8(0), U8(0), U8(simple_flags), // |
5376 B(Star), R(0), // | 5376 B(Star), R(0), // |
5377 B(CreateArrayLiteral), U8(1), U8(1), U8(simple_flags), // | 5377 B(CreateArrayLiteral), U8(1), U8(1), U8(simple_flags), // |
5378 B(JumpIfUndefined), U8(59), // | 5378 B(JumpIfUndefined), U8(56), // |
5379 B(JumpIfNull), U8(57), // | 5379 B(JumpIfNull), U8(54), // |
5380 B(ToObject), // | 5380 B(ToObject), // |
5381 B(JumpIfNull), U8(54), // | 5381 B(JumpIfNull), U8(51), // |
5382 B(Star), R(1), // | 5382 B(Star), R(1), // |
5383 B(ForInPrepare), R(2), R(3), R(4), // | 5383 B(ForInPrepare), R(2), // |
5384 B(LdaZero), // | 5384 B(LdaZero), // |
5385 B(Star), R(5), // | 5385 B(Star), R(5), // |
5386 B(ForInDone), R(5), R(4), // | 5386 B(ForInDone), R(5), R(4), // |
5387 B(JumpIfTrue), U8(40), // | 5387 B(JumpIfTrue), U8(39), // |
5388 B(ForInNext), R(1), R(2), R(3), R(5), // | 5388 B(ForInNext), R(1), R(5), R(2), // |
5389 B(JumpIfUndefined), U8(27), // | 5389 B(JumpIfUndefined), U8(27), // |
5390 B(Star), R(6), // | 5390 B(Star), R(6), // |
5391 B(Ldar), R(0), // | 5391 B(Ldar), R(0), // |
5392 B(Star), R(7), // | 5392 B(Star), R(7), // |
5393 B(LdaZero), // | 5393 B(LdaZero), // |
5394 B(Star), R(8), // | 5394 B(Star), R(8), // |
5395 B(Ldar), R(6), // | 5395 B(Ldar), R(6), // |
5396 B(KeyedStoreICSloppy), R(7), R(8), U8(vector->GetIndex(slot3)), // | 5396 B(KeyedStoreICSloppy), R(7), R(8), U8(vector->GetIndex(slot3)), // |
5397 B(Ldar), R(0), // | 5397 B(Ldar), R(0), // |
5398 B(Star), R(6), // | 5398 B(Star), R(6), // |
5399 B(LdaSmi8), U8(3), // | 5399 B(LdaSmi8), U8(3), // |
5400 B(KeyedLoadICSloppy), R(6), U8(vector->GetIndex(slot2)), // | 5400 B(KeyedLoadICSloppy), R(6), U8(vector->GetIndex(slot2)), // |
5401 B(Return), // | 5401 B(Return), // |
5402 B(ForInStep), R(5), // | 5402 B(ForInStep), R(5), // |
5403 B(Star), R(5), // | 5403 B(Star), R(5), // |
5404 B(Jump), U8(-41), // | 5404 B(Jump), U8(-40), // |
5405 B(LdaUndefined), // | 5405 B(LdaUndefined), // |
5406 B(Return), // | 5406 B(Return), // |
5407 }, | 5407 }, |
5408 2, | 5408 2, |
5409 {InstanceType::FIXED_ARRAY_TYPE, InstanceType::FIXED_ARRAY_TYPE}}, | 5409 {InstanceType::FIXED_ARRAY_TYPE, InstanceType::FIXED_ARRAY_TYPE}}, |
5410 }; | 5410 }; |
5411 | 5411 |
5412 for (size_t i = 0; i < arraysize(snippets); i++) { | 5412 for (size_t i = 0; i < arraysize(snippets); i++) { |
5413 Handle<BytecodeArray> bytecode_array = | 5413 Handle<BytecodeArray> bytecode_array = |
5414 helper.MakeBytecodeForFunctionBody(snippets[i].code_snippet); | 5414 helper.MakeBytecodeForFunctionBody(snippets[i].code_snippet); |
(...skipping 1303 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6718 std::string(function_epilogue); | 6718 std::string(function_epilogue); |
6719 Handle<BytecodeArray> bytecode_array = | 6719 Handle<BytecodeArray> bytecode_array = |
6720 helper.MakeBytecode(script.c_str(), "t", "f"); | 6720 helper.MakeBytecode(script.c_str(), "t", "f"); |
6721 CheckBytecodeArrayEqual(snippets[i], bytecode_array); | 6721 CheckBytecodeArrayEqual(snippets[i], bytecode_array); |
6722 } | 6722 } |
6723 } | 6723 } |
6724 | 6724 |
6725 } // namespace interpreter | 6725 } // namespace interpreter |
6726 } // namespace internal | 6726 } // namespace internal |
6727 } // namespace v8 | 6727 } // namespace v8 |
OLD | NEW |