| 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 // TODO(rmcilroy): Remove this define after this flag is turned on globally | 5 // TODO(rmcilroy): Remove this define after this flag is turned on globally |
| 6 #define V8_IMMINENT_DEPRECATION_WARNINGS | 6 #define V8_IMMINENT_DEPRECATION_WARNINGS |
| 7 | 7 |
| 8 #include "src/v8.h" | 8 #include "src/v8.h" |
| 9 | 9 |
| 10 #include "src/compiler.h" | 10 #include "src/compiler.h" |
| (...skipping 241 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 252 helper.MakeBytecodeForFunctionBody(snippets[i].code_snippet); | 252 helper.MakeBytecodeForFunctionBody(snippets[i].code_snippet); |
| 253 CheckBytecodeArrayEqual(snippets[i], bytecode_array); | 253 CheckBytecodeArrayEqual(snippets[i], bytecode_array); |
| 254 } | 254 } |
| 255 } | 255 } |
| 256 | 256 |
| 257 | 257 |
| 258 TEST(PrimitiveExpressions) { | 258 TEST(PrimitiveExpressions) { |
| 259 InitializedHandleScope handle_scope; | 259 InitializedHandleScope handle_scope; |
| 260 BytecodeGeneratorHelper helper; | 260 BytecodeGeneratorHelper helper; |
| 261 | 261 |
| 262 ExpectedSnippet<int> snippets[] = { | 262 ExpectedSnippet<int> snippets[] = {{"var x = 0; return x;", |
| 263 {"var x = 0; return x;", | 263 kPointerSize, |
| 264 kPointerSize, | 264 1, |
| 265 1, | 265 4, |
| 266 4, | 266 {B(LdaZero), // |
| 267 {B(LdaZero), // | 267 B(Star), R(0), // |
| 268 B(Star), R(0), // | 268 B(Return)}, |
| 269 B(Return)}, | 269 0}, |
| 270 0}, | 270 {"var x = 0; return x + 3;", |
| 271 {"var x = 0; return x + 3;", | 271 kPointerSize, |
| 272 kPointerSize, | 272 1, |
| 273 1, | 273 8, |
| 274 8, | 274 {B(LdaZero), // |
| 275 {B(LdaZero), // | 275 B(Star), R(0), // |
| 276 B(Star), R(0), // | 276 B(LdaSmi8), U8(3), // |
| 277 B(LdaSmi8), U8(3), // | 277 B(Add), R(0), // |
| 278 B(Add), R(0), // | 278 B(Return)}, |
| 279 B(Return)}, | 279 0}, |
| 280 0}, | 280 {"var x = 0; return x - 3;", |
| 281 {"var x = 0; return x - 3;", | 281 kPointerSize, |
| 282 kPointerSize, | 282 1, |
| 283 1, | 283 8, |
| 284 8, | 284 {B(LdaZero), // |
| 285 {B(LdaZero), // | 285 B(Star), R(0), // |
| 286 B(Star), R(0), // | 286 B(LdaSmi8), U8(3), // |
| 287 B(LdaSmi8), U8(3), // | 287 B(Sub), R(0), // |
| 288 B(Sub), R(0), // | 288 B(Return)}, |
| 289 B(Return)}, | 289 0}, |
| 290 0}, | 290 {"var x = 4; return x * 3;", |
| 291 {"var x = 4; return x * 3;", | 291 kPointerSize, |
| 292 kPointerSize, | 292 1, |
| 293 1, | 293 9, |
| 294 9, | 294 {B(LdaSmi8), U8(4), // |
| 295 {B(LdaSmi8), U8(4), // | 295 B(Star), R(0), // |
| 296 B(Star), R(0), // | 296 B(LdaSmi8), U8(3), // |
| 297 B(LdaSmi8), U8(3), // | 297 B(Mul), R(0), // |
| 298 B(Mul), R(0), // | 298 B(Return)}, |
| 299 B(Return)}, | 299 0}, |
| 300 0}, | 300 {"var x = 4; return x / 3;", |
| 301 {"var x = 4; return x / 3;", | 301 kPointerSize, |
| 302 kPointerSize, | 302 1, |
| 303 1, | 303 9, |
| 304 9, | 304 {B(LdaSmi8), U8(4), // |
| 305 {B(LdaSmi8), U8(4), // | 305 B(Star), R(0), // |
| 306 B(Star), R(0), // | 306 B(LdaSmi8), U8(3), // |
| 307 B(LdaSmi8), U8(3), // | 307 B(Div), R(0), // |
| 308 B(Div), R(0), // | 308 B(Return)}, |
| 309 B(Return)}, | 309 0}, |
| 310 0}, | 310 {"var x = 4; return x % 3;", |
| 311 {"var x = 4; return x % 3;", | 311 kPointerSize, |
| 312 kPointerSize, | 312 1, |
| 313 1, | 313 9, |
| 314 9, | 314 {B(LdaSmi8), U8(4), // |
| 315 {B(LdaSmi8), U8(4), // | 315 B(Star), R(0), // |
| 316 B(Star), R(0), // | 316 B(LdaSmi8), U8(3), // |
| 317 B(LdaSmi8), U8(3), // | 317 B(Mod), R(0), // |
| 318 B(Mod), R(0), // | 318 B(Return)}, |
| 319 B(Return)}, | 319 0}, |
| 320 0}, | 320 {"var x = 1; return x | 2;", |
| 321 {"var x = 1; return x | 2;", | 321 kPointerSize, |
| 322 kPointerSize, | 322 1, |
| 323 1, | 323 9, |
| 324 9, | 324 {B(LdaSmi8), U8(1), // |
| 325 {B(LdaSmi8), U8(1), // | 325 B(Star), R(0), // |
| 326 B(Star), R(0), // | 326 B(LdaSmi8), U8(2), // |
| 327 B(LdaSmi8), U8(2), // | 327 B(BitwiseOr), R(0), // |
| 328 B(BitwiseOr), R(0), // | 328 B(Return)}, |
| 329 B(Return)}, | 329 0}, |
| 330 0}, | 330 {"var x = 1; return x ^ 2;", |
| 331 {"var x = 1; return x ^ 2;", | 331 kPointerSize, |
| 332 kPointerSize, | 332 1, |
| 333 1, | 333 9, |
| 334 9, | 334 {B(LdaSmi8), U8(1), // |
| 335 {B(LdaSmi8), U8(1), // | 335 B(Star), R(0), // |
| 336 B(Star), R(0), // | 336 B(LdaSmi8), U8(2), // |
| 337 B(LdaSmi8), U8(2), // | 337 B(BitwiseXor), R(0), // |
| 338 B(BitwiseXor), R(0), // | 338 B(Return)}, |
| 339 B(Return)}, | 339 0}, |
| 340 0}, | 340 {"var x = 1; return x & 2;", |
| 341 {"var x = 1; return x & 2;", | 341 kPointerSize, |
| 342 kPointerSize, | 342 1, |
| 343 1, | 343 9, |
| 344 9, | 344 {B(LdaSmi8), U8(1), // |
| 345 {B(LdaSmi8), U8(1), // | 345 B(Star), R(0), // |
| 346 B(Star), R(0), // | 346 B(LdaSmi8), U8(2), // |
| 347 B(LdaSmi8), U8(2), // | 347 B(BitwiseAnd), R(0), // |
| 348 B(BitwiseAnd), R(0), // | 348 B(Return)}, |
| 349 B(Return)}, | 349 0}, |
| 350 0}, | 350 {"var x = 10; return x << 3;", |
| 351 {"var x = 10; return x << 3;", | 351 kPointerSize, |
| 352 kPointerSize, | 352 1, |
| 353 1, | 353 9, |
| 354 9, | 354 {B(LdaSmi8), U8(10), // |
| 355 {B(LdaSmi8), U8(10), // | 355 B(Star), R(0), // |
| 356 B(Star), R(0), // | 356 B(LdaSmi8), U8(3), // |
| 357 B(LdaSmi8), U8(3), // | 357 B(ShiftLeft), R(0), // |
| 358 B(ShiftLeft), R(0), // | 358 B(Return)}, |
| 359 B(Return)}, | 359 0}, |
| 360 0}, | 360 {"var x = 10; return x >> 3;", |
| 361 {"var x = 10; return x >> 3;", | 361 kPointerSize, |
| 362 kPointerSize, | 362 1, |
| 363 1, | 363 9, |
| 364 9, | 364 {B(LdaSmi8), U8(10), // |
| 365 {B(LdaSmi8), U8(10), // | 365 B(Star), R(0), // |
| 366 B(Star), R(0), // | 366 B(LdaSmi8), U8(3), // |
| 367 B(LdaSmi8), U8(3), // | 367 B(ShiftRight), R(0), // |
| 368 B(ShiftRight), R(0), // | 368 B(Return)}, |
| 369 B(Return)}, | 369 0}, |
| 370 0}, | 370 {"var x = 10; return x >>> 3;", |
| 371 {"var x = 10; return x >>> 3;", | 371 kPointerSize, |
| 372 kPointerSize, | 372 1, |
| 373 1, | 373 9, |
| 374 9, | 374 {B(LdaSmi8), U8(10), // |
| 375 {B(LdaSmi8), U8(10), // | 375 B(Star), R(0), // |
| 376 B(Star), R(0), // | 376 B(LdaSmi8), U8(3), // |
| 377 B(LdaSmi8), U8(3), // | 377 B(ShiftRightLogical), R(0), // |
| 378 B(ShiftRightLogical), R(0), // | 378 B(Return)}, |
| 379 B(Return)}, | 379 0}, |
| 380 0}, | 380 {"var x = 0; return (x, 3);", |
| 381 {"var x = 0; return (x, 3);", | 381 kPointerSize, |
| 382 kPointerSize, | 382 1, |
| 383 1, | 383 6, |
| 384 6, | 384 {B(LdaZero), // |
| 385 {B(LdaZero), // | 385 B(Star), R(0), // |
| 386 B(Star), R(0), // | 386 B(LdaSmi8), U8(3), // |
| 387 B(LdaSmi8), U8(3), // | 387 B(Return)}, |
| 388 B(Return)}, | 388 0}}; |
| 389 0}}; | |
| 390 | 389 |
| 391 for (size_t i = 0; i < arraysize(snippets); i++) { | 390 for (size_t i = 0; i < arraysize(snippets); i++) { |
| 392 Handle<BytecodeArray> bytecode_array = | 391 Handle<BytecodeArray> bytecode_array = |
| 393 helper.MakeBytecodeForFunctionBody(snippets[i].code_snippet); | 392 helper.MakeBytecodeForFunctionBody(snippets[i].code_snippet); |
| 394 CheckBytecodeArrayEqual(snippets[i], bytecode_array); | 393 CheckBytecodeArrayEqual(snippets[i], bytecode_array); |
| 395 } | 394 } |
| 396 } | 395 } |
| 397 | 396 |
| 398 | 397 |
| 399 TEST(LogicalExpressions) { | 398 TEST(LogicalExpressions) { |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 465 B(Star), R(1), // | 464 B(Star), R(1), // |
| 466 B(LdaSmi8), U8(4), // | 465 B(LdaSmi8), U8(4), // |
| 467 B(Star), R(2), // | 466 B(Star), R(2), // |
| 468 B(Ldar), R(0), // | 467 B(Ldar), R(0), // |
| 469 B(JumpIfToBooleanTrue), U8(8), // | 468 B(JumpIfToBooleanTrue), U8(8), // |
| 470 B(LdaSmi8), U8(5), // | 469 B(LdaSmi8), U8(5), // |
| 471 B(Star), R(2), // | 470 B(Star), R(2), // |
| 472 B(LdaSmi8), U8(3), // | 471 B(LdaSmi8), U8(3), // |
| 473 B(Return)}, | 472 B(Return)}, |
| 474 0}, | 473 0}, |
| 475 {"var x = 1; var a = 2, b = 3; return x || (" | 474 {"var x = 1; var a = 2, b = 3; return x || (" REPEAT_32( |
| 476 REPEAT_32(SPACE, "a = 1, b = 2, ") | 475 SPACE, "a = 1, b = 2, ") "3);", |
| 477 "3);", | |
| 478 3 * kPointerSize, | 476 3 * kPointerSize, |
| 479 1, | 477 1, |
| 480 275, | 478 275, |
| 481 {B(LdaSmi8), U8(1), // | 479 {B(LdaSmi8), U8(1), // |
| 482 B(Star), R(0), // | 480 B(Star), R(0), // |
| 483 B(LdaSmi8), U8(2), // | 481 B(LdaSmi8), U8(2), // |
| 484 B(Star), R(1), // | 482 B(Star), R(1), // |
| 485 B(LdaSmi8), U8(3), // | 483 B(LdaSmi8), U8(3), // |
| 486 B(Star), R(2), // | 484 B(Star), R(2), // |
| 487 B(Ldar), R(0), // | 485 B(Ldar), R(0), // |
| 488 B(JumpIfToBooleanTrueConstant), U8(0), // | 486 B(JumpIfToBooleanTrueConstant), U8(0), // |
| 489 REPEAT_32(COMMA, // | 487 REPEAT_32(COMMA, // |
| 490 B(LdaSmi8), U8(1), // | 488 B(LdaSmi8), U8(1), // |
| 491 B(Star), R(1), // | 489 B(Star), R(1), // |
| 492 B(LdaSmi8), U8(2), // | 490 B(LdaSmi8), U8(2), // |
| 493 B(Star), R(2)), // | 491 B(Star), R(2)), // |
| 494 B(LdaSmi8), U8(3), // | 492 B(LdaSmi8), |
| 493 U8(3), // |
| 495 B(Return)}, | 494 B(Return)}, |
| 496 1, | 495 1, |
| 497 {260, 0, 0, 0}}, | 496 {260, 0, 0, 0}}, |
| 498 {"var x = 0; var a = 2, b = 3; return x && (" | 497 {"var x = 0; var a = 2, b = 3; return x && (" REPEAT_32( |
| 499 REPEAT_32(SPACE, "a = 1, b = 2, ") | 498 SPACE, "a = 1, b = 2, ") "3);", |
| 500 "3);", | |
| 501 3 * kPointerSize, | 499 3 * kPointerSize, |
| 502 1, | 500 1, |
| 503 274, | 501 274, |
| 504 {B(LdaZero), // | 502 {B(LdaZero), // |
| 505 B(Star), R(0), // | 503 B(Star), R(0), // |
| 506 B(LdaSmi8), U8(2), // | 504 B(LdaSmi8), U8(2), // |
| 507 B(Star), R(1), // | 505 B(Star), R(1), // |
| 508 B(LdaSmi8), U8(3), // | 506 B(LdaSmi8), U8(3), // |
| 509 B(Star), R(2), // | 507 B(Star), R(2), // |
| 510 B(Ldar), R(0), // | 508 B(Ldar), R(0), // |
| 511 B(JumpIfToBooleanFalseConstant), U8(0), // | 509 B(JumpIfToBooleanFalseConstant), U8(0), // |
| 512 REPEAT_32(COMMA, // | 510 REPEAT_32(COMMA, // |
| 513 B(LdaSmi8), U8(1), // | 511 B(LdaSmi8), U8(1), // |
| 514 B(Star), R(1), // | 512 B(Star), R(1), // |
| 515 B(LdaSmi8), U8(2), // | 513 B(LdaSmi8), U8(2), // |
| 516 B(Star), R(2)), // | 514 B(Star), R(2)), // |
| 517 B(LdaSmi8), U8(3), // | 515 B(LdaSmi8), |
| 518 B(Return)}, // | 516 U8(3), // |
| 517 B(Return)}, // |
| 519 1, | 518 1, |
| 520 {260, 0, 0, 0}}, | 519 {260, 0, 0, 0}}, |
| 521 {"var x = 1; var a = 2, b = 3; return (x > 3) || (" | 520 {"var x = 1; var a = 2, b = 3; return (x > 3) || (" REPEAT_32( |
| 522 REPEAT_32(SPACE, "a = 1, b = 2, ") | 521 SPACE, "a = 1, b = 2, ") "3);", |
| 523 "3);", | |
| 524 3 * kPointerSize, | 522 3 * kPointerSize, |
| 525 1, | 523 1, |
| 526 277, | 524 277, |
| 527 {B(LdaSmi8), U8(1), // | 525 {B(LdaSmi8), U8(1), // |
| 528 B(Star), R(0), // | 526 B(Star), R(0), // |
| 529 B(LdaSmi8), U8(2), // | 527 B(LdaSmi8), U8(2), // |
| 530 B(Star), R(1), // | 528 B(Star), R(1), // |
| 531 B(LdaSmi8), U8(3), // | 529 B(LdaSmi8), U8(3), // |
| 532 B(Star), R(2), // | 530 B(Star), R(2), // |
| 533 B(LdaSmi8), U8(3), // | 531 B(LdaSmi8), U8(3), // |
| 534 B(TestGreaterThan), R(0), // | 532 B(TestGreaterThan), R(0), // |
| 535 B(JumpIfTrueConstant), U8(0), // | 533 B(JumpIfTrueConstant), U8(0), // |
| 536 REPEAT_32(COMMA, // | 534 REPEAT_32(COMMA, // |
| 537 B(LdaSmi8), U8(1), // | 535 B(LdaSmi8), U8(1), // |
| 538 B(Star), R(1), // | 536 B(Star), R(1), // |
| 539 B(LdaSmi8), U8(2), // | 537 B(LdaSmi8), U8(2), // |
| 540 B(Star), R(2)), // | 538 B(Star), R(2)), // |
| 541 B(LdaSmi8), U8(3), // | 539 B(LdaSmi8), |
| 540 U8(3), // |
| 542 B(Return)}, | 541 B(Return)}, |
| 543 1, | 542 1, |
| 544 {260, 0, 0, 0}}, | 543 {260, 0, 0, 0}}, |
| 545 {"var x = 0; var a = 2, b = 3; return (x < 5) && (" | 544 {"var x = 0; var a = 2, b = 3; return (x < 5) && (" REPEAT_32( |
| 546 REPEAT_32(SPACE, "a = 1, b = 2, ") | 545 SPACE, "a = 1, b = 2, ") "3);", |
| 547 "3);", | |
| 548 3 * kPointerSize, | 546 3 * kPointerSize, |
| 549 1, | 547 1, |
| 550 276, | 548 276, |
| 551 {B(LdaZero), // | 549 {B(LdaZero), // |
| 552 B(Star), R(0), // | 550 B(Star), R(0), // |
| 553 B(LdaSmi8), U8(2), // | 551 B(LdaSmi8), U8(2), // |
| 554 B(Star), R(1), // | 552 B(Star), R(1), // |
| 555 B(LdaSmi8), U8(3), // | 553 B(LdaSmi8), U8(3), // |
| 556 B(Star), R(2), // | 554 B(Star), R(2), // |
| 557 B(LdaSmi8), U8(5), // | 555 B(LdaSmi8), U8(5), // |
| 558 B(TestLessThan), R(0), // | 556 B(TestLessThan), R(0), // |
| 559 B(JumpIfFalseConstant), U8(0), // | 557 B(JumpIfFalseConstant), U8(0), // |
| 560 REPEAT_32(COMMA, // | 558 REPEAT_32(COMMA, // |
| 561 B(LdaSmi8), U8(1), // | 559 B(LdaSmi8), U8(1), // |
| 562 B(Star), R(1), // | 560 B(Star), R(1), // |
| 563 B(LdaSmi8), U8(2), // | 561 B(LdaSmi8), U8(2), // |
| 564 B(Star), R(2)), // | 562 B(Star), R(2)), // |
| 565 B(LdaSmi8), U8(3), // | 563 B(LdaSmi8), |
| 564 U8(3), // |
| 566 B(Return)}, | 565 B(Return)}, |
| 567 1, | 566 1, |
| 568 {260, 0, 0, 0}}, | 567 {260, 0, 0, 0}}, |
| 569 {"return 0 && 3;", | 568 {"return 0 && 3;", |
| 570 0 * kPointerSize, | 569 0 * kPointerSize, |
| 571 1, | 570 1, |
| 572 2, | 571 2, |
| 573 {B(LdaZero), // | 572 {B(LdaZero), // |
| 574 B(Return)}, | 573 B(Return)}, |
| 575 0}, | 574 0}, |
| (...skipping 687 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1263 B(Ldar), A(2, 3), // | 1262 B(Ldar), A(2, 3), // |
| 1264 B(Add), A(2, 3), // | 1263 B(Add), A(2, 3), // |
| 1265 B(Star), R(2), // | 1264 B(Star), R(2), // |
| 1266 B(Ldar), A(2, 3), // | 1265 B(Ldar), A(2, 3), // |
| 1267 B(Star), R(3), // | 1266 B(Star), R(3), // |
| 1268 B(Call), R(0), R(1), U8(2), U8(vector->GetIndex(slot1)), // | 1267 B(Call), R(0), R(1), U8(2), U8(vector->GetIndex(slot1)), // |
| 1269 B(Return), // | 1268 B(Return), // |
| 1270 }, | 1269 }, |
| 1271 1, | 1270 1, |
| 1272 {"func"}}, | 1271 {"func"}}, |
| 1273 {"function f(a) {\n" | 1272 {"function f(a) {\n" REPEAT_127( |
| 1274 REPEAT_127(SPACE, " a.func;\n") | 1273 SPACE, " a.func;\n") " return a.func(); }\nf(" FUNC_ARG ")", |
| 1275 " return a.func(); }\nf(" FUNC_ARG ")", | |
| 1276 2 * kPointerSize, | 1274 2 * kPointerSize, |
| 1277 2, | 1275 2, |
| 1278 528, | 1276 528, |
| 1279 { | 1277 { |
| 1280 REPEAT_127(COMMA, // | 1278 REPEAT_127(COMMA, // |
| 1281 B(LoadICSloppy), A(1, 2), U8(0), U8((wide_idx += 2))), // | 1279 B(LoadICSloppy), A(1, 2), U8(0), U8((wide_idx += 2))), // |
| 1282 B(Ldar), A(1, 2), // | 1280 B(Ldar), |
| 1283 B(Star), R(1), // | 1281 A(1, 2), // |
| 1284 B(LoadICSloppyWide), R(1), U16(0), U16(wide_idx + 4), // | 1282 B(Star), R(1), // |
| 1285 B(Star), R(0), // | 1283 B(LoadICSloppyWide), R(1), U16(0), U16(wide_idx + 4), // |
| 1286 B(CallWide), R(0), R(1), U16(0), U16(wide_idx + 2), // | 1284 B(Star), R(0), // |
| 1287 B(Return), // | 1285 B(CallWide), R(0), R(1), U16(0), U16(wide_idx + 2), // |
| 1286 B(Return), // |
| 1288 }, | 1287 }, |
| 1289 1, | 1288 1, |
| 1290 {"func"}}, | 1289 {"func"}}, |
| 1291 }; | 1290 }; |
| 1292 for (size_t i = 0; i < arraysize(snippets); i++) { | 1291 for (size_t i = 0; i < arraysize(snippets); i++) { |
| 1293 Handle<BytecodeArray> bytecode_array = | 1292 Handle<BytecodeArray> bytecode_array = |
| 1294 helper.MakeBytecode(snippets[i].code_snippet, helper.kFunctionName); | 1293 helper.MakeBytecode(snippets[i].code_snippet, helper.kFunctionName); |
| 1295 CheckBytecodeArrayEqual(snippets[i], bytecode_array); | 1294 CheckBytecodeArrayEqual(snippets[i], bytecode_array); |
| 1296 } | 1295 } |
| 1297 } | 1296 } |
| (...skipping 426 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1724 B(TestIn), A(1, 3), // | 1723 B(TestIn), A(1, 3), // |
| 1725 B(JumpIfFalse), U8(5), // | 1724 B(JumpIfFalse), U8(5), // |
| 1726 B(LdaConstant), U8(0), // | 1725 B(LdaConstant), U8(0), // |
| 1727 B(Return), // | 1726 B(Return), // |
| 1728 B(LdaUndefined), // | 1727 B(LdaUndefined), // |
| 1729 B(Return), // | 1728 B(Return), // |
| 1730 }, | 1729 }, |
| 1731 1, | 1730 1, |
| 1732 {helper.factory()->NewNumberFromInt(200), unused, unused, unused, unused, | 1731 {helper.factory()->NewNumberFromInt(200), unused, unused, unused, unused, |
| 1733 unused}}, | 1732 unused}}, |
| 1734 {"function f(z) { var a = 0; var b = 0; if (a === 0.01) { " | 1733 {"function f(z) { var a = 0; var b = 0; if (a === 0.01) { " REPEAT_64( |
| 1735 REPEAT_64(SPACE, "b = a; a = b; ") | 1734 SPACE, |
| 1736 " return 200; } else { return -200; } } f(0.001)", | 1735 "b = a; a = b; ") " return 200; } else { return -200; } } f(0.001)", |
| 1737 2 * kPointerSize, | 1736 2 * kPointerSize, |
| 1738 2, | 1737 2, |
| 1739 278, | 1738 278, |
| 1740 { | 1739 {B(LdaZero), // |
| 1741 B(LdaZero), // | 1740 B(Star), R(0), // |
| 1742 B(Star), R(0), // | 1741 B(LdaZero), // |
| 1743 B(LdaZero), // | 1742 B(Star), R(1), // |
| 1744 B(Star), R(1), // | 1743 B(LdaConstant), U8(0), // |
| 1745 B(LdaConstant), U8(0), // | 1744 B(TestEqualStrict), R(0), // |
| 1746 B(TestEqualStrict), R(0), // | 1745 B(JumpIfFalseConstant), U8(2), // |
| 1747 B(JumpIfFalseConstant), U8(2), // | 1746 B(Ldar), R(0), // |
| 1748 B(Ldar), R(0), // | 1747 REPEAT_64(COMMA, // |
| 1749 REPEAT_64(COMMA, // | 1748 B(Star), R(1), // |
| 1750 B(Star), R(1), // | 1749 B(Star), R(0)), // |
| 1751 B(Star), R(0)), // | 1750 B(LdaConstant), |
| 1752 B(LdaConstant), U8(1), // | 1751 U8(1), // |
| 1753 B(Return), // | 1752 B(Return), // |
| 1754 B(LdaConstant), U8(3), // | 1753 B(LdaConstant), U8(3), // |
| 1755 B(Return), // | 1754 B(Return), // |
| 1756 B(LdaUndefined), // | 1755 B(LdaUndefined), // |
| 1757 B(Return)}, // | 1756 B(Return)}, // |
| 1758 4, | 1757 4, |
| 1759 {helper.factory()->NewHeapNumber(0.01), | 1758 {helper.factory()->NewHeapNumber(0.01), |
| 1760 helper.factory()->NewNumberFromInt(200), | 1759 helper.factory()->NewNumberFromInt(200), |
| 1761 helper.factory()->NewNumberFromInt(263), | 1760 helper.factory()->NewNumberFromInt(263), |
| 1762 helper.factory()->NewNumberFromInt(-200), unused, unused}}, | 1761 helper.factory()->NewNumberFromInt(-200), unused, unused}}, |
| 1763 {"function f() { var a = 0; var b = 0; if (a) { " | 1762 {"function f() { var a = 0; var b = 0; if (a) { " REPEAT_64( |
| 1764 REPEAT_64(SPACE, "b = a; a = b; ") | 1763 SPACE, |
| 1765 " return 200; } else { return -200; } } f()", | 1764 "b = a; a = b; ") " return 200; } else { return -200; } } f()", |
| 1766 2 * kPointerSize, | 1765 2 * kPointerSize, |
| 1767 1, | 1766 1, |
| 1768 276, | 1767 276, |
| 1769 { | 1768 {B(LdaZero), // |
| 1770 B(LdaZero), // | 1769 B(Star), R(0), // |
| 1771 B(Star), R(0), // | 1770 B(LdaZero), // |
| 1772 B(LdaZero), // | 1771 B(Star), R(1), // |
| 1773 B(Star), R(1), // | 1772 B(Ldar), R(0), // |
| 1774 B(Ldar), R(0), // | 1773 B(JumpIfToBooleanFalseConstant), U8(1), // |
| 1775 B(JumpIfToBooleanFalseConstant), U8(1), // | 1774 B(Ldar), R(0), // |
| 1776 B(Ldar), R(0), // | 1775 REPEAT_64(COMMA, // |
| 1777 REPEAT_64(COMMA, // | 1776 B(Star), R(1), // |
| 1778 B(Star), R(1), // | 1777 B(Star), R(0)), // |
| 1779 B(Star), R(0)), // | 1778 B(LdaConstant), |
| 1780 B(LdaConstant), U8(0), // | 1779 U8(0), // |
| 1781 B(Return), // | 1780 B(Return), // |
| 1782 B(LdaConstant), U8(2), // | 1781 B(LdaConstant), U8(2), // |
| 1783 B(Return), // | 1782 B(Return), // |
| 1784 B(LdaUndefined), // | 1783 B(LdaUndefined), // |
| 1785 B(Return)}, // | 1784 B(Return)}, // |
| 1786 3, | 1785 3, |
| 1787 {helper.factory()->NewNumberFromInt(200), | 1786 {helper.factory()->NewNumberFromInt(200), |
| 1788 helper.factory()->NewNumberFromInt(263), | 1787 helper.factory()->NewNumberFromInt(263), |
| 1789 helper.factory()->NewNumberFromInt(-200), unused, unused, unused}}, | 1788 helper.factory()->NewNumberFromInt(-200), unused, unused, unused}}, |
| 1790 | 1789 |
| 1791 {"function f(a, b) {\n" | 1790 {"function f(a, b) {\n" |
| 1792 " if (a == b) { return 1; }\n" | 1791 " if (a == b) { return 1; }\n" |
| 1793 " if (a === b) { return 1; }\n" | 1792 " if (a === b) { return 1; }\n" |
| 1794 " if (a < b) { return 1; }\n" | 1793 " if (a < b) { return 1; }\n" |
| 1795 " if (a > b) { return 1; }\n" | 1794 " if (a > b) { return 1; }\n" |
| (...skipping 30 matching lines...) Expand all Loading... |
| 1826 " var a = 0;" | 1825 " var a = 0;" |
| 1827 " if (a) {" | 1826 " if (a) {" |
| 1828 " return 20;" | 1827 " return 20;" |
| 1829 "} else {" | 1828 "} else {" |
| 1830 " return -20;}" | 1829 " return -20;}" |
| 1831 "};" | 1830 "};" |
| 1832 "f();", | 1831 "f();", |
| 1833 1 * kPointerSize, | 1832 1 * kPointerSize, |
| 1834 1, | 1833 1, |
| 1835 13, | 1834 13, |
| 1836 { | 1835 {B(LdaZero), // |
| 1837 B(LdaZero), // | 1836 B(Star), R(0), // |
| 1838 B(Star), R(0), // | 1837 B(JumpIfToBooleanFalse), U8(5), // |
| 1839 B(JumpIfToBooleanFalse), U8(5), // | 1838 B(LdaSmi8), U8(20), // |
| 1840 B(LdaSmi8), U8(20), // | 1839 B(Return), // |
| 1841 B(Return), // | 1840 B(LdaSmi8), U8(-20), // |
| 1842 B(LdaSmi8), U8(-20), // | 1841 B(Return), // |
| 1843 B(Return), // | 1842 B(LdaUndefined), // |
| 1844 B(LdaUndefined), // | 1843 B(Return)}, |
| 1845 B(Return) | |
| 1846 }, | |
| 1847 0, | 1844 0, |
| 1848 {unused, unused, unused, unused, unused, unused}}}; | 1845 {unused, unused, unused, unused, unused, unused}}}; |
| 1849 | 1846 |
| 1850 for (size_t i = 0; i < arraysize(snippets); i++) { | 1847 for (size_t i = 0; i < arraysize(snippets); i++) { |
| 1851 Handle<BytecodeArray> bytecode_array = | 1848 Handle<BytecodeArray> bytecode_array = |
| 1852 helper.MakeBytecode(snippets[i].code_snippet, helper.kFunctionName); | 1849 helper.MakeBytecode(snippets[i].code_snippet, helper.kFunctionName); |
| 1853 CheckBytecodeArrayEqual(snippets[i], bytecode_array); | 1850 CheckBytecodeArrayEqual(snippets[i], bytecode_array); |
| 1854 } | 1851 } |
| 1855 } | 1852 } |
| 1856 | 1853 |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1927 B(CallRuntime), U16(Runtime::kDeclareGlobals), R(1), U8(2), // | 1924 B(CallRuntime), U16(Runtime::kDeclareGlobals), R(1), U8(2), // |
| 1928 B(LdaConstant), U8(1), // | 1925 B(LdaConstant), U8(1), // |
| 1929 B(Star), R(1), // | 1926 B(Star), R(1), // |
| 1930 B(LdaZero), // | 1927 B(LdaZero), // |
| 1931 B(Star), R(2), // | 1928 B(Star), R(2), // |
| 1932 B(LdaSmi8), U8(1), // | 1929 B(LdaSmi8), U8(1), // |
| 1933 B(Star), R(3), // | 1930 B(Star), R(3), // |
| 1934 B(CallRuntime), U16(Runtime::kInitializeVarGlobal), R(1), U8(3), // | 1931 B(CallRuntime), U16(Runtime::kInitializeVarGlobal), R(1), U8(3), // |
| 1935 B(LdaSmi8), U8(2), // | 1932 B(LdaSmi8), U8(2), // |
| 1936 B(StaGlobalSloppy), U8(1), // | 1933 B(StaGlobalSloppy), U8(1), // |
| 1937 U8(store_vector->GetIndex(store_slot_2)), // | 1934 U8(store_vector->GetIndex(store_slot_2)), // |
| 1938 B(Star), R(0), // | 1935 B(Star), R(0), // |
| 1939 B(Return) // | 1936 B(Return) // |
| 1940 }, | 1937 }, |
| 1941 2, | 1938 2, |
| 1942 {InstanceType::FIXED_ARRAY_TYPE, | 1939 {InstanceType::FIXED_ARRAY_TYPE, |
| 1943 InstanceType::ONE_BYTE_INTERNALIZED_STRING_TYPE}}, | 1940 InstanceType::ONE_BYTE_INTERNALIZED_STRING_TYPE}}, |
| 1944 {"function f() {}\nf();", | 1941 {"function f() {}\nf();", |
| 1945 3 * kPointerSize, | 1942 3 * kPointerSize, |
| 1946 1, | 1943 1, |
| 1947 28, | 1944 28, |
| 1948 { | 1945 { |
| 1949 B(LdaConstant), U8(0), // | 1946 B(LdaConstant), U8(0), // |
| 1950 B(Star), R(1), // | 1947 B(Star), R(1), // |
| 1951 B(LdaZero), // | 1948 B(LdaZero), // |
| 1952 B(Star), R(2), // | 1949 B(Star), R(2), // |
| 1953 B(CallRuntime), U16(Runtime::kDeclareGlobals), R(1), U8(2), // | 1950 B(CallRuntime), U16(Runtime::kDeclareGlobals), R(1), U8(2), // |
| 1954 B(LdaUndefined), // | 1951 B(LdaUndefined), // |
| 1955 B(Star), R(2), // | 1952 B(Star), R(2), // |
| 1956 B(LdaGlobalSloppy), U8(1), // | 1953 B(LdaGlobalSloppy), U8(1), // |
| 1957 U8(load_vector->GetIndex(load_slot_1)), // | 1954 U8(load_vector->GetIndex(load_slot_1)), // |
| 1958 B(Star), R(1), // | 1955 B(Star), R(1), // |
| 1959 B(Call), R(1), R(2), U8(0), // | 1956 B(Call), R(1), R(2), U8(0), // |
| 1960 U8(load_vector->GetIndex(call_slot_1)), // | 1957 U8(load_vector->GetIndex(call_slot_1)), // |
| 1961 B(Star), R(0), // | 1958 B(Star), R(0), // |
| 1962 B(Return) // | 1959 B(Return) // |
| 1963 }, | 1960 }, |
| 1964 2, | 1961 2, |
| 1965 {InstanceType::FIXED_ARRAY_TYPE, | 1962 {InstanceType::FIXED_ARRAY_TYPE, |
| 1966 InstanceType::ONE_BYTE_INTERNALIZED_STRING_TYPE}}, | 1963 InstanceType::ONE_BYTE_INTERNALIZED_STRING_TYPE}}, |
| 1967 }; | 1964 }; |
| 1968 | 1965 |
| 1969 for (size_t i = 0; i < arraysize(snippets); i++) { | 1966 for (size_t i = 0; i < arraysize(snippets); i++) { |
| 1970 Handle<BytecodeArray> bytecode_array = | 1967 Handle<BytecodeArray> bytecode_array = |
| 1971 helper.MakeTopLevelBytecode(snippets[i].code_snippet); | 1968 helper.MakeTopLevelBytecode(snippets[i].code_snippet); |
| 1972 CheckBytecodeArrayEqual(snippets[i], bytecode_array); | 1969 CheckBytecodeArrayEqual(snippets[i], bytecode_array); |
| (...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2195 B(LdaSmi8), U8(12), // | 2192 B(LdaSmi8), U8(12), // |
| 2196 B(Mul), R(1), // | 2193 B(Mul), R(1), // |
| 2197 B(Star), R(1), // | 2194 B(Star), R(1), // |
| 2198 B(LdaSmi8), U8(1), // | 2195 B(LdaSmi8), U8(1), // |
| 2199 B(Sub), R(0), // | 2196 B(Sub), R(0), // |
| 2200 B(Star), R(0), // | 2197 B(Star), R(0), // |
| 2201 B(Ldar), R(0), // | 2198 B(Ldar), R(0), // |
| 2202 B(JumpIfToBooleanTrue), U8(-14), // | 2199 B(JumpIfToBooleanTrue), U8(-14), // |
| 2203 B(Ldar), R(1), // | 2200 B(Ldar), R(1), // |
| 2204 B(Return), // | 2201 B(Return), // |
| 2205 }, | 2202 }, |
| 2206 0}, | 2203 0}, |
| 2207 {"var x = 10;" | 2204 {"var x = 10;" |
| 2208 "var y = 1;" | 2205 "var y = 1;" |
| 2209 "do {" | 2206 "do {" |
| 2210 " y = y * 12;" | 2207 " y = y * 12;" |
| 2211 " x = x - 1;" | 2208 " x = x - 1;" |
| 2212 "} while(x);" | 2209 "} while(x);" |
| 2213 "return y;", | 2210 "return y;", |
| 2214 2 * kPointerSize, | 2211 2 * kPointerSize, |
| 2215 1, | 2212 1, |
| (...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2395 helper.MakeBytecodeForFunctionBody(snippets[i].code_snippet); | 2392 helper.MakeBytecodeForFunctionBody(snippets[i].code_snippet); |
| 2396 CheckBytecodeArrayEqual(snippets[i], bytecode_array); | 2393 CheckBytecodeArrayEqual(snippets[i], bytecode_array); |
| 2397 } | 2394 } |
| 2398 } | 2395 } |
| 2399 | 2396 |
| 2400 | 2397 |
| 2401 TEST(UnaryOperators) { | 2398 TEST(UnaryOperators) { |
| 2402 InitializedHandleScope handle_scope; | 2399 InitializedHandleScope handle_scope; |
| 2403 BytecodeGeneratorHelper helper; | 2400 BytecodeGeneratorHelper helper; |
| 2404 | 2401 |
| 2405 ExpectedSnippet<int> snippets[] = { | 2402 ExpectedSnippet<int> snippets[] = {{"var x = 0;" |
| 2406 {"var x = 0;" | 2403 "while (x != 10) {" |
| 2407 "while (x != 10) {" | 2404 " x = x + 10;" |
| 2408 " x = x + 10;" | 2405 "}" |
| 2409 "}" | 2406 "return x;", |
| 2410 "return x;", | 2407 kPointerSize, |
| 2411 kPointerSize, | 2408 1, |
| 2412 1, | 2409 21, |
| 2413 21, | 2410 { |
| 2414 { | 2411 B(LdaZero), // |
| 2415 B(LdaZero), // | 2412 B(Star), R(0), // |
| 2416 B(Star), R(0), // | 2413 B(Jump), U8(8), // |
| 2417 B(Jump), U8(8), // | 2414 B(LdaSmi8), U8(10), // |
| 2418 B(LdaSmi8), U8(10), // | 2415 B(Add), R(0), // |
| 2419 B(Add), R(0), // | 2416 B(Star), R(0), // |
| 2420 B(Star), R(0), // | 2417 B(LdaSmi8), U8(10), // |
| 2421 B(LdaSmi8), U8(10), // | 2418 B(TestEqual), R(0), // |
| 2422 B(TestEqual), R(0), // | 2419 B(LogicalNot), // |
| 2423 B(LogicalNot), // | 2420 B(JumpIfTrue), U8(-11), // |
| 2424 B(JumpIfTrue), U8(-11), // | 2421 B(Ldar), R(0), // |
| 2425 B(Ldar), R(0), // | 2422 B(Return), // |
| 2426 B(Return), // | 2423 }, |
| 2427 }, | 2424 0}, |
| 2428 0}, | 2425 {"var x = false;" |
| 2429 {"var x = false;" | 2426 "do {" |
| 2430 "do {" | 2427 " x = !x;" |
| 2431 " x = !x;" | 2428 "} while(x == false);" |
| 2432 "} while(x == false);" | 2429 "return x;", |
| 2433 "return x;", | 2430 kPointerSize, |
| 2434 kPointerSize, | 2431 1, |
| 2435 1, | 2432 16, |
| 2436 16, | 2433 { |
| 2437 { | 2434 B(LdaFalse), // |
| 2438 B(LdaFalse), // | 2435 B(Star), R(0), // |
| 2439 B(Star), R(0), // | 2436 B(Ldar), R(0), // |
| 2440 B(Ldar), R(0), // | 2437 B(LogicalNot), // |
| 2441 B(LogicalNot), // | 2438 B(Star), R(0), // |
| 2442 B(Star), R(0), // | 2439 B(LdaFalse), // |
| 2443 B(LdaFalse), // | 2440 B(TestEqual), R(0), // |
| 2444 B(TestEqual), R(0), // | 2441 B(JumpIfTrue), U8(-8), // |
| 2445 B(JumpIfTrue), U8(-8), // | 2442 B(Ldar), R(0), // |
| 2446 B(Ldar), R(0), // | 2443 B(Return), // |
| 2447 B(Return), // | 2444 }, |
| 2448 }, | 2445 0}, |
| 2449 0}, | 2446 {"var x = 101;" |
| 2450 {"var x = 101;" | 2447 "return void(x * 3);", |
| 2451 "return void(x * 3);", | 2448 kPointerSize, |
| 2452 kPointerSize, | 2449 1, |
| 2453 1, | 2450 10, |
| 2454 10, | 2451 { |
| 2455 { | 2452 B(LdaSmi8), U8(101), // |
| 2456 B(LdaSmi8), U8(101), // | 2453 B(Star), R(0), // |
| 2457 B(Star), R(0), // | 2454 B(LdaSmi8), U8(3), // |
| 2458 B(LdaSmi8), U8(3), // | 2455 B(Mul), R(0), // |
| 2459 B(Mul), R(0), // | 2456 B(LdaUndefined), // |
| 2460 B(LdaUndefined), // | 2457 B(Return), // |
| 2461 B(Return), // | 2458 }, |
| 2462 }, | 2459 0}, |
| 2463 0}, | 2460 {"var x = 1234;" |
| 2464 {"var x = 1234;" | 2461 "var y = void (x * x - 1);" |
| 2465 "var y = void (x * x - 1);" | 2462 "return y;", |
| 2466 "return y;", | 2463 3 * kPointerSize, |
| 2467 3 * kPointerSize, | 2464 1, |
| 2468 1, | 2465 16, |
| 2469 16, | 2466 { |
| 2470 { | 2467 B(LdaConstant), U8(0), // |
| 2471 B(LdaConstant), U8(0), // | 2468 B(Star), R(0), // |
| 2472 B(Star), R(0), // | 2469 B(Mul), R(0), // |
| 2473 B(Mul), R(0), // | 2470 B(Star), R(2), // |
| 2474 B(Star), R(2), // | 2471 B(LdaSmi8), U8(1), // |
| 2475 B(LdaSmi8), U8(1), // | 2472 B(Sub), R(2), // |
| 2476 B(Sub), R(2), // | 2473 B(LdaUndefined), // |
| 2477 B(LdaUndefined), // | 2474 B(Star), R(1), // |
| 2478 B(Star), R(1), // | 2475 B(Return), // |
| 2479 B(Return), // | 2476 }, |
| 2480 }, | 2477 1, |
| 2481 1, | 2478 {1234}}, |
| 2482 {1234}}, | 2479 {"var x = 13;" |
| 2483 {"var x = 13;" | 2480 "return ~x;", |
| 2484 "return ~x;", | 2481 1 * kPointerSize, |
| 2485 1 * kPointerSize, | 2482 1, |
| 2486 1, | 2483 9, |
| 2487 9, | 2484 { |
| 2488 { | 2485 B(LdaSmi8), U8(13), // |
| 2489 B(LdaSmi8), U8(13), // | 2486 B(Star), R(0), // |
| 2490 B(Star), R(0), // | 2487 B(LdaSmi8), U8(-1), // |
| 2491 B(LdaSmi8), U8(-1), // | 2488 B(BitwiseXor), R(0), // |
| 2492 B(BitwiseXor), R(0), // | 2489 B(Return), // |
| 2493 B(Return), // | 2490 }, |
| 2494 }, | 2491 0}, |
| 2495 0}, | 2492 {"var x = 13;" |
| 2496 {"var x = 13;" | 2493 "return +x;", |
| 2497 "return +x;", | 2494 1 * kPointerSize, |
| 2498 1 * kPointerSize, | 2495 1, |
| 2499 1, | 2496 9, |
| 2500 9, | 2497 { |
| 2501 { | 2498 B(LdaSmi8), U8(13), // |
| 2502 B(LdaSmi8), U8(13), // | 2499 B(Star), R(0), // |
| 2503 B(Star), R(0), // | 2500 B(LdaSmi8), U8(1), // |
| 2504 B(LdaSmi8), U8(1), // | 2501 B(Mul), R(0), // |
| 2505 B(Mul), R(0), // | 2502 B(Return), // |
| 2506 B(Return), // | 2503 }, |
| 2507 }, | 2504 0}, |
| 2508 0}, | 2505 {"var x = 13;" |
| 2509 {"var x = 13;" | 2506 "return -x;", |
| 2510 "return -x;", | 2507 1 * kPointerSize, |
| 2511 1 * kPointerSize, | 2508 1, |
| 2512 1, | 2509 9, |
| 2513 9, | 2510 { |
| 2514 { | 2511 B(LdaSmi8), U8(13), // |
| 2515 B(LdaSmi8), U8(13), // | 2512 B(Star), R(0), // |
| 2516 B(Star), R(0), // | 2513 B(LdaSmi8), U8(-1), // |
| 2517 B(LdaSmi8), U8(-1), // | 2514 B(Mul), R(0), // |
| 2518 B(Mul), R(0), // | 2515 B(Return), // |
| 2519 B(Return), // | 2516 }, |
| 2520 }, | 2517 0}}; |
| 2521 0}}; | |
| 2522 | 2518 |
| 2523 for (size_t i = 0; i < arraysize(snippets); i++) { | 2519 for (size_t i = 0; i < arraysize(snippets); i++) { |
| 2524 Handle<BytecodeArray> bytecode_array = | 2520 Handle<BytecodeArray> bytecode_array = |
| 2525 helper.MakeBytecodeForFunctionBody(snippets[i].code_snippet); | 2521 helper.MakeBytecodeForFunctionBody(snippets[i].code_snippet); |
| 2526 CheckBytecodeArrayEqual(snippets[i], bytecode_array); | 2522 CheckBytecodeArrayEqual(snippets[i], bytecode_array); |
| 2527 } | 2523 } |
| 2528 } | 2524 } |
| 2529 | 2525 |
| 2530 | 2526 |
| 2531 TEST(Typeof) { | 2527 TEST(Typeof) { |
| (...skipping 22 matching lines...) Expand all Loading... |
| 2554 B(Return), // | 2550 B(Return), // |
| 2555 }}, | 2551 }}, |
| 2556 {"var x = 13;\n" | 2552 {"var x = 13;\n" |
| 2557 "function f() {\n" | 2553 "function f() {\n" |
| 2558 " return typeof(x);\n" | 2554 " return typeof(x);\n" |
| 2559 "}; f();", | 2555 "}; f();", |
| 2560 0, | 2556 0, |
| 2561 1, | 2557 1, |
| 2562 5, | 2558 5, |
| 2563 { | 2559 { |
| 2564 B(LdaGlobalInsideTypeofSloppy), U8(0), // | 2560 B(LdaGlobalInsideTypeofSloppy), U8(0), // |
| 2565 U8(vector->GetIndex(slot)), // | 2561 U8(vector->GetIndex(slot)), // |
| 2566 B(TypeOf), // | 2562 B(TypeOf), // |
| 2567 B(Return), // | 2563 B(Return), // |
| 2568 }, | 2564 }, |
| 2569 1, | 2565 1, |
| 2570 {"x"}}, | 2566 {"x"}}, |
| 2571 {"var x = 13;\n" | 2567 {"var x = 13;\n" |
| 2572 "function f() {\n" | 2568 "function f() {\n" |
| 2573 " 'use strict';\n" | 2569 " 'use strict';\n" |
| 2574 " return typeof(x);\n" | 2570 " return typeof(x);\n" |
| 2575 "}; f();", | 2571 "}; f();", |
| 2576 0, | 2572 0, |
| 2577 1, | 2573 1, |
| 2578 5, | 2574 5, |
| 2579 { | 2575 { |
| 2580 B(LdaGlobalInsideTypeofStrict), U8(0), // | 2576 B(LdaGlobalInsideTypeofStrict), U8(0), // |
| 2581 U8(vector->GetIndex(slot)), // | 2577 U8(vector->GetIndex(slot)), // |
| 2582 B(TypeOf), // | 2578 B(TypeOf), // |
| 2583 B(Return), // | 2579 B(Return), // |
| 2584 }, | 2580 }, |
| 2585 1, | 2581 1, |
| 2586 {"x"}}, | 2582 {"x"}}, |
| 2587 }; | 2583 }; |
| 2588 | 2584 |
| 2589 for (size_t i = 0; i < arraysize(snippets); i++) { | 2585 for (size_t i = 0; i < arraysize(snippets); i++) { |
| 2590 Handle<BytecodeArray> bytecode_array = | 2586 Handle<BytecodeArray> bytecode_array = |
| 2591 helper.MakeBytecodeForFunction(snippets[i].code_snippet); | 2587 helper.MakeBytecodeForFunction(snippets[i].code_snippet); |
| 2592 CheckBytecodeArrayEqual(snippets[i], bytecode_array); | 2588 CheckBytecodeArrayEqual(snippets[i], bytecode_array); |
| 2593 } | 2589 } |
| 2594 } | 2590 } |
| 2595 | 2591 |
| 2596 | 2592 |
| 2597 TEST(Delete) { | 2593 TEST(Delete) { |
| 2598 InitializedHandleScope handle_scope; | 2594 InitializedHandleScope handle_scope; |
| 2599 BytecodeGeneratorHelper helper; | 2595 BytecodeGeneratorHelper helper; |
| 2600 | 2596 |
| 2601 int deep_elements_flags = | 2597 int deep_elements_flags = |
| 2602 ObjectLiteral::kFastElements | ObjectLiteral::kDisableMementos; | 2598 ObjectLiteral::kFastElements | ObjectLiteral::kDisableMementos; |
| 2603 int closure = Register::function_closure().index(); | 2599 int closure = Register::function_closure().index(); |
| 2604 int first_context_slot = Context::MIN_CONTEXT_SLOTS; | 2600 int first_context_slot = Context::MIN_CONTEXT_SLOTS; |
| 2605 | 2601 |
| 2606 ExpectedSnippet<InstanceType> snippets[] = { | 2602 ExpectedSnippet<InstanceType> snippets[] = { |
| 2607 {"var a = {x:13, y:14}; return delete a.x;", | 2603 {"var a = {x:13, y:14}; return delete a.x;", |
| 2608 1 * kPointerSize, | 2604 1 * kPointerSize, |
| 2609 1, | 2605 1, |
| 2610 12, | 2606 12, |
| 2611 { | 2607 {B(LdaConstant), U8(0), // |
| 2612 B(LdaConstant), U8(0), // | 2608 B(CreateObjectLiteral), U8(0), U8(deep_elements_flags), // |
| 2613 B(CreateObjectLiteral), U8(0), U8(deep_elements_flags), // | 2609 B(Star), R(0), // |
| 2614 B(Star), R(0), // | 2610 B(LdaConstant), U8(1), // |
| 2615 B(LdaConstant), U8(1), // | 2611 B(DeletePropertySloppy), R(0), // |
| 2616 B(DeletePropertySloppy), R(0), // | 2612 B(Return)}, |
| 2617 B(Return) | |
| 2618 }, | |
| 2619 2, | 2613 2, |
| 2620 {InstanceType::FIXED_ARRAY_TYPE, | 2614 {InstanceType::FIXED_ARRAY_TYPE, |
| 2621 InstanceType::ONE_BYTE_INTERNALIZED_STRING_TYPE}}, | 2615 InstanceType::ONE_BYTE_INTERNALIZED_STRING_TYPE}}, |
| 2622 {"'use strict'; var a = {x:13, y:14}; return delete a.x;", | 2616 {"'use strict'; var a = {x:13, y:14}; return delete a.x;", |
| 2623 1 * kPointerSize, | 2617 1 * kPointerSize, |
| 2624 1, | 2618 1, |
| 2625 12, | 2619 12, |
| 2626 { | 2620 {B(LdaConstant), U8(0), // |
| 2627 B(LdaConstant), U8(0), // | 2621 B(CreateObjectLiteral), U8(0), U8(deep_elements_flags), // |
| 2628 B(CreateObjectLiteral), U8(0), U8(deep_elements_flags), // | 2622 B(Star), R(0), // |
| 2629 B(Star), R(0), // | 2623 B(LdaConstant), U8(1), // |
| 2630 B(LdaConstant), U8(1), // | 2624 B(DeletePropertyStrict), R(0), // |
| 2631 B(DeletePropertyStrict), R(0), // | 2625 B(Return)}, |
| 2632 B(Return) | |
| 2633 }, | |
| 2634 2, | 2626 2, |
| 2635 {InstanceType::FIXED_ARRAY_TYPE, | 2627 {InstanceType::FIXED_ARRAY_TYPE, |
| 2636 InstanceType::ONE_BYTE_INTERNALIZED_STRING_TYPE}}, | 2628 InstanceType::ONE_BYTE_INTERNALIZED_STRING_TYPE}}, |
| 2637 {"var a = {1:13, 2:14}; return delete a[2];", | 2629 {"var a = {1:13, 2:14}; return delete a[2];", |
| 2638 1 * kPointerSize, | 2630 1 * kPointerSize, |
| 2639 1, | 2631 1, |
| 2640 12, | 2632 12, |
| 2641 { | 2633 {B(LdaConstant), U8(0), // |
| 2642 B(LdaConstant), U8(0), // | 2634 B(CreateObjectLiteral), U8(0), U8(deep_elements_flags), // |
| 2643 B(CreateObjectLiteral), U8(0), U8(deep_elements_flags), // | 2635 B(Star), R(0), // |
| 2644 B(Star), R(0), // | 2636 B(LdaSmi8), U8(2), // |
| 2645 B(LdaSmi8), U8(2), // | 2637 B(DeletePropertySloppy), R(0), // |
| 2646 B(DeletePropertySloppy), R(0), // | 2638 B(Return)}, |
| 2647 B(Return) | |
| 2648 }, | |
| 2649 1, | 2639 1, |
| 2650 {InstanceType::FIXED_ARRAY_TYPE}}, | 2640 {InstanceType::FIXED_ARRAY_TYPE}}, |
| 2651 {"var a = 10; return delete a;", | 2641 {"var a = 10; return delete a;", |
| 2652 1 * kPointerSize, | 2642 1 * kPointerSize, |
| 2653 1, | 2643 1, |
| 2654 6, | 2644 6, |
| 2655 { | 2645 {B(LdaSmi8), U8(10), // |
| 2656 B(LdaSmi8), U8(10), // | 2646 B(Star), R(0), // |
| 2657 B(Star), R(0), // | 2647 B(LdaFalse), // |
| 2658 B(LdaFalse), // | 2648 B(Return)}, |
| 2659 B(Return) | |
| 2660 }, | |
| 2661 0}, | 2649 0}, |
| 2662 {"'use strict';" | 2650 {"'use strict';" |
| 2663 "var a = {1:10};" | 2651 "var a = {1:10};" |
| 2664 "(function f1() {return a;});" | 2652 "(function f1() {return a;});" |
| 2665 "return delete a[1];", | 2653 "return delete a[1];", |
| 2666 2 * kPointerSize, | 2654 2 * kPointerSize, |
| 2667 1, | 2655 1, |
| 2668 28, | 2656 28, |
| 2669 { | 2657 {B(CallRuntime), U16(Runtime::kNewFunctionContext), // |
| 2670 B(CallRuntime), U16(Runtime::kNewFunctionContext), // | 2658 R(closure), U8(1), // |
| 2671 R(closure), U8(1), // | 2659 B(PushContext), R(0), // |
| 2672 B(PushContext), R(0), // | 2660 B(LdaConstant), U8(0), // |
| 2673 B(LdaConstant), U8(0), // | 2661 B(CreateObjectLiteral), U8(0), U8(deep_elements_flags), // |
| 2674 B(CreateObjectLiteral), U8(0), U8(deep_elements_flags), // | 2662 B(StaContextSlot), R(0), U8(first_context_slot), // |
| 2675 B(StaContextSlot), R(0), U8(first_context_slot), // | 2663 B(CreateClosure), U8(1), U8(0), // |
| 2676 B(CreateClosure), U8(1), U8(0), // | 2664 B(LdaContextSlot), R(0), U8(first_context_slot), // |
| 2677 B(LdaContextSlot), R(0), U8(first_context_slot), // | 2665 B(Star), R(1), // |
| 2678 B(Star), R(1), // | 2666 B(LdaSmi8), U8(1), // |
| 2679 B(LdaSmi8), U8(1), // | 2667 B(DeletePropertyStrict), R(1), // |
| 2680 B(DeletePropertyStrict), R(1), // | 2668 B(Return)}, |
| 2681 B(Return) | |
| 2682 }, | |
| 2683 2, | 2669 2, |
| 2684 {InstanceType::FIXED_ARRAY_TYPE, | 2670 {InstanceType::FIXED_ARRAY_TYPE, |
| 2685 InstanceType::SHARED_FUNCTION_INFO_TYPE}}, | 2671 InstanceType::SHARED_FUNCTION_INFO_TYPE}}, |
| 2686 {"return delete 'test';", | 2672 {"return delete 'test';", |
| 2687 0 * kPointerSize, | 2673 0 * kPointerSize, |
| 2688 1, | 2674 1, |
| 2689 2, | 2675 2, |
| 2690 { | 2676 {B(LdaTrue), // |
| 2691 B(LdaTrue), // | 2677 B(Return)}, |
| 2692 B(Return) | |
| 2693 }, | |
| 2694 0}, | 2678 0}, |
| 2695 }; | 2679 }; |
| 2696 | 2680 |
| 2697 for (size_t i = 0; i < arraysize(snippets); i++) { | 2681 for (size_t i = 0; i < arraysize(snippets); i++) { |
| 2698 Handle<BytecodeArray> bytecode_array = | 2682 Handle<BytecodeArray> bytecode_array = |
| 2699 helper.MakeBytecodeForFunctionBody(snippets[i].code_snippet); | 2683 helper.MakeBytecodeForFunctionBody(snippets[i].code_snippet); |
| 2700 CheckBytecodeArrayEqual(snippets[i], bytecode_array); | 2684 CheckBytecodeArrayEqual(snippets[i], bytecode_array); |
| 2701 } | 2685 } |
| 2702 } | 2686 } |
| 2703 | 2687 |
| (...skipping 429 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3133 B(Star), R(0), // | 3117 B(Star), R(0), // |
| 3134 B(LdaConstant), U8(1), // | 3118 B(LdaConstant), U8(1), // |
| 3135 B(Star), R(1), // | 3119 B(Star), R(1), // |
| 3136 B(CreateClosure), U8(2), U8(0), // | 3120 B(CreateClosure), U8(2), U8(0), // |
| 3137 B(Star), R(2), // | 3121 B(Star), R(2), // |
| 3138 B(LdaNull), // | 3122 B(LdaNull), // |
| 3139 B(Star), R(3), // | 3123 B(Star), R(3), // |
| 3140 B(LdaZero), // | 3124 B(LdaZero), // |
| 3141 B(Star), R(4), // | 3125 B(Star), R(4), // |
| 3142 B(CallRuntime), U16(Runtime::kDefineAccessorPropertyUnchecked), // | 3126 B(CallRuntime), U16(Runtime::kDefineAccessorPropertyUnchecked), // |
| 3143 R(0), U8(5), // | 3127 R(0), U8(5), // |
| 3144 B(Ldar), R(0), // | 3128 B(Ldar), R(0), // |
| 3145 B(Return), // | 3129 B(Return), // |
| 3146 }, | 3130 }, |
| 3147 3, | 3131 3, |
| 3148 {InstanceType::FIXED_ARRAY_TYPE, | 3132 {InstanceType::FIXED_ARRAY_TYPE, |
| 3149 InstanceType::ONE_BYTE_INTERNALIZED_STRING_TYPE, | 3133 InstanceType::ONE_BYTE_INTERNALIZED_STRING_TYPE, |
| 3150 InstanceType::SHARED_FUNCTION_INFO_TYPE}}, | 3134 InstanceType::SHARED_FUNCTION_INFO_TYPE}}, |
| 3151 {"return { get a() { return this.x; }, set a(val) { this.x = val } };", | 3135 {"return { get a() { return this.x; }, set a(val) { this.x = val } };", |
| 3152 5 * kPointerSize, | 3136 5 * kPointerSize, |
| 3153 1, | 3137 1, |
| 3154 32, | 3138 32, |
| 3155 { | 3139 { |
| 3156 B(LdaConstant), U8(0), // | 3140 B(LdaConstant), U8(0), // |
| 3157 B(CreateObjectLiteral), U8(0), U8(deep_elements_flags), // | 3141 B(CreateObjectLiteral), U8(0), U8(deep_elements_flags), // |
| 3158 B(Star), R(0), // | 3142 B(Star), R(0), // |
| 3159 B(LdaConstant), U8(1), // | 3143 B(LdaConstant), U8(1), // |
| 3160 B(Star), R(1), // | 3144 B(Star), R(1), // |
| 3161 B(CreateClosure), U8(2), U8(0), // | 3145 B(CreateClosure), U8(2), U8(0), // |
| 3162 B(Star), R(2), // | 3146 B(Star), R(2), // |
| 3163 B(CreateClosure), U8(3), U8(0), // | 3147 B(CreateClosure), U8(3), U8(0), // |
| 3164 B(Star), R(3), // | 3148 B(Star), R(3), // |
| 3165 B(LdaZero), // | 3149 B(LdaZero), // |
| 3166 B(Star), R(4), // | 3150 B(Star), R(4), // |
| 3167 B(CallRuntime), U16(Runtime::kDefineAccessorPropertyUnchecked), // | 3151 B(CallRuntime), U16(Runtime::kDefineAccessorPropertyUnchecked), // |
| 3168 R(0), U8(5), // | 3152 R(0), U8(5), // |
| 3169 B(Ldar), R(0), // | 3153 B(Ldar), R(0), // |
| 3170 B(Return), // | 3154 B(Return), // |
| 3171 }, | 3155 }, |
| 3172 4, | 3156 4, |
| 3173 {InstanceType::FIXED_ARRAY_TYPE, | 3157 {InstanceType::FIXED_ARRAY_TYPE, |
| 3174 InstanceType::ONE_BYTE_INTERNALIZED_STRING_TYPE, | 3158 InstanceType::ONE_BYTE_INTERNALIZED_STRING_TYPE, |
| 3175 InstanceType::SHARED_FUNCTION_INFO_TYPE, | 3159 InstanceType::SHARED_FUNCTION_INFO_TYPE, |
| 3176 InstanceType::SHARED_FUNCTION_INFO_TYPE}}, | 3160 InstanceType::SHARED_FUNCTION_INFO_TYPE}}, |
| 3177 {"return { set b(val) { this.y = val } };", | 3161 {"return { set b(val) { this.y = val } };", |
| 3178 5 * kPointerSize, | 3162 5 * kPointerSize, |
| 3179 1, | 3163 1, |
| 3180 30, | 3164 30, |
| 3181 { | 3165 { |
| 3182 B(LdaConstant), U8(0), // | 3166 B(LdaConstant), U8(0), // |
| 3183 B(CreateObjectLiteral), U8(0), U8(deep_elements_flags), // | 3167 B(CreateObjectLiteral), U8(0), U8(deep_elements_flags), // |
| 3184 B(Star), R(0), // | 3168 B(Star), R(0), // |
| 3185 B(LdaConstant), U8(1), // | 3169 B(LdaConstant), U8(1), // |
| 3186 B(Star), R(1), // | 3170 B(Star), R(1), // |
| 3187 B(LdaNull), // | 3171 B(LdaNull), // |
| 3188 B(Star), R(2), // | 3172 B(Star), R(2), // |
| 3189 B(CreateClosure), U8(2), U8(0), // | 3173 B(CreateClosure), U8(2), U8(0), // |
| 3190 B(Star), R(3), // | 3174 B(Star), R(3), // |
| 3191 B(LdaZero), // | 3175 B(LdaZero), // |
| 3192 B(Star), R(4), // | 3176 B(Star), R(4), // |
| 3193 B(CallRuntime), U16(Runtime::kDefineAccessorPropertyUnchecked), // | 3177 B(CallRuntime), U16(Runtime::kDefineAccessorPropertyUnchecked), // |
| 3194 R(0), U8(5), // | 3178 R(0), U8(5), // |
| 3195 B(Ldar), R(0), // | 3179 B(Ldar), R(0), // |
| 3196 B(Return), // | 3180 B(Return), // |
| 3197 }, | 3181 }, |
| 3198 3, | 3182 3, |
| 3199 {InstanceType::FIXED_ARRAY_TYPE, | 3183 {InstanceType::FIXED_ARRAY_TYPE, |
| 3200 InstanceType::ONE_BYTE_INTERNALIZED_STRING_TYPE, | 3184 InstanceType::ONE_BYTE_INTERNALIZED_STRING_TYPE, |
| 3201 InstanceType::SHARED_FUNCTION_INFO_TYPE}}, | 3185 InstanceType::SHARED_FUNCTION_INFO_TYPE}}, |
| 3202 {"var a = 1; return { 1: a };", | 3186 {"var a = 1; return { 1: a };", |
| 3203 5 * kPointerSize, | 3187 5 * kPointerSize, |
| 3204 1, | 3188 1, |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3247 B(CreateObjectLiteral), U8(0), U8(simple_flags), // | 3231 B(CreateObjectLiteral), U8(0), U8(simple_flags), // |
| 3248 B(Star), R(1), // | 3232 B(Star), R(1), // |
| 3249 B(Ldar), R(0), // | 3233 B(Ldar), R(0), // |
| 3250 B(ToName), // | 3234 B(ToName), // |
| 3251 B(Star), R(2), // | 3235 B(Star), R(2), // |
| 3252 B(LdaSmi8), U8(1), // | 3236 B(LdaSmi8), U8(1), // |
| 3253 B(Star), R(3), // | 3237 B(Star), R(3), // |
| 3254 B(LdaZero), // | 3238 B(LdaZero), // |
| 3255 B(Star), R(4), // | 3239 B(Star), R(4), // |
| 3256 B(CallRuntime), U16(Runtime::kDefineDataPropertyUnchecked), R(1), // | 3240 B(CallRuntime), U16(Runtime::kDefineDataPropertyUnchecked), R(1), // |
| 3257 U8(4), // | 3241 U8(4), // |
| 3258 B(Ldar), R(1), // | 3242 B(Ldar), R(1), // |
| 3259 B(Return), // | 3243 B(Return), // |
| 3260 }, | 3244 }, |
| 3261 2, | 3245 2, |
| 3262 {InstanceType::ONE_BYTE_INTERNALIZED_STRING_TYPE, | 3246 {InstanceType::ONE_BYTE_INTERNALIZED_STRING_TYPE, |
| 3263 InstanceType::FIXED_ARRAY_TYPE}}, | 3247 InstanceType::FIXED_ARRAY_TYPE}}, |
| 3264 {"var a = 'test'; return { val: a, [a]: 1 }", | 3248 {"var a = 'test'; return { val: a, [a]: 1 }", |
| 3265 5 * kPointerSize, | 3249 5 * kPointerSize, |
| 3266 1, | 3250 1, |
| 3267 37, | 3251 37, |
| 3268 { | 3252 { |
| 3269 B(LdaConstant), U8(0), // | 3253 B(LdaConstant), U8(0), // |
| 3270 B(Star), R(0), // | 3254 B(Star), R(0), // |
| 3271 B(LdaConstant), U8(1), // | 3255 B(LdaConstant), U8(1), // |
| 3272 B(CreateObjectLiteral), U8(0), U8(deep_elements_flags), // | 3256 B(CreateObjectLiteral), U8(0), U8(deep_elements_flags), // |
| 3273 B(Star), R(1), // | 3257 B(Star), R(1), // |
| 3274 B(Ldar), R(0), // | 3258 B(Ldar), R(0), // |
| 3275 B(StoreICSloppy), R(1), U8(2), U8(vector->GetIndex(slot1)), // | 3259 B(StoreICSloppy), R(1), U8(2), U8(vector->GetIndex(slot1)), // |
| 3276 B(Ldar), R(0), // | 3260 B(Ldar), R(0), // |
| 3277 B(ToName), // | 3261 B(ToName), // |
| 3278 B(Star), R(2), // | 3262 B(Star), R(2), // |
| 3279 B(LdaSmi8), U8(1), // | 3263 B(LdaSmi8), U8(1), // |
| 3280 B(Star), R(3), // | 3264 B(Star), R(3), // |
| 3281 B(LdaZero), // | 3265 B(LdaZero), // |
| 3282 B(Star), R(4), // | 3266 B(Star), R(4), // |
| 3283 B(CallRuntime), U16(Runtime::kDefineDataPropertyUnchecked), R(1), // | 3267 B(CallRuntime), U16(Runtime::kDefineDataPropertyUnchecked), R(1), // |
| 3284 U8(4), // | 3268 U8(4), // |
| 3285 B(Ldar), R(1), // | 3269 B(Ldar), R(1), // |
| 3286 B(Return), // | 3270 B(Return), // |
| 3287 }, | 3271 }, |
| 3288 3, | 3272 3, |
| 3289 {InstanceType::ONE_BYTE_INTERNALIZED_STRING_TYPE, | 3273 {InstanceType::ONE_BYTE_INTERNALIZED_STRING_TYPE, |
| 3290 InstanceType::FIXED_ARRAY_TYPE, | 3274 InstanceType::FIXED_ARRAY_TYPE, |
| 3291 InstanceType::ONE_BYTE_INTERNALIZED_STRING_TYPE}}, | 3275 InstanceType::ONE_BYTE_INTERNALIZED_STRING_TYPE}}, |
| 3292 {"var a = 'test'; return { [a]: 1, __proto__: {} }", | 3276 {"var a = 'test'; return { [a]: 1, __proto__: {} }", |
| 3293 5 * kPointerSize, | 3277 5 * kPointerSize, |
| 3294 1, | 3278 1, |
| 3295 43, | 3279 43, |
| 3296 { | 3280 { |
| 3297 B(LdaConstant), U8(0), // | 3281 B(LdaConstant), U8(0), // |
| 3298 B(Star), R(0), // | 3282 B(Star), R(0), // |
| 3299 B(LdaConstant), U8(1), // | 3283 B(LdaConstant), U8(1), // |
| 3300 B(CreateObjectLiteral), U8(1), U8(simple_flags), // | 3284 B(CreateObjectLiteral), U8(1), U8(simple_flags), // |
| 3301 B(Star), R(1), // | 3285 B(Star), R(1), // |
| 3302 B(Ldar), R(0), // | 3286 B(Ldar), R(0), // |
| 3303 B(ToName), // | 3287 B(ToName), // |
| 3304 B(Star), R(2), // | 3288 B(Star), R(2), // |
| 3305 B(LdaSmi8), U8(1), // | 3289 B(LdaSmi8), U8(1), // |
| 3306 B(Star), R(3), // | 3290 B(Star), R(3), // |
| 3307 B(LdaZero), // | 3291 B(LdaZero), // |
| 3308 B(Star), R(4), // | 3292 B(Star), R(4), // |
| 3309 B(CallRuntime), U16(Runtime::kDefineDataPropertyUnchecked), R(1), // | 3293 B(CallRuntime), U16(Runtime::kDefineDataPropertyUnchecked), R(1), // |
| 3310 U8(4), // | 3294 U8(4), // |
| 3311 B(LdaConstant), U8(1), // | 3295 B(LdaConstant), U8(1), // |
| 3312 B(CreateObjectLiteral), U8(0), U8(13), // | 3296 B(CreateObjectLiteral), U8(0), U8(13), // |
| 3313 B(Star), R(2), // | 3297 B(Star), R(2), // |
| 3314 B(CallRuntime), U16(Runtime::kInternalSetPrototype), R(1), U8(2), // | 3298 B(CallRuntime), U16(Runtime::kInternalSetPrototype), R(1), U8(2), // |
| 3315 B(Ldar), R(1), // | 3299 B(Ldar), R(1), // |
| 3316 B(Return), // | 3300 B(Return), // |
| 3317 }, | 3301 }, |
| 3318 2, | 3302 2, |
| 3319 {InstanceType::ONE_BYTE_INTERNALIZED_STRING_TYPE, | 3303 {InstanceType::ONE_BYTE_INTERNALIZED_STRING_TYPE, |
| 3320 InstanceType::FIXED_ARRAY_TYPE}}, | 3304 InstanceType::FIXED_ARRAY_TYPE}}, |
| 3321 {"var n = 'name'; return { [n]: 'val', get a() { }, set a(b) {} };", | 3305 {"var n = 'name'; return { [n]: 'val', get a() { }, set a(b) {} };", |
| 3322 5 * kPointerSize, | 3306 5 * kPointerSize, |
| 3323 1, | 3307 1, |
| 3324 67, | 3308 67, |
| 3325 { | 3309 { |
| 3326 B(LdaConstant), U8(0), // | 3310 B(LdaConstant), U8(0), // |
| 3327 B(Star), R(0), // | 3311 B(Star), R(0), // |
| 3328 B(LdaConstant), U8(1), // | 3312 B(LdaConstant), U8(1), // |
| 3329 B(CreateObjectLiteral), U8(0), U8(simple_flags), // | 3313 B(CreateObjectLiteral), U8(0), U8(simple_flags), // |
| 3330 B(Star), R(1), // | 3314 B(Star), R(1), // |
| 3331 B(Ldar), R(0), // | 3315 B(Ldar), R(0), // |
| 3332 B(ToName), // | 3316 B(ToName), // |
| 3333 B(Star), R(2), // | 3317 B(Star), R(2), // |
| 3334 B(LdaConstant), U8(2), // | 3318 B(LdaConstant), U8(2), // |
| 3335 B(Star), R(3), // | 3319 B(Star), R(3), // |
| 3336 B(LdaZero), // | 3320 B(LdaZero), // |
| 3337 B(Star), R(4), // | 3321 B(Star), R(4), // |
| 3338 B(CallRuntime), U16(Runtime::kDefineDataPropertyUnchecked), R(1), // | 3322 B(CallRuntime), U16(Runtime::kDefineDataPropertyUnchecked), R(1), // |
| 3339 U8(4), // | 3323 U8(4), // |
| 3340 B(LdaConstant), U8(3), // | 3324 B(LdaConstant), U8(3), // |
| 3341 B(ToName), // | 3325 B(ToName), // |
| 3342 B(Star), R(2), // | 3326 B(Star), R(2), // |
| 3343 B(CreateClosure), U8(4), U8(0), // | 3327 B(CreateClosure), U8(4), U8(0), // |
| 3344 B(Star), R(3), // | 3328 B(Star), R(3), // |
| 3345 B(LdaZero), // | 3329 B(LdaZero), // |
| 3346 B(Star), R(4), // | 3330 B(Star), R(4), // |
| 3347 B(CallRuntime), U16(Runtime::kDefineGetterPropertyUnchecked), // | 3331 B(CallRuntime), U16(Runtime::kDefineGetterPropertyUnchecked), // |
| 3348 R(1), U8(4), // | 3332 R(1), U8(4), // |
| 3349 B(LdaConstant), U8(3), // | 3333 B(LdaConstant), U8(3), // |
| 3350 B(ToName), // | 3334 B(ToName), // |
| 3351 B(Star), R(2), // | 3335 B(Star), R(2), // |
| 3352 B(CreateClosure), U8(5), U8(0), // | 3336 B(CreateClosure), U8(5), U8(0), // |
| 3353 B(Star), R(3), // | 3337 B(Star), R(3), // |
| 3354 B(LdaZero), // | 3338 B(LdaZero), // |
| 3355 B(Star), R(4), // | 3339 B(Star), R(4), // |
| 3356 B(CallRuntime), U16(Runtime::kDefineSetterPropertyUnchecked), // | 3340 B(CallRuntime), U16(Runtime::kDefineSetterPropertyUnchecked), // |
| 3357 R(1), U8(4), // | 3341 R(1), U8(4), // |
| 3358 B(Ldar), R(1), // | 3342 B(Ldar), R(1), // |
| 3359 B(Return), // | 3343 B(Return), // |
| 3360 }, | 3344 }, |
| 3361 6, | 3345 6, |
| 3362 {InstanceType::ONE_BYTE_INTERNALIZED_STRING_TYPE, | 3346 {InstanceType::ONE_BYTE_INTERNALIZED_STRING_TYPE, |
| 3363 InstanceType::FIXED_ARRAY_TYPE, | 3347 InstanceType::FIXED_ARRAY_TYPE, |
| 3364 InstanceType::ONE_BYTE_INTERNALIZED_STRING_TYPE, | 3348 InstanceType::ONE_BYTE_INTERNALIZED_STRING_TYPE, |
| 3365 InstanceType::ONE_BYTE_INTERNALIZED_STRING_TYPE, | 3349 InstanceType::ONE_BYTE_INTERNALIZED_STRING_TYPE, |
| 3366 InstanceType::SHARED_FUNCTION_INFO_TYPE, | 3350 InstanceType::SHARED_FUNCTION_INFO_TYPE, |
| 3367 InstanceType::SHARED_FUNCTION_INFO_TYPE}}, | 3351 InstanceType::SHARED_FUNCTION_INFO_TYPE}}, |
| (...skipping 270 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3638 | 3622 |
| 3639 int closure = Register::function_closure().index(); | 3623 int closure = Register::function_closure().index(); |
| 3640 int first_context_slot = Context::MIN_CONTEXT_SLOTS; | 3624 int first_context_slot = Context::MIN_CONTEXT_SLOTS; |
| 3641 ExpectedSnippet<InstanceType> snippets[] = { | 3625 ExpectedSnippet<InstanceType> snippets[] = { |
| 3642 {"var a; return function() { a = 1; };", | 3626 {"var a; return function() { a = 1; };", |
| 3643 1 * kPointerSize, | 3627 1 * kPointerSize, |
| 3644 1, | 3628 1, |
| 3645 11, | 3629 11, |
| 3646 { | 3630 { |
| 3647 B(CallRuntime), U16(Runtime::kNewFunctionContext), // | 3631 B(CallRuntime), U16(Runtime::kNewFunctionContext), // |
| 3648 R(closure), U8(1), // | 3632 R(closure), U8(1), // |
| 3649 B(PushContext), R(0), // | 3633 B(PushContext), R(0), // |
| 3650 B(CreateClosure), U8(0), U8(0), // | 3634 B(CreateClosure), U8(0), U8(0), // |
| 3651 B(Return), // | 3635 B(Return), // |
| 3652 }, | 3636 }, |
| 3653 1, | 3637 1, |
| 3654 {InstanceType::SHARED_FUNCTION_INFO_TYPE}}, | 3638 {InstanceType::SHARED_FUNCTION_INFO_TYPE}}, |
| 3655 {"var a = 1; return function() { a = 2; };", | 3639 {"var a = 1; return function() { a = 2; };", |
| 3656 1 * kPointerSize, | 3640 1 * kPointerSize, |
| 3657 1, | 3641 1, |
| 3658 16, | 3642 16, |
| 3659 { | 3643 { |
| 3660 B(CallRuntime), U16(Runtime::kNewFunctionContext), // | 3644 B(CallRuntime), U16(Runtime::kNewFunctionContext), // |
| 3661 R(closure), U8(1), // | 3645 R(closure), U8(1), // |
| 3662 B(PushContext), R(0), // | 3646 B(PushContext), R(0), // |
| 3663 B(LdaSmi8), U8(1), // | 3647 B(LdaSmi8), U8(1), // |
| 3664 B(StaContextSlot), R(0), U8(first_context_slot), // | 3648 B(StaContextSlot), R(0), U8(first_context_slot), // |
| 3665 B(CreateClosure), U8(0), U8(0), // | 3649 B(CreateClosure), U8(0), U8(0), // |
| 3666 B(Return), // | 3650 B(Return), // |
| 3667 }, | 3651 }, |
| 3668 1, | 3652 1, |
| 3669 {InstanceType::SHARED_FUNCTION_INFO_TYPE}}, | 3653 {InstanceType::SHARED_FUNCTION_INFO_TYPE}}, |
| 3670 {"var a = 1; var b = 2; return function() { a = 2; b = 3 };", | 3654 {"var a = 1; var b = 2; return function() { a = 2; b = 3 };", |
| 3671 1 * kPointerSize, | 3655 1 * kPointerSize, |
| 3672 1, | 3656 1, |
| 3673 21, | 3657 21, |
| 3674 { | 3658 { |
| 3675 B(CallRuntime), U16(Runtime::kNewFunctionContext), // | 3659 B(CallRuntime), U16(Runtime::kNewFunctionContext), // |
| 3676 R(closure), U8(1), // | 3660 R(closure), U8(1), // |
| 3677 B(PushContext), R(0), // | 3661 B(PushContext), R(0), // |
| 3678 B(LdaSmi8), U8(1), // | 3662 B(LdaSmi8), U8(1), // |
| 3679 B(StaContextSlot), R(0), U8(first_context_slot), // | 3663 B(StaContextSlot), R(0), U8(first_context_slot), // |
| 3680 B(LdaSmi8), U8(2), // | 3664 B(LdaSmi8), U8(2), // |
| 3681 B(StaContextSlot), R(0), U8(first_context_slot + 1), // | 3665 B(StaContextSlot), R(0), U8(first_context_slot + 1), // |
| 3682 B(CreateClosure), U8(0), U8(0), // | 3666 B(CreateClosure), U8(0), U8(0), // |
| 3683 B(Return), // | 3667 B(Return), // |
| 3684 }, | 3668 }, |
| 3685 1, | 3669 1, |
| 3686 {InstanceType::SHARED_FUNCTION_INFO_TYPE}}, | 3670 {InstanceType::SHARED_FUNCTION_INFO_TYPE}}, |
| 3687 {"var a; (function() { a = 2; })(); return a;", | 3671 {"var a; (function() { a = 2; })(); return a;", |
| 3688 3 * kPointerSize, | 3672 3 * kPointerSize, |
| 3689 1, | 3673 1, |
| 3690 24, | 3674 24, |
| 3691 { | 3675 { |
| 3692 B(CallRuntime), U16(Runtime::kNewFunctionContext), // | 3676 B(CallRuntime), U16(Runtime::kNewFunctionContext), // |
| 3693 R(closure), U8(1), // | 3677 R(closure), U8(1), // |
| 3694 B(PushContext), R(0), // | 3678 B(PushContext), R(0), // |
| 3695 B(LdaUndefined), // | 3679 B(LdaUndefined), // |
| 3696 B(Star), R(2), // | 3680 B(Star), R(2), // |
| 3697 B(CreateClosure), U8(0), U8(0), // | 3681 B(CreateClosure), U8(0), U8(0), // |
| 3698 B(Star), R(1), // | 3682 B(Star), R(1), // |
| 3699 B(Call), R(1), R(2), U8(0), U8(vector->GetIndex(slot)), // | 3683 B(Call), R(1), R(2), U8(0), U8(vector->GetIndex(slot)), // |
| 3700 B(LdaContextSlot), R(0), U8(first_context_slot), // | 3684 B(LdaContextSlot), R(0), U8(first_context_slot), // |
| 3701 B(Return), // | 3685 B(Return), // |
| 3702 }, | 3686 }, |
| 3703 1, | 3687 1, |
| 3704 {InstanceType::SHARED_FUNCTION_INFO_TYPE}}, | 3688 {InstanceType::SHARED_FUNCTION_INFO_TYPE}}, |
| 3705 {"'use strict'; let a = 1; { let b = 2; return function() { a + b; }; }", | 3689 {"'use strict'; let a = 1; { let b = 2; return function() { a + b; }; }", |
| 3706 4 * kPointerSize, | 3690 4 * kPointerSize, |
| 3707 1, | 3691 1, |
| 3708 44, | 3692 44, |
| 3709 { | 3693 { |
| 3710 B(CallRuntime), U16(Runtime::kNewFunctionContext), // | 3694 B(CallRuntime), U16(Runtime::kNewFunctionContext), // |
| 3711 R(closure), U8(1), // | 3695 R(closure), U8(1), // |
| 3712 B(PushContext), R(0), // | 3696 B(PushContext), R(0), // |
| 3713 B(LdaTheHole), // | 3697 B(LdaTheHole), // |
| 3714 B(StaContextSlot), R(0), U8(first_context_slot), // | 3698 B(StaContextSlot), R(0), U8(first_context_slot), // |
| 3715 B(LdaSmi8), U8(1), // | 3699 B(LdaSmi8), U8(1), // |
| 3716 B(StaContextSlot), R(0), U8(first_context_slot), // | 3700 B(StaContextSlot), R(0), U8(first_context_slot), // |
| 3717 B(LdaConstant), U8(0), // | 3701 B(LdaConstant), U8(0), // |
| 3718 B(Star), R(2), // | 3702 B(Star), R(2), // |
| 3719 B(Ldar), R(closure), // | 3703 B(Ldar), R(closure), // |
| 3720 B(Star), R(3), // | 3704 B(Star), R(3), // |
| 3721 B(CallRuntime), U16(Runtime::kPushBlockContext), R(2), U8(2), // | 3705 B(CallRuntime), U16(Runtime::kPushBlockContext), R(2), U8(2), // |
| (...skipping 25 matching lines...) Expand all Loading... |
| 3747 int closure = Register::function_closure().index(); | 3731 int closure = Register::function_closure().index(); |
| 3748 int first_context_slot = Context::MIN_CONTEXT_SLOTS; | 3732 int first_context_slot = Context::MIN_CONTEXT_SLOTS; |
| 3749 | 3733 |
| 3750 ExpectedSnippet<InstanceType> snippets[] = { | 3734 ExpectedSnippet<InstanceType> snippets[] = { |
| 3751 {"function f(arg1) { return function() { arg1 = 2; }; }", | 3735 {"function f(arg1) { return function() { arg1 = 2; }; }", |
| 3752 1 * kPointerSize, | 3736 1 * kPointerSize, |
| 3753 2, | 3737 2, |
| 3754 16, | 3738 16, |
| 3755 { | 3739 { |
| 3756 B(CallRuntime), U16(Runtime::kNewFunctionContext), // | 3740 B(CallRuntime), U16(Runtime::kNewFunctionContext), // |
| 3757 R(closure), U8(1), // | 3741 R(closure), U8(1), // |
| 3758 B(PushContext), R(0), // | 3742 B(PushContext), R(0), // |
| 3759 B(Ldar), R(helper.kLastParamIndex), // | 3743 B(Ldar), R(helper.kLastParamIndex), // |
| 3760 B(StaContextSlot), R(0), U8(first_context_slot), // | 3744 B(StaContextSlot), R(0), U8(first_context_slot), // |
| 3761 B(CreateClosure), U8(0), U8(0), // | 3745 B(CreateClosure), U8(0), U8(0), // |
| 3762 B(Return), // | 3746 B(Return), // |
| 3763 }, | 3747 }, |
| 3764 1, | 3748 1, |
| 3765 {InstanceType::SHARED_FUNCTION_INFO_TYPE}}, | 3749 {InstanceType::SHARED_FUNCTION_INFO_TYPE}}, |
| 3766 {"function f(arg1) { var a = function() { arg1 = 2; }; return arg1; }", | 3750 {"function f(arg1) { var a = function() { arg1 = 2; }; return arg1; }", |
| 3767 2 * kPointerSize, | 3751 2 * kPointerSize, |
| 3768 2, | 3752 2, |
| 3769 21, | 3753 21, |
| 3770 { | 3754 { |
| 3771 B(CallRuntime), U16(Runtime::kNewFunctionContext), // | 3755 B(CallRuntime), U16(Runtime::kNewFunctionContext), // |
| 3772 R(closure), U8(1), // | 3756 R(closure), U8(1), // |
| 3773 B(PushContext), R(1), // | 3757 B(PushContext), R(1), // |
| 3774 B(Ldar), R(helper.kLastParamIndex), // | 3758 B(Ldar), R(helper.kLastParamIndex), // |
| 3775 B(StaContextSlot), R(1), U8(first_context_slot), // | 3759 B(StaContextSlot), R(1), U8(first_context_slot), // |
| 3776 B(CreateClosure), U8(0), U8(0), // | 3760 B(CreateClosure), U8(0), U8(0), // |
| 3777 B(Star), R(0), // | 3761 B(Star), R(0), // |
| 3778 B(LdaContextSlot), R(1), U8(first_context_slot), // | 3762 B(LdaContextSlot), R(1), U8(first_context_slot), // |
| 3779 B(Return), // | 3763 B(Return), // |
| 3780 }, | 3764 }, |
| 3781 1, | 3765 1, |
| 3782 {InstanceType::SHARED_FUNCTION_INFO_TYPE}}, | 3766 {InstanceType::SHARED_FUNCTION_INFO_TYPE}}, |
| 3783 {"function f(a1, a2, a3, a4) { return function() { a1 = a3; }; }", | 3767 {"function f(a1, a2, a3, a4) { return function() { a1 = a3; }; }", |
| 3784 1 * kPointerSize, | 3768 1 * kPointerSize, |
| 3785 5, | 3769 5, |
| 3786 21, | 3770 21, |
| 3787 { | 3771 { |
| 3788 B(CallRuntime), U16(Runtime::kNewFunctionContext), // | 3772 B(CallRuntime), U16(Runtime::kNewFunctionContext), // |
| 3789 R(closure), U8(1), // | 3773 R(closure), U8(1), // |
| 3790 B(PushContext), R(0), // | 3774 B(PushContext), R(0), // |
| 3791 B(Ldar), R(helper.kLastParamIndex - 3), // | 3775 B(Ldar), R(helper.kLastParamIndex - 3), // |
| 3792 B(StaContextSlot), R(0), U8(first_context_slot + 1), // | 3776 B(StaContextSlot), R(0), U8(first_context_slot + 1), // |
| 3793 B(Ldar), R(helper.kLastParamIndex -1), // | 3777 B(Ldar), R(helper.kLastParamIndex - 1), // |
| 3794 B(StaContextSlot), R(0), U8(first_context_slot), // | 3778 B(StaContextSlot), R(0), U8(first_context_slot), // |
| 3795 B(CreateClosure), U8(0), U8(0), // | 3779 B(CreateClosure), U8(0), U8(0), // |
| 3796 B(Return), // | 3780 B(Return), // |
| 3797 }, | 3781 }, |
| 3798 1, | 3782 1, |
| 3799 {InstanceType::SHARED_FUNCTION_INFO_TYPE}}, | 3783 {InstanceType::SHARED_FUNCTION_INFO_TYPE}}, |
| 3800 {"function f() { var self = this; return function() { self = 2; }; }", | 3784 {"function f() { var self = this; return function() { self = 2; }; }", |
| 3801 1 * kPointerSize, | 3785 1 * kPointerSize, |
| 3802 1, | 3786 1, |
| 3803 16, | 3787 16, |
| 3804 { | 3788 { |
| 3805 B(CallRuntime), U16(Runtime::kNewFunctionContext), // | 3789 B(CallRuntime), U16(Runtime::kNewFunctionContext), // |
| 3806 R(closure), U8(1), // | 3790 R(closure), U8(1), // |
| 3807 B(PushContext), R(0), // | 3791 B(PushContext), R(0), // |
| 3808 B(Ldar), R(helper.kLastParamIndex), // | 3792 B(Ldar), R(helper.kLastParamIndex), // |
| 3809 B(StaContextSlot), R(0), U8(first_context_slot), // | 3793 B(StaContextSlot), R(0), U8(first_context_slot), // |
| 3810 B(CreateClosure), U8(0), U8(0), // | 3794 B(CreateClosure), U8(0), U8(0), // |
| 3811 B(Return), // | 3795 B(Return), // |
| 3812 }, | 3796 }, |
| 3813 1, | 3797 1, |
| 3814 {InstanceType::SHARED_FUNCTION_INFO_TYPE}}, | 3798 {InstanceType::SHARED_FUNCTION_INFO_TYPE}}, |
| 3815 }; | 3799 }; |
| 3816 | 3800 |
| (...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4041 }, | 4025 }, |
| 4042 2, | 4026 2, |
| 4043 {InstanceType::ONE_BYTE_INTERNALIZED_STRING_TYPE, | 4027 {InstanceType::ONE_BYTE_INTERNALIZED_STRING_TYPE, |
| 4044 InstanceType::FIXED_ARRAY_TYPE}}, | 4028 InstanceType::FIXED_ARRAY_TYPE}}, |
| 4045 {"var a = 1; var b = function() { return a }; return ++a;", | 4029 {"var a = 1; var b = function() { return a }; return ++a;", |
| 4046 2 * kPointerSize, | 4030 2 * kPointerSize, |
| 4047 1, | 4031 1, |
| 4048 26, | 4032 26, |
| 4049 { | 4033 { |
| 4050 B(CallRuntime), U16(Runtime::kNewFunctionContext), R(closure), // | 4034 B(CallRuntime), U16(Runtime::kNewFunctionContext), R(closure), // |
| 4051 U8(1), // | 4035 U8(1), // |
| 4052 B(PushContext), R(1), // | 4036 B(PushContext), R(1), // |
| 4053 B(LdaSmi8), U8(1), // | 4037 B(LdaSmi8), U8(1), // |
| 4054 B(StaContextSlot), R(1), U8(first_context_slot), // | 4038 B(StaContextSlot), R(1), U8(first_context_slot), // |
| 4055 B(CreateClosure), U8(0), U8(0), // | 4039 B(CreateClosure), U8(0), U8(0), // |
| 4056 B(Star), R(0), // | 4040 B(Star), R(0), // |
| 4057 B(LdaContextSlot), R(1), U8(first_context_slot), // | 4041 B(LdaContextSlot), R(1), U8(first_context_slot), // |
| 4058 B(ToNumber), // | 4042 B(ToNumber), // |
| 4059 B(Inc), // | 4043 B(Inc), // |
| 4060 B(StaContextSlot), R(1), U8(first_context_slot), // | 4044 B(StaContextSlot), R(1), U8(first_context_slot), // |
| 4061 B(Return), // | 4045 B(Return), // |
| 4062 }, | 4046 }, |
| 4063 1, | 4047 1, |
| 4064 {InstanceType::SHARED_FUNCTION_INFO_TYPE}}, | 4048 {InstanceType::SHARED_FUNCTION_INFO_TYPE}}, |
| 4065 {"var a = 1; var b = function() { return a }; return a--;", | 4049 {"var a = 1; var b = function() { return a }; return a--;", |
| 4066 3 * kPointerSize, | 4050 3 * kPointerSize, |
| 4067 1, | 4051 1, |
| 4068 30, | 4052 30, |
| 4069 { | 4053 { |
| 4070 B(CallRuntime), U16(Runtime::kNewFunctionContext), R(closure), // | 4054 B(CallRuntime), U16(Runtime::kNewFunctionContext), R(closure), // |
| 4071 U8(1), // | 4055 U8(1), // |
| 4072 B(PushContext), R(1), // | 4056 B(PushContext), R(1), // |
| 4073 B(LdaSmi8), U8(1), // | 4057 B(LdaSmi8), U8(1), // |
| 4074 B(StaContextSlot), R(1), U8(first_context_slot), // | 4058 B(StaContextSlot), R(1), U8(first_context_slot), // |
| 4075 B(CreateClosure), U8(0), U8(0), // | 4059 B(CreateClosure), U8(0), U8(0), // |
| 4076 B(Star), R(0), // | 4060 B(Star), R(0), // |
| 4077 B(LdaContextSlot), R(1), U8(first_context_slot), // | 4061 B(LdaContextSlot), R(1), U8(first_context_slot), // |
| 4078 B(ToNumber), // | 4062 B(ToNumber), // |
| 4079 B(Star), R(2), // | 4063 B(Star), R(2), // |
| 4080 B(Dec), // | 4064 B(Dec), // |
| 4081 B(StaContextSlot), R(1), U8(first_context_slot), // | 4065 B(StaContextSlot), R(1), U8(first_context_slot), // |
| 4082 B(Ldar), R(2), // | 4066 B(Ldar), R(2), // |
| 4083 B(Return), // | 4067 B(Return), // |
| 4084 }, | 4068 }, |
| 4085 1, | 4069 1, |
| 4086 {InstanceType::SHARED_FUNCTION_INFO_TYPE}}, | 4070 {InstanceType::SHARED_FUNCTION_INFO_TYPE}}, |
| 4087 {"var idx = 1; var a = [1, 2]; return a[idx++] = 2;", | 4071 {"var idx = 1; var a = [1, 2]; return a[idx++] = 2;", |
| 4088 3 * kPointerSize, | 4072 3 * kPointerSize, |
| 4089 1, | 4073 1, |
| 4090 26, | 4074 26, |
| 4091 { | 4075 { |
| 4092 B(LdaSmi8), U8(1), // | 4076 B(LdaSmi8), U8(1), // |
| 4093 B(Star), R(0), // | 4077 B(Star), R(0), // |
| 4094 B(LdaConstant), U8(0), // | 4078 B(LdaConstant), U8(0), // |
| 4095 B(CreateArrayLiteral), U8(0), U8(array_literal_flags), // | 4079 B(CreateArrayLiteral), U8(0), U8(array_literal_flags), // |
| 4096 B(Star), R(1), // | 4080 B(Star), R(1), // |
| 4097 B(Ldar), R(0), // | 4081 B(Ldar), R(0), // |
| 4098 B(ToNumber), // | 4082 B(ToNumber), // |
| 4099 B(Star), R(2), // | 4083 B(Star), R(2), // |
| 4100 B(Inc), // | 4084 B(Inc), // |
| 4101 B(Star), R(0), // | 4085 B(Star), R(0), // |
| 4102 B(LdaSmi8), U8(2), // | 4086 B(LdaSmi8), U8(2), // |
| 4103 B(KeyedStoreICSloppy), R(1), R(2), // | 4087 B(KeyedStoreICSloppy), R(1), R(2), // |
| 4104 U8(store_vector->GetIndex(store_slot)), // | 4088 U8(store_vector->GetIndex(store_slot)), // |
| 4105 B(Return), // | 4089 B(Return), // |
| 4106 }, | 4090 }, |
| 4107 1, | 4091 1, |
| 4108 {InstanceType::FIXED_ARRAY_TYPE}}, | 4092 {InstanceType::FIXED_ARRAY_TYPE}}, |
| 4109 }; | 4093 }; |
| 4110 | 4094 |
| 4111 for (size_t i = 0; i < arraysize(snippets); i++) { | 4095 for (size_t i = 0; i < arraysize(snippets); i++) { |
| 4112 Handle<BytecodeArray> bytecode_array = | 4096 Handle<BytecodeArray> bytecode_array = |
| 4113 helper.MakeBytecodeForFunctionBody(snippets[i].code_snippet); | 4097 helper.MakeBytecodeForFunctionBody(snippets[i].code_snippet); |
| 4114 CheckBytecodeArrayEqual(snippets[i], bytecode_array); | 4098 CheckBytecodeArrayEqual(snippets[i], bytecode_array); |
| 4115 } | 4099 } |
| (...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4278 B(Return), // | 4262 B(Return), // |
| 4279 }, | 4263 }, |
| 4280 1, | 4264 1, |
| 4281 {InstanceType::FIXED_ARRAY_TYPE}}, | 4265 {InstanceType::FIXED_ARRAY_TYPE}}, |
| 4282 {"var a = 1; (function f() { return a; }); a |= 24;", | 4266 {"var a = 1; (function f() { return a; }); a |= 24;", |
| 4283 2 * kPointerSize, | 4267 2 * kPointerSize, |
| 4284 1, | 4268 1, |
| 4285 29, | 4269 29, |
| 4286 { | 4270 { |
| 4287 B(CallRuntime), U16(Runtime::kNewFunctionContext), R(closure), // | 4271 B(CallRuntime), U16(Runtime::kNewFunctionContext), R(closure), // |
| 4288 U8(1), // | 4272 U8(1), // |
| 4289 B(PushContext), R(0), // | 4273 B(PushContext), R(0), // |
| 4290 B(LdaSmi8), U8(1), // | 4274 B(LdaSmi8), U8(1), // |
| 4291 B(StaContextSlot), R(0), U8(first_context_slot), // | 4275 B(StaContextSlot), R(0), U8(first_context_slot), // |
| 4292 B(CreateClosure), U8(0), U8(0), // | 4276 B(CreateClosure), U8(0), U8(0), // |
| 4293 B(LdaContextSlot), R(0), U8(first_context_slot), // | 4277 B(LdaContextSlot), R(0), U8(first_context_slot), // |
| 4294 B(Star), R(1), // | 4278 B(Star), R(1), // |
| 4295 B(LdaSmi8), U8(24), // | 4279 B(LdaSmi8), U8(24), // |
| 4296 B(BitwiseOr), R(1), // | 4280 B(BitwiseOr), R(1), // |
| 4297 B(StaContextSlot), R(0), U8(first_context_slot), // | 4281 B(StaContextSlot), R(0), U8(first_context_slot), // |
| 4298 B(LdaUndefined), // | 4282 B(LdaUndefined), // |
| (...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4404 B(CreateUnmappedArguments), // | 4388 B(CreateUnmappedArguments), // |
| 4405 B(Star), R(0), // | 4389 B(Star), R(0), // |
| 4406 B(Return), // | 4390 B(Return), // |
| 4407 }}, | 4391 }}, |
| 4408 {"function f(a) { return arguments[0]; }", | 4392 {"function f(a) { return arguments[0]; }", |
| 4409 2 * kPointerSize, | 4393 2 * kPointerSize, |
| 4410 2, | 4394 2, |
| 4411 20, | 4395 20, |
| 4412 { | 4396 { |
| 4413 B(CallRuntime), U16(Runtime::kNewFunctionContext), R(closure), // | 4397 B(CallRuntime), U16(Runtime::kNewFunctionContext), R(closure), // |
| 4414 U8(1), // | 4398 U8(1), // |
| 4415 B(PushContext), R(1), // | 4399 B(PushContext), R(1), // |
| 4416 B(Ldar), R(BytecodeGeneratorHelper::kLastParamIndex), // | 4400 B(Ldar), R(BytecodeGeneratorHelper::kLastParamIndex), // |
| 4417 B(StaContextSlot), R(1), U8(first_context_slot), // | 4401 B(StaContextSlot), R(1), U8(first_context_slot), // |
| 4418 B(CreateMappedArguments), // | 4402 B(CreateMappedArguments), // |
| 4419 B(Star), R(0), // | 4403 B(Star), R(0), // |
| 4420 B(LdaZero), // | 4404 B(LdaZero), // |
| 4421 B(KeyedLoadICSloppy), R(0), U8(vector->GetIndex(slot)), // | 4405 B(KeyedLoadICSloppy), R(0), U8(vector->GetIndex(slot)), // |
| 4422 B(Return), // | 4406 B(Return), // |
| 4423 }}, | 4407 }}, |
| 4424 {"function f(a, b, c) { return arguments; }", | 4408 {"function f(a, b, c) { return arguments; }", |
| 4425 2 * kPointerSize, | 4409 2 * kPointerSize, |
| 4426 4, | 4410 4, |
| 4427 26, | 4411 26, |
| 4428 { | 4412 { |
| 4429 B(CallRuntime), U16(Runtime::kNewFunctionContext), R(closure), // | 4413 B(CallRuntime), U16(Runtime::kNewFunctionContext), R(closure), // |
| 4430 U8(1), // | 4414 U8(1), // |
| 4431 B(PushContext), R(1), // | 4415 B(PushContext), R(1), // |
| 4432 B(Ldar), R(BytecodeGeneratorHelper::kLastParamIndex - 2), // | 4416 B(Ldar), R(BytecodeGeneratorHelper::kLastParamIndex - 2), // |
| 4433 B(StaContextSlot), R(1), U8(first_context_slot + 2), // | 4417 B(StaContextSlot), R(1), U8(first_context_slot + 2), // |
| 4434 B(Ldar), R(BytecodeGeneratorHelper::kLastParamIndex - 1), // | 4418 B(Ldar), R(BytecodeGeneratorHelper::kLastParamIndex - 1), // |
| 4435 B(StaContextSlot), R(1), U8(first_context_slot + 1), // | 4419 B(StaContextSlot), R(1), U8(first_context_slot + 1), // |
| 4436 B(Ldar), R(BytecodeGeneratorHelper::kLastParamIndex), // | 4420 B(Ldar), R(BytecodeGeneratorHelper::kLastParamIndex), // |
| 4437 B(StaContextSlot), R(1), U8(first_context_slot), // | 4421 B(StaContextSlot), R(1), U8(first_context_slot), // |
| 4438 B(CreateMappedArguments), // | 4422 B(CreateMappedArguments), // |
| 4439 B(Star), R(0), // | 4423 B(Star), R(0), // |
| 4440 B(Return), // | 4424 B(Return), // |
| (...skipping 463 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4904 B(Star), R(1), // | 4888 B(Star), R(1), // |
| 4905 B(Jump), U8(8), // | 4889 B(Jump), U8(8), // |
| 4906 B(LdaSmi8), U8(2), // | 4890 B(LdaSmi8), U8(2), // |
| 4907 B(Star), R(1), // | 4891 B(Star), R(1), // |
| 4908 B(Jump), U8(2), // | 4892 B(Jump), U8(2), // |
| 4909 B(LdaUndefined), // | 4893 B(LdaUndefined), // |
| 4910 B(Return), // | 4894 B(Return), // |
| 4911 }}, | 4895 }}, |
| 4912 {"var a = 1;\n" | 4896 {"var a = 1;\n" |
| 4913 "switch(a) {\n" | 4897 "switch(a) {\n" |
| 4914 " case 1:\n" REPEAT_64(SPACE, " a = 2;") | 4898 " case 1:\n" REPEAT_64(SPACE, " a = 2;") "break;\n" |
| 4915 "break;\n" | 4899 " case 2: a = 3; break;" |
| 4916 " case 2: a = 3; break;" | 4900 "}\n", |
| 4917 "}\n", | |
| 4918 2 * kPointerSize, | 4901 2 * kPointerSize, |
| 4919 1, | 4902 1, |
| 4920 286, | 4903 286, |
| 4921 { | 4904 { |
| 4922 B(LdaSmi8), U8(1), // | 4905 B(LdaSmi8), U8(1), // |
| 4923 B(Star), R(1), // | 4906 B(Star), R(1), // |
| 4924 B(Star), R(0), // | 4907 B(Star), R(0), // |
| 4925 B(LdaSmi8), U8(1), // | 4908 B(LdaSmi8), U8(1), // |
| 4926 B(TestEqualStrict), R(0), // | 4909 B(TestEqualStrict), R(0), // |
| 4927 B(JumpIfTrue), U8(10), // | 4910 B(JumpIfTrue), U8(10), // |
| 4928 B(LdaSmi8), U8(2), // | 4911 B(LdaSmi8), U8(2), // |
| 4929 B(TestEqualStrict), R(0), // | 4912 B(TestEqualStrict), R(0), // |
| 4930 B(JumpIfTrueConstant), U8(0), // | 4913 B(JumpIfTrueConstant), U8(0), // |
| 4931 B(JumpConstant), U8(1), // | 4914 B(JumpConstant), U8(1), // |
| 4932 REPEAT_64(COMMA, // | 4915 REPEAT_64(COMMA, // |
| 4933 B(LdaSmi8), U8(2), // | 4916 B(LdaSmi8), U8(2), // |
| 4934 B(Star), R(1)), // | 4917 B(Star), R(1)), // |
| 4935 B(Jump), U8(8), // | 4918 B(Jump), |
| 4936 B(LdaSmi8), U8(3), // | 4919 U8(8), // |
| 4937 B(Star), R(1), // | 4920 B(LdaSmi8), U8(3), // |
| 4938 B(Jump), U8(2), // | 4921 B(Star), R(1), // |
| 4939 B(LdaUndefined), // | 4922 B(Jump), U8(2), // |
| 4940 B(Return), // | 4923 B(LdaUndefined), // |
| 4924 B(Return), // |
| 4941 }, | 4925 }, |
| 4942 2, | 4926 2, |
| 4943 {262, 266}}, | 4927 {262, 266}}, |
| 4944 {"var a = 1;\n" | 4928 {"var a = 1;\n" |
| 4945 "switch(a) {\n" | 4929 "switch(a) {\n" |
| 4946 " case 1: \n" | 4930 " case 1: \n" |
| 4947 " switch(a + 1) {\n" | 4931 " switch(a + 1) {\n" |
| 4948 " case 2 : a = 1; break;\n" | 4932 " case 2 : a = 1; break;\n" |
| 4949 " default : a = 2; break;\n" | 4933 " default : a = 2; break;\n" |
| 4950 " } // fall-through\n" | 4934 " } // fall-through\n" |
| (...skipping 236 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5187 CheckBytecodeArrayEqual(snippets[i], bytecode_array); | 5171 CheckBytecodeArrayEqual(snippets[i], bytecode_array); |
| 5188 } | 5172 } |
| 5189 } | 5173 } |
| 5190 | 5174 |
| 5191 | 5175 |
| 5192 TEST(RemoveRedundantLdar) { | 5176 TEST(RemoveRedundantLdar) { |
| 5193 InitializedHandleScope handle_scope; | 5177 InitializedHandleScope handle_scope; |
| 5194 BytecodeGeneratorHelper helper; | 5178 BytecodeGeneratorHelper helper; |
| 5195 | 5179 |
| 5196 ExpectedSnippet<int> snippets[] = { | 5180 ExpectedSnippet<int> snippets[] = { |
| 5197 {"var ld_a = 1;\n" // This test is to check Ldar does not | 5181 {"var ld_a = 1;\n" // This test is to check Ldar does not |
| 5198 "while(true) {\n" // get removed if the preceding Star is | 5182 "while(true) {\n" // get removed if the preceding Star is |
| 5199 " ld_a = ld_a + ld_a;\n" // in a different basicblock. | 5183 " ld_a = ld_a + ld_a;\n" // in a different basicblock. |
| 5200 " if (ld_a > 10) break;\n" | 5184 " if (ld_a > 10) break;\n" |
| 5201 "}\n" | 5185 "}\n" |
| 5202 "return ld_a;", | 5186 "return ld_a;", |
| 5203 1 * kPointerSize, | 5187 1 * kPointerSize, |
| 5204 1, | 5188 1, |
| 5205 23, | 5189 23, |
| 5206 { | 5190 {B(LdaSmi8), U8(1), // |
| 5207 B(LdaSmi8), U8(1), // | 5191 B(Star), R(0), // |
| 5208 B(Star), R(0), // | 5192 B(Ldar), R(0), // This load should not be removed as it |
| 5209 B(Ldar), R(0), // This load should not be removed as it | 5193 B(Add), R(0), // is the target of the branch. |
| 5210 B(Add), R(0), // is the target of the branch. | 5194 B(Star), R(0), // |
| 5211 B(Star), R(0), // | 5195 B(LdaSmi8), U8(10), // |
| 5212 B(LdaSmi8), U8(10), // | 5196 B(TestGreaterThan), R(0), // |
| 5213 B(TestGreaterThan), R(0), // | 5197 B(JumpIfFalse), U8(4), // |
| 5214 B(JumpIfFalse), U8(4), // | 5198 B(Jump), U8(4), // |
| 5215 B(Jump), U8(4), // | 5199 B(Jump), U8(-14), // |
| 5216 B(Jump), U8(-14), // | 5200 B(Ldar), R(0), // |
| 5217 B(Ldar), R(0), // | 5201 B(Return)}}, |
| 5218 B(Return) | |
| 5219 }}, | |
| 5220 {"var ld_a = 1;\n" | 5202 {"var ld_a = 1;\n" |
| 5221 "do {\n" | 5203 "do {\n" |
| 5222 " ld_a = ld_a + ld_a;\n" | 5204 " ld_a = ld_a + ld_a;\n" |
| 5223 " if (ld_a > 10) continue;\n" | 5205 " if (ld_a > 10) continue;\n" |
| 5224 "} while(false);\n" | 5206 "} while(false);\n" |
| 5225 "return ld_a;", | 5207 "return ld_a;", |
| 5226 1 * kPointerSize, | 5208 1 * kPointerSize, |
| 5227 1, | 5209 1, |
| 5228 19, | 5210 19, |
| 5229 { | 5211 {B(LdaSmi8), U8(1), // |
| 5230 B(LdaSmi8), U8(1), // | 5212 B(Star), R(0), // |
| 5231 B(Star), R(0), // | 5213 B(Add), R(0), // |
| 5232 B(Add), R(0), // | 5214 B(Star), R(0), // |
| 5233 B(Star), R(0), // | 5215 B(LdaSmi8), U8(10), // |
| 5234 B(LdaSmi8), U8(10), // | 5216 B(TestGreaterThan), R(0), // |
| 5235 B(TestGreaterThan), R(0), // | 5217 B(JumpIfFalse), U8(4), // |
| 5236 B(JumpIfFalse), U8(4), // | 5218 B(Jump), U8(2), // |
| 5237 B(Jump), U8(2), // | 5219 B(Ldar), R(0), // |
| 5238 B(Ldar), R(0), // | 5220 B(Return)}}, |
| 5239 B(Return) | |
| 5240 }}, | |
| 5241 }; | 5221 }; |
| 5242 | 5222 |
| 5243 for (size_t i = 0; i < arraysize(snippets); i++) { | 5223 for (size_t i = 0; i < arraysize(snippets); i++) { |
| 5244 Handle<BytecodeArray> bytecode_array = | 5224 Handle<BytecodeArray> bytecode_array = |
| 5245 helper.MakeBytecodeForFunctionBody(snippets[i].code_snippet); | 5225 helper.MakeBytecodeForFunctionBody(snippets[i].code_snippet); |
| 5246 CheckBytecodeArrayEqual(snippets[i], bytecode_array); | 5226 CheckBytecodeArrayEqual(snippets[i], bytecode_array); |
| 5247 } | 5227 } |
| 5248 } | 5228 } |
| 5249 | 5229 |
| 5250 | 5230 |
| (...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5462 for (size_t i = 0; i < arraysize(snippets); i++) { | 5442 for (size_t i = 0; i < arraysize(snippets); i++) { |
| 5463 Handle<BytecodeArray> bytecode_array = | 5443 Handle<BytecodeArray> bytecode_array = |
| 5464 helper.MakeBytecodeForFunctionBody(snippets[i].code_snippet); | 5444 helper.MakeBytecodeForFunctionBody(snippets[i].code_snippet); |
| 5465 CheckBytecodeArrayEqual(snippets[i], bytecode_array); | 5445 CheckBytecodeArrayEqual(snippets[i], bytecode_array); |
| 5466 } | 5446 } |
| 5467 } | 5447 } |
| 5468 | 5448 |
| 5469 } // namespace interpreter | 5449 } // namespace interpreter |
| 5470 } // namespace internal | 5450 } // namespace internal |
| 5471 } // namespace v8 | 5451 } // namespace v8 |
| OLD | NEW |