| 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 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 68 SNPrintF(program, "%s\n%s();", function, kFunctionName); | 68 SNPrintF(program, "%s\n%s();", function, kFunctionName); |
| 69 return MakeBytecode(program.start(), kFunctionName); | 69 return MakeBytecode(program.start(), kFunctionName); |
| 70 } | 70 } |
| 71 }; | 71 }; |
| 72 | 72 |
| 73 | 73 |
| 74 // Helper macros for handcrafting bytecode sequences. | 74 // Helper macros for handcrafting bytecode sequences. |
| 75 #define B(x) static_cast<uint8_t>(Bytecode::k##x) | 75 #define B(x) static_cast<uint8_t>(Bytecode::k##x) |
| 76 #define U8(x) static_cast<uint8_t>((x) & 0xff) | 76 #define U8(x) static_cast<uint8_t>((x) & 0xff) |
| 77 #define R(x) static_cast<uint8_t>(-(x) & 0xff) | 77 #define R(x) static_cast<uint8_t>(-(x) & 0xff) |
| 78 #define A(x, n) R(helper.kLastParamIndex - (n) + 1 + (x)) |
| 79 #define THIS(n) A(0, n) |
| 78 #define _ static_cast<uint8_t>(0x5a) | 80 #define _ static_cast<uint8_t>(0x5a) |
| 79 #if defined(V8_TARGET_LITTLE_ENDIAN) | 81 #if defined(V8_TARGET_LITTLE_ENDIAN) |
| 80 #define U16(x) static_cast<uint8_t>((x) & 0xff), \ | 82 #define U16(x) static_cast<uint8_t>((x) & 0xff), \ |
| 81 static_cast<uint8_t>(((x) >> kBitsPerByte) & 0xff) | 83 static_cast<uint8_t>(((x) >> kBitsPerByte) & 0xff) |
| 82 #elif defined(V8_TARGET_BIG_ENDIAN) | 84 #elif defined(V8_TARGET_BIG_ENDIAN) |
| 83 #define U16(x) static_cast<uint8_t>(((x) >> kBitsPerByte) & 0xff), \ | 85 #define U16(x) static_cast<uint8_t>(((x) >> kBitsPerByte) & 0xff), \ |
| 84 static_cast<uint8_t>((x) & 0xff) | 86 static_cast<uint8_t>((x) & 0xff) |
| 85 #else | 87 #else |
| 86 #error Unknown byte ordering | 88 #error Unknown byte ordering |
| 87 #endif | 89 #endif |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 121 CHECK(actual == *expected || expected->StrictEquals(actual)); | 123 CHECK(actual == *expected || expected->StrictEquals(actual)); |
| 122 } | 124 } |
| 123 | 125 |
| 124 | 126 |
| 125 static void CheckConstant(InstanceType expected, Object* actual) { | 127 static void CheckConstant(InstanceType expected, Object* actual) { |
| 126 CHECK_EQ(expected, HeapObject::cast(actual)->map()->instance_type()); | 128 CHECK_EQ(expected, HeapObject::cast(actual)->map()->instance_type()); |
| 127 } | 129 } |
| 128 | 130 |
| 129 | 131 |
| 130 template <typename T> | 132 template <typename T> |
| 131 static void CheckBytecodeArrayEqual(struct ExpectedSnippet<T> expected, | 133 static void CheckBytecodeArrayEqual(const ExpectedSnippet<T>& expected, |
| 132 Handle<BytecodeArray> actual, | 134 Handle<BytecodeArray> actual, |
| 133 bool has_unknown = false) { | 135 bool has_unknown = false) { |
| 134 CHECK_EQ(actual->frame_size(), expected.frame_size); | 136 CHECK_EQ(actual->frame_size(), expected.frame_size); |
| 135 CHECK_EQ(actual->parameter_count(), expected.parameter_count); | 137 CHECK_EQ(actual->parameter_count(), expected.parameter_count); |
| 136 CHECK_EQ(actual->length(), expected.bytecode_length); | 138 CHECK_EQ(actual->length(), expected.bytecode_length); |
| 137 if (expected.constant_count == 0) { | 139 if (expected.constant_count == 0) { |
| 138 CHECK_EQ(actual->constant_pool(), CcTest::heap()->empty_fixed_array()); | 140 CHECK_EQ(actual->constant_pool(), CcTest::heap()->empty_fixed_array()); |
| 139 } else { | 141 } else { |
| 140 CHECK_EQ(actual->constant_pool()->length(), expected.constant_count); | 142 CHECK_EQ(actual->constant_pool()->length(), expected.constant_count); |
| 141 for (int i = 0; i < expected.constant_count; i++) { | 143 for (int i = 0; i < expected.constant_count; i++) { |
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 233 {"var x = 0; return x;", | 235 {"var x = 0; return x;", |
| 234 kPointerSize, | 236 kPointerSize, |
| 235 1, | 237 1, |
| 236 6, | 238 6, |
| 237 {B(LdaZero), // | 239 {B(LdaZero), // |
| 238 B(Star), R(0), // | 240 B(Star), R(0), // |
| 239 B(Ldar), R(0), // | 241 B(Ldar), R(0), // |
| 240 B(Return)}, | 242 B(Return)}, |
| 241 0}, | 243 0}, |
| 242 {"var x = 0; return x + 3;", | 244 {"var x = 0; return x + 3;", |
| 243 2 * kPointerSize, | 245 kPointerSize, |
| 244 1, | |
| 245 12, | |
| 246 {B(LdaZero), // | |
| 247 B(Star), R(0), // | |
| 248 B(Ldar), R(0), // Easy to spot r1 not really needed here. | |
| 249 B(Star), R(1), // Dead store. | |
| 250 B(LdaSmi8), U8(3), // | |
| 251 B(Add), R(1), // | |
| 252 B(Return)}, | |
| 253 0}, | |
| 254 {"var x = 0; return x - 3;", | |
| 255 2 * kPointerSize, | |
| 256 1, | |
| 257 12, | |
| 258 {B(LdaZero), // | |
| 259 B(Star), R(0), // | |
| 260 B(Ldar), R(0), // Easy to spot r1 not really needed here. | |
| 261 B(Star), R(1), // Dead store. | |
| 262 B(LdaSmi8), U8(3), // | |
| 263 B(Sub), R(1), // | |
| 264 B(Return)}, | |
| 265 0}, | |
| 266 {"var x = 4; return x * 3;", | |
| 267 2 * kPointerSize, | |
| 268 1, | |
| 269 13, | |
| 270 {B(LdaSmi8), U8(4), // | |
| 271 B(Star), R(0), // | |
| 272 B(Ldar), R(0), // Easy to spot r1 not really needed here. | |
| 273 B(Star), R(1), // Dead store. | |
| 274 B(LdaSmi8), U8(3), // | |
| 275 B(Mul), R(1), // | |
| 276 B(Return)}, | |
| 277 0}, | |
| 278 {"var x = 4; return x / 3;", | |
| 279 2 * kPointerSize, | |
| 280 1, | |
| 281 13, | |
| 282 {B(LdaSmi8), U8(4), // | |
| 283 B(Star), R(0), // | |
| 284 B(Ldar), R(0), // Easy to spot r1 not really needed here. | |
| 285 B(Star), R(1), // Dead store. | |
| 286 B(LdaSmi8), U8(3), // | |
| 287 B(Div), R(1), // | |
| 288 B(Return)}, | |
| 289 0}, | |
| 290 {"var x = 4; return x % 3;", | |
| 291 2 * kPointerSize, | |
| 292 1, | |
| 293 13, | |
| 294 {B(LdaSmi8), U8(4), // | |
| 295 B(Star), R(0), // | |
| 296 B(Ldar), R(0), // Easy to spot r1 not really needed here. | |
| 297 B(Star), R(1), // Dead store. | |
| 298 B(LdaSmi8), U8(3), // | |
| 299 B(Mod), R(1), // | |
| 300 B(Return)}, | |
| 301 0}, | |
| 302 {"var x = 1; return x | 2;", | |
| 303 2 * kPointerSize, | |
| 304 1, | |
| 305 13, | |
| 306 {B(LdaSmi8), U8(1), // | |
| 307 B(Star), R(0), // | |
| 308 B(Ldar), R(0), // Easy to spot r1 not really needed here. | |
| 309 B(Star), R(1), // Dead store. | |
| 310 B(LdaSmi8), U8(2), // | |
| 311 B(BitwiseOr), R(1), // | |
| 312 B(Return)}, | |
| 313 0}, | |
| 314 {"var x = 1; return x ^ 2;", | |
| 315 2 * kPointerSize, | |
| 316 1, | |
| 317 13, | |
| 318 {B(LdaSmi8), U8(1), // | |
| 319 B(Star), R(0), // | |
| 320 B(Ldar), R(0), // Easy to spot r1 not really needed here. | |
| 321 B(Star), R(1), // Dead store. | |
| 322 B(LdaSmi8), U8(2), // | |
| 323 B(BitwiseXor), R(1), // | |
| 324 B(Return)}, | |
| 325 0}, | |
| 326 {"var x = 1; return x & 2;", | |
| 327 2 * kPointerSize, | |
| 328 1, | |
| 329 13, | |
| 330 {B(LdaSmi8), U8(1), // | |
| 331 B(Star), R(0), // | |
| 332 B(Ldar), R(0), // Easy to spot r1 not really needed here. | |
| 333 B(Star), R(1), // Dead store. | |
| 334 B(LdaSmi8), U8(2), // | |
| 335 B(BitwiseAnd), R(1), // | |
| 336 B(Return)}, | |
| 337 0}, | |
| 338 {"var x = 10; return x << 3;", | |
| 339 2 * kPointerSize, | |
| 340 1, | |
| 341 13, | |
| 342 {B(LdaSmi8), U8(10), // | |
| 343 B(Star), R(0), // | |
| 344 B(Ldar), R(0), // Easy to spot r1 not really needed here. | |
| 345 B(Star), R(1), // Dead store. | |
| 346 B(LdaSmi8), U8(3), // | |
| 347 B(ShiftLeft), R(1), // | |
| 348 B(Return)}, | |
| 349 0}, | |
| 350 {"var x = 10; return x >> 3;", | |
| 351 2 * kPointerSize, | |
| 352 1, | |
| 353 13, | |
| 354 {B(LdaSmi8), U8(10), // | |
| 355 B(Star), R(0), // | |
| 356 B(Ldar), R(0), // Easy to spot r1 not really needed here. | |
| 357 B(Star), R(1), // Dead store. | |
| 358 B(LdaSmi8), U8(3), // | |
| 359 B(ShiftRight), R(1), // | |
| 360 B(Return)}, | |
| 361 0}, | |
| 362 {"var x = 10; return x >>> 3;", | |
| 363 2 * kPointerSize, | |
| 364 1, | |
| 365 13, | |
| 366 {B(LdaSmi8), U8(10), // | |
| 367 B(Star), R(0), // | |
| 368 B(Ldar), R(0), // Easy to spot r1 not really needed here. | |
| 369 B(Star), R(1), // Dead store. | |
| 370 B(LdaSmi8), U8(3), // | |
| 371 B(ShiftRightLogical), R(1), // | |
| 372 B(Return)}, | |
| 373 0}, | |
| 374 {"var x = 0; return (x, 3);", | |
| 375 1 * kPointerSize, | |
| 376 1, | 246 1, |
| 377 8, | 247 8, |
| 378 {B(LdaZero), // | 248 {B(LdaZero), // |
| 379 B(Star), R(0), // | 249 B(Star), R(0), // |
| 380 B(Ldar), R(0), // | 250 B(LdaSmi8), U8(3), // |
| 251 B(Add), R(0), // |
| 252 B(Return)}, |
| 253 0}, |
| 254 {"var x = 0; return x - 3;", |
| 255 kPointerSize, |
| 256 1, |
| 257 8, |
| 258 {B(LdaZero), // |
| 259 B(Star), R(0), // |
| 260 B(LdaSmi8), U8(3), // |
| 261 B(Sub), R(0), // |
| 262 B(Return)}, |
| 263 0}, |
| 264 {"var x = 4; return x * 3;", |
| 265 kPointerSize, |
| 266 1, |
| 267 9, |
| 268 {B(LdaSmi8), U8(4), // |
| 269 B(Star), R(0), // |
| 270 B(LdaSmi8), U8(3), // |
| 271 B(Mul), R(0), // |
| 272 B(Return)}, |
| 273 0}, |
| 274 {"var x = 4; return x / 3;", |
| 275 kPointerSize, |
| 276 1, |
| 277 9, |
| 278 {B(LdaSmi8), U8(4), // |
| 279 B(Star), R(0), // |
| 280 B(LdaSmi8), U8(3), // |
| 281 B(Div), R(0), // |
| 282 B(Return)}, |
| 283 0}, |
| 284 {"var x = 4; return x % 3;", |
| 285 kPointerSize, |
| 286 1, |
| 287 9, |
| 288 {B(LdaSmi8), U8(4), // |
| 289 B(Star), R(0), // |
| 290 B(LdaSmi8), U8(3), // |
| 291 B(Mod), R(0), // |
| 292 B(Return)}, |
| 293 0}, |
| 294 {"var x = 1; return x | 2;", |
| 295 kPointerSize, |
| 296 1, |
| 297 9, |
| 298 {B(LdaSmi8), U8(1), // |
| 299 B(Star), R(0), // |
| 300 B(LdaSmi8), U8(2), // |
| 301 B(BitwiseOr), R(0), // |
| 302 B(Return)}, |
| 303 0}, |
| 304 {"var x = 1; return x ^ 2;", |
| 305 kPointerSize, |
| 306 1, |
| 307 9, |
| 308 {B(LdaSmi8), U8(1), // |
| 309 B(Star), R(0), // |
| 310 B(LdaSmi8), U8(2), // |
| 311 B(BitwiseXor), R(0), // |
| 312 B(Return)}, |
| 313 0}, |
| 314 {"var x = 1; return x & 2;", |
| 315 kPointerSize, |
| 316 1, |
| 317 9, |
| 318 {B(LdaSmi8), U8(1), // |
| 319 B(Star), R(0), // |
| 320 B(LdaSmi8), U8(2), // |
| 321 B(BitwiseAnd), R(0), // |
| 322 B(Return)}, |
| 323 0}, |
| 324 {"var x = 10; return x << 3;", |
| 325 kPointerSize, |
| 326 1, |
| 327 9, |
| 328 {B(LdaSmi8), U8(10), // |
| 329 B(Star), R(0), // |
| 330 B(LdaSmi8), U8(3), // |
| 331 B(ShiftLeft), R(0), // |
| 332 B(Return)}, |
| 333 0}, |
| 334 {"var x = 10; return x >> 3;", |
| 335 kPointerSize, |
| 336 1, |
| 337 9, |
| 338 {B(LdaSmi8), U8(10), // |
| 339 B(Star), R(0), // |
| 340 B(LdaSmi8), U8(3), // |
| 341 B(ShiftRight), R(0), // |
| 342 B(Return)}, |
| 343 0}, |
| 344 {"var x = 10; return x >>> 3;", |
| 345 kPointerSize, |
| 346 1, |
| 347 9, |
| 348 {B(LdaSmi8), U8(10), // |
| 349 B(Star), R(0), // |
| 350 B(LdaSmi8), U8(3), // |
| 351 B(ShiftRightLogical), R(0), // |
| 352 B(Return)}, |
| 353 0}, |
| 354 {"var x = 0; return (x, 3);", |
| 355 kPointerSize, |
| 356 1, |
| 357 6, |
| 358 {B(LdaZero), // |
| 359 B(Star), R(0), // |
| 381 B(LdaSmi8), U8(3), // | 360 B(LdaSmi8), U8(3), // |
| 382 B(Return)}, | 361 B(Return)}, |
| 383 0}}; | 362 0}}; |
| 384 | 363 |
| 385 for (size_t i = 0; i < arraysize(snippets); i++) { | 364 for (size_t i = 0; i < arraysize(snippets); i++) { |
| 386 Handle<BytecodeArray> bytecode_array = | 365 Handle<BytecodeArray> bytecode_array = |
| 387 helper.MakeBytecodeForFunctionBody(snippets[i].code_snippet); | 366 helper.MakeBytecodeForFunctionBody(snippets[i].code_snippet); |
| 388 CheckBytecodeArrayEqual(snippets[i], bytecode_array); | 367 CheckBytecodeArrayEqual(snippets[i], bytecode_array); |
| 389 } | 368 } |
| 390 } | 369 } |
| (...skipping 20 matching lines...) Expand all Loading... |
| 411 1 * kPointerSize, | 390 1 * kPointerSize, |
| 412 1, | 391 1, |
| 413 10, | 392 10, |
| 414 {B(LdaZero), // | 393 {B(LdaZero), // |
| 415 B(Star), R(0), // | 394 B(Star), R(0), // |
| 416 B(Ldar), R(0), // | 395 B(Ldar), R(0), // |
| 417 B(JumpIfToBooleanFalse), U8(4), // | 396 B(JumpIfToBooleanFalse), U8(4), // |
| 418 B(LdaSmi8), U8(3), // | 397 B(LdaSmi8), U8(3), // |
| 419 B(Return)}, | 398 B(Return)}, |
| 420 0}, | 399 0}, |
| 400 {"var x = 0; return x || (1, 2, 3);", |
| 401 1 * kPointerSize, |
| 402 1, |
| 403 10, |
| 404 {B(LdaZero), // |
| 405 B(Star), R(0), // |
| 406 B(Ldar), R(0), // |
| 407 B(JumpIfToBooleanTrue), U8(4), // |
| 408 B(LdaSmi8), U8(3), // |
| 409 B(Return)}, |
| 410 0}, |
| 411 {"var a = 2, b = 3, c = 4; return a || (a, b, a, b, c = 5, 3);", |
| 412 3 * kPointerSize, |
| 413 1, |
| 414 23, |
| 415 {B(LdaSmi8), U8(2), // |
| 416 B(Star), R(0), // |
| 417 B(LdaSmi8), U8(3), // |
| 418 B(Star), R(1), // |
| 419 B(LdaSmi8), U8(4), // |
| 420 B(Star), R(2), // |
| 421 B(Ldar), R(0), // |
| 422 B(JumpIfToBooleanTrue), U8(8), // |
| 423 B(LdaSmi8), U8(5), // |
| 424 B(Star), R(2), // |
| 425 B(LdaSmi8), U8(3), // |
| 426 B(Return)}, |
| 427 0}, |
| 421 {"var x = 1; var a = 2, b = 3; return x || (" | 428 {"var x = 1; var a = 2, b = 3; return x || (" |
| 422 #define X "a, b, a, b, " | 429 #define X "a = 1, b = 2, " |
| 423 X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X | 430 X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X |
| 424 #undef X | 431 #undef X |
| 425 "3);", | 432 "3);", |
| 426 3 * kPointerSize, | 433 3 * kPointerSize, |
| 427 1, | 434 1, |
| 428 283, | 435 283, |
| 429 {B(LdaSmi8), U8(1), // | 436 {B(LdaSmi8), U8(1), // |
| 430 B(Star), R(0), // | 437 B(Star), R(0), // |
| 431 B(LdaSmi8), U8(2), // | 438 B(LdaSmi8), U8(2), // |
| 432 B(Star), R(1), // | 439 B(Star), R(1), // |
| 433 B(LdaSmi8), U8(3), // | 440 B(LdaSmi8), U8(3), // |
| 434 B(Star), R(2), // | 441 B(Star), R(2), // |
| 435 B(Ldar), R(0), // | 442 B(Ldar), R(0), // |
| 436 B(JumpIfToBooleanTrueConstant), U8(0), // | 443 B(JumpIfToBooleanTrueConstant), U8(0), // |
| 437 #define X B(Ldar), R(1), B(Ldar), R(2), B(Ldar), R(1), B(Ldar), R(2), | 444 #define X B(LdaSmi8), U8(1), B(Star), R(1), B(LdaSmi8), U8(2), B(Star), R(2), |
| 438 X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X | 445 X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X |
| 439 #undef X | 446 #undef X |
| 440 B(LdaSmi8), U8(3), // | 447 B(LdaSmi8), U8(3), // |
| 441 B(Return)}, | 448 B(Return)}, |
| 442 1, | 449 1, |
| 443 {268, 0, 0, 0}}, | 450 {268, 0, 0, 0}}, |
| 444 {"var x = 0; var a = 2, b = 3; return x && (" | 451 {"var x = 0; var a = 2, b = 3; return x && (" |
| 445 #define X "a, b, a, b, " | 452 #define X "a = 1, b = 2, " |
| 446 X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X | 453 X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X |
| 447 #undef X | 454 #undef X |
| 448 "3);", | 455 "3);", |
| 449 3 * kPointerSize, | 456 3 * kPointerSize, |
| 450 1, | 457 1, |
| 451 282, | 458 282, |
| 452 {B(LdaZero), // | 459 {B(LdaZero), // |
| 453 B(Star), R(0), // | 460 B(Star), R(0), // |
| 454 B(LdaSmi8), U8(2), // | 461 B(LdaSmi8), U8(2), // |
| 455 B(Star), R(1), // | 462 B(Star), R(1), // |
| 456 B(LdaSmi8), U8(3), // | 463 B(LdaSmi8), U8(3), // |
| 457 B(Star), R(2), // | 464 B(Star), R(2), // |
| 458 B(Ldar), R(0), // | 465 B(Ldar), R(0), // |
| 459 B(JumpIfToBooleanFalseConstant), U8(0), // | 466 B(JumpIfToBooleanFalseConstant), U8(0), // |
| 460 #define X B(Ldar), R(1), B(Ldar), R(2), B(Ldar), R(1), B(Ldar), R(2), | 467 #define X B(LdaSmi8), U8(1), B(Star), R(1), B(LdaSmi8), U8(2), B(Star), R(2), |
| 461 X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X | 468 X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X |
| 462 #undef X | 469 #undef X |
| 463 B(LdaSmi8), U8(3), // | 470 B(LdaSmi8), U8(3), // |
| 464 B(Return)}, | 471 B(Return)}, |
| 465 1, | 472 1, |
| 466 {268, 0, 0, 0}}, | 473 {268, 0, 0, 0}}, |
| 467 {"return 0 && 3;", | 474 {"return 0 && 3;", |
| 468 0 * kPointerSize, | 475 0 * kPointerSize, |
| 469 1, | 476 1, |
| 470 2, | 477 2, |
| 471 {B(LdaZero), // | 478 {B(LdaZero), // |
| 472 B(Return)}, | 479 B(Return)}, |
| 473 0}, | 480 0}, |
| 474 {"return 1 || 3;", | 481 {"return 1 || 3;", |
| 475 0 * kPointerSize, | 482 0 * kPointerSize, |
| 476 1, | 483 1, |
| 477 3, | 484 3, |
| 478 {B(LdaSmi8), U8(1), // | 485 {B(LdaSmi8), U8(1), // |
| 479 B(Return)}, | 486 B(Return)}, |
| 480 0}, | 487 0}, |
| 481 {"var x = 1; return x && 3 || 0, 1;", | 488 {"var x = 1; return x && 3 || 0, 1;", |
| 482 1 * kPointerSize, | 489 1 * kPointerSize, |
| 483 1, | 490 1, |
| 484 16, | 491 16, |
| 485 {B(LdaSmi8), U8(1), // | 492 {B(LdaSmi8), U8(1), // |
| 486 B(Star), R(0), // | 493 B(Star), R(0), // |
| 487 B(Ldar), R(0), // | 494 B(Ldar), R(0), // |
| 488 B(JumpIfToBooleanFalse), U8(4), // | 495 B(JumpIfToBooleanFalse), U8(4), // |
| (...skipping 11 matching lines...) Expand all Loading... |
| 500 } | 507 } |
| 501 } | 508 } |
| 502 | 509 |
| 503 | 510 |
| 504 TEST(Parameters) { | 511 TEST(Parameters) { |
| 505 InitializedHandleScope handle_scope; | 512 InitializedHandleScope handle_scope; |
| 506 BytecodeGeneratorHelper helper; | 513 BytecodeGeneratorHelper helper; |
| 507 | 514 |
| 508 ExpectedSnippet<int> snippets[] = { | 515 ExpectedSnippet<int> snippets[] = { |
| 509 {"function f() { return this; }", | 516 {"function f() { return this; }", |
| 510 0, 1, 3, {B(Ldar), R(helper.kLastParamIndex), B(Return)}, 0}, | 517 0, |
| 518 1, |
| 519 3, |
| 520 {B(Ldar), THIS(1), B(Return)}, |
| 521 0}, |
| 511 {"function f(arg1) { return arg1; }", | 522 {"function f(arg1) { return arg1; }", |
| 512 0, 2, 3, {B(Ldar), R(helper.kLastParamIndex), B(Return)}, 0}, | 523 0, |
| 524 2, |
| 525 3, |
| 526 {B(Ldar), A(1, 2), B(Return)}, |
| 527 0}, |
| 513 {"function f(arg1) { return this; }", | 528 {"function f(arg1) { return this; }", |
| 514 0, 2, 3, {B(Ldar), R(helper.kLastParamIndex - 1), B(Return)}, 0}, | 529 0, |
| 530 2, |
| 531 3, |
| 532 {B(Ldar), THIS(2), B(Return)}, |
| 533 0}, |
| 515 {"function f(arg1, arg2, arg3, arg4, arg5, arg6, arg7) { return arg4; }", | 534 {"function f(arg1, arg2, arg3, arg4, arg5, arg6, arg7) { return arg4; }", |
| 516 0, 8, 3, {B(Ldar), R(helper.kLastParamIndex - 3), B(Return)}, 0}, | 535 0, |
| 536 8, |
| 537 3, |
| 538 {B(Ldar), A(4, 8), B(Return)}, |
| 539 0}, |
| 517 {"function f(arg1, arg2, arg3, arg4, arg5, arg6, arg7) { return this; }", | 540 {"function f(arg1, arg2, arg3, arg4, arg5, arg6, arg7) { return this; }", |
| 518 0, 8, 3, {B(Ldar), R(helper.kLastParamIndex - 7), B(Return)}, 0}, | 541 0, |
| 542 8, |
| 543 3, |
| 544 {B(Ldar), THIS(8), B(Return)}, |
| 545 0}, |
| 519 {"function f(arg1) { arg1 = 1; }", | 546 {"function f(arg1) { arg1 = 1; }", |
| 520 0, 2, 6, | 547 0, |
| 521 {B(LdaSmi8), U8(1), // | 548 2, |
| 522 B(Star), R(helper.kLastParamIndex), // | 549 6, |
| 523 B(LdaUndefined), // | 550 {B(LdaSmi8), U8(1), // |
| 551 B(Star), A(1, 2), // |
| 552 B(LdaUndefined), // |
| 524 B(Return)}, | 553 B(Return)}, |
| 525 0}, | 554 0}, |
| 526 {"function f(arg1, arg2, arg3, arg4) { arg2 = 1; }", | 555 {"function f(arg1, arg2, arg3, arg4) { arg2 = 1; }", |
| 527 0, 5, 6, | 556 0, |
| 528 {B(LdaSmi8), U8(1), // | 557 5, |
| 529 B(Star), R(helper.kLastParamIndex - 2), // | 558 6, |
| 530 B(LdaUndefined), // | 559 {B(LdaSmi8), U8(1), // |
| 560 B(Star), A(2, 5), // |
| 561 B(LdaUndefined), // |
| 531 B(Return)}, | 562 B(Return)}, |
| 532 0}, | 563 0}, |
| 533 }; | 564 }; |
| 534 | 565 |
| 535 for (size_t i = 0; i < arraysize(snippets); i++) { | 566 for (size_t i = 0; i < arraysize(snippets); i++) { |
| 536 Handle<BytecodeArray> bytecode_array = | 567 Handle<BytecodeArray> bytecode_array = |
| 537 helper.MakeBytecodeForFunction(snippets[i].code_snippet); | 568 helper.MakeBytecodeForFunction(snippets[i].code_snippet); |
| 538 CheckBytecodeArrayEqual(snippets[i], bytecode_array); | 569 CheckBytecodeArrayEqual(snippets[i], bytecode_array); |
| 539 } | 570 } |
| 540 } | 571 } |
| (...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 690 | 721 |
| 691 FeedbackVectorSpec feedback_spec(&zone); | 722 FeedbackVectorSpec feedback_spec(&zone); |
| 692 FeedbackVectorSlot slot1 = feedback_spec.AddLoadICSlot(); | 723 FeedbackVectorSlot slot1 = feedback_spec.AddLoadICSlot(); |
| 693 FeedbackVectorSlot slot2 = feedback_spec.AddLoadICSlot(); | 724 FeedbackVectorSlot slot2 = feedback_spec.AddLoadICSlot(); |
| 694 | 725 |
| 695 Handle<i::TypeFeedbackVector> vector = | 726 Handle<i::TypeFeedbackVector> vector = |
| 696 i::NewTypeFeedbackVector(helper.isolate(), &feedback_spec); | 727 i::NewTypeFeedbackVector(helper.isolate(), &feedback_spec); |
| 697 | 728 |
| 698 ExpectedSnippet<const char*> snippets[] = { | 729 ExpectedSnippet<const char*> snippets[] = { |
| 699 {"function f(a) { return a.name; }\nf({name : \"test\"})", | 730 {"function f(a) { return a.name; }\nf({name : \"test\"})", |
| 700 1 * kPointerSize, | 731 0, |
| 701 2, | 732 2, |
| 702 10, | 733 6, |
| 703 { | 734 { |
| 704 B(Ldar), R(helper.kLastParamIndex), // | 735 B(LdaConstant), U8(0), // |
| 705 B(Star), R(0), // | 736 B(LoadICSloppy), A(1, 2), U8(vector->GetIndex(slot1)), // |
| 706 B(LdaConstant), U8(0), // | 737 B(Return), // |
| 707 B(LoadICSloppy), R(0), U8(vector->GetIndex(slot1)), // | |
| 708 B(Return) // | |
| 709 }, | 738 }, |
| 710 1, | 739 1, |
| 711 {"name"}}, | 740 {"name"}}, |
| 712 {"function f(a) { return a[\"key\"]; }\nf({key : \"test\"})", | 741 {"function f(a) { return a[\"key\"]; }\nf({key : \"test\"})", |
| 713 1 * kPointerSize, | 742 0, |
| 714 2, | 743 2, |
| 715 10, | 744 6, |
| 716 { | 745 { |
| 717 B(Ldar), R(helper.kLastParamIndex), // | 746 B(LdaConstant), U8(0), // |
| 718 B(Star), R(0), // | 747 B(LoadICSloppy), A(1, 2), U8(vector->GetIndex(slot1)), // |
| 719 B(LdaConstant), U8(0), // | 748 B(Return) // |
| 720 B(LoadICSloppy), R(0), U8(vector->GetIndex(slot1)), // | |
| 721 B(Return) // | |
| 722 }, | 749 }, |
| 723 1, | 750 1, |
| 724 {"key"}}, | 751 {"key"}}, |
| 725 {"function f(a) { return a[100]; }\nf({100 : \"test\"})", | 752 {"function f(a) { return a[100]; }\nf({100 : \"test\"})", |
| 726 1 * kPointerSize, | 753 0, |
| 727 2, | 754 2, |
| 728 10, | 755 6, |
| 729 { | 756 { |
| 730 B(Ldar), R(helper.kLastParamIndex), // | 757 B(LdaSmi8), U8(100), // |
| 731 B(Star), R(0), // | 758 B(KeyedLoadICSloppy), A(1, 2), U8(vector->GetIndex(slot1)), // |
| 732 B(LdaSmi8), U8(100), // | 759 B(Return) // |
| 733 B(KeyedLoadICSloppy), R(0), U8(vector->GetIndex(slot1)), // | |
| 734 B(Return) // | |
| 735 }, | 760 }, |
| 736 0}, | 761 0}, |
| 737 {"function f(a, b) { return a[b]; }\nf({arg : \"test\"}, \"arg\")", | 762 {"function f(a, b) { return a[b]; }\nf({arg : \"test\"}, \"arg\")", |
| 738 1 * kPointerSize, | 763 0, |
| 739 3, | 764 3, |
| 740 10, | 765 6, |
| 741 { | 766 { |
| 742 B(Ldar), R(helper.kLastParamIndex - 1), // | 767 B(Ldar), A(1, 2), // |
| 743 B(Star), R(0), // | 768 B(KeyedLoadICSloppy), A(1, 3), U8(vector->GetIndex(slot1)), // |
| 744 B(Ldar), R(helper.kLastParamIndex), // | 769 B(Return) // |
| 745 B(KeyedLoadICSloppy), R(0), U8(vector->GetIndex(slot1)), // | |
| 746 B(Return) // | |
| 747 }, | 770 }, |
| 748 0}, | 771 0}, |
| 749 {"function f(a) { var b = a.name; return a[-124]; }\n" | 772 {"function f(a) { var b = a.name; return a[-124]; }\n" |
| 750 "f({\"-124\" : \"test\", name : 123 })", | 773 "f({\"-124\" : \"test\", name : 123 })", |
| 751 2 * kPointerSize, | 774 kPointerSize, |
| 752 2, | 775 2, |
| 753 21, | 776 13, |
| 754 { | 777 { |
| 755 B(Ldar), R(helper.kLastParamIndex), // | 778 B(LdaConstant), U8(0), // |
| 756 B(Star), R(1), // | 779 B(LoadICSloppy), A(1, 2), U8(vector->GetIndex(slot1)), // |
| 757 B(LdaConstant), U8(0), // | 780 B(Star), R(0), // |
| 758 B(LoadICSloppy), R(1), U8(vector->GetIndex(slot1)), // | 781 B(LdaSmi8), U8(-124), // |
| 759 B(Star), R(0), // | 782 B(KeyedLoadICSloppy), A(1, 2), U8(vector->GetIndex(slot2)), // |
| 760 B(Ldar), R(helper.kLastParamIndex), // | 783 B(Return), // |
| 761 B(Star), R(1), // | |
| 762 B(LdaSmi8), U8(-124), // | |
| 763 B(KeyedLoadICSloppy), R(1), U8(vector->GetIndex(slot2)), // | |
| 764 B(Return) // | |
| 765 }, | 784 }, |
| 766 1, | 785 1, |
| 767 {"name"}}, | 786 {"name"}}, |
| 768 {"function f(a) { \"use strict\"; return a.name; }\nf({name : \"test\"})", | 787 {"function f(a) { \"use strict\"; return a.name; }\nf({name : \"test\"})", |
| 769 1 * kPointerSize, | 788 0, |
| 770 2, | 789 2, |
| 771 12, | 790 6, |
| 772 { | 791 { |
| 773 // TODO(rmcilroy) Avoid unnecessary LdaConstant for "use strict" | 792 B(LdaConstant), U8(0), // |
| 774 // expression, or any other unused literal expression. | 793 B(LoadICStrict), A(1, 2), U8(vector->GetIndex(slot1)), // |
| 775 B(LdaConstant), U8(0), // | 794 B(Return), // |
| 776 B(Ldar), R(helper.kLastParamIndex), // | |
| 777 B(Star), R(0), // | |
| 778 B(LdaConstant), U8(1), // | |
| 779 B(LoadICStrict), R(0), U8(vector->GetIndex(slot1)), // | |
| 780 B(Return) // | |
| 781 }, | 795 }, |
| 782 2, | 796 1, |
| 783 {"use strict", "name"}}, | 797 {"name"}}, |
| 784 {"function f(a, b) { \"use strict\"; return a[b]; }\n" | 798 {"function f(a, b) { \"use strict\"; return a[b]; }\n" |
| 785 "f({arg : \"test\"}, \"arg\")", | 799 "f({arg : \"test\"}, \"arg\")", |
| 786 1 * kPointerSize, | 800 0, |
| 787 3, | 801 3, |
| 788 12, | 802 6, |
| 789 { | 803 { |
| 790 // TODO(rmcilroy) Avoid unnecessary LdaConstant for "use strict" | 804 B(Ldar), A(2, 3), // |
| 791 // expression, or any other unused literal expression. | 805 B(KeyedLoadICStrict), A(1, 3), U8(vector->GetIndex(slot1)), // |
| 792 B(LdaConstant), U8(0), // | 806 B(Return), // |
| 793 B(Ldar), R(helper.kLastParamIndex - 1), // | |
| 794 B(Star), R(0), // | |
| 795 B(Ldar), R(helper.kLastParamIndex), // | |
| 796 B(KeyedLoadICStrict), R(0), U8(vector->GetIndex(slot1)), // | |
| 797 B(Return) // | |
| 798 }, | 807 }, |
| 799 1, | 808 0, |
| 800 {"use strict"}}}; | 809 }}; |
| 801 for (size_t i = 0; i < arraysize(snippets); i++) { | 810 for (size_t i = 0; i < arraysize(snippets); i++) { |
| 802 Handle<BytecodeArray> bytecode_array = | 811 Handle<BytecodeArray> bytecode_array = |
| 803 helper.MakeBytecode(snippets[i].code_snippet, helper.kFunctionName); | 812 helper.MakeBytecode(snippets[i].code_snippet, helper.kFunctionName); |
| 804 CheckBytecodeArrayEqual(snippets[i], bytecode_array); | 813 CheckBytecodeArrayEqual(snippets[i], bytecode_array); |
| 805 } | 814 } |
| 806 } | 815 } |
| 807 | 816 |
| 808 | 817 |
| 809 TEST(PropertyStores) { | 818 TEST(PropertyStores) { |
| 810 InitializedHandleScope handle_scope; | 819 InitializedHandleScope handle_scope; |
| 811 BytecodeGeneratorHelper helper; | 820 BytecodeGeneratorHelper helper; |
| 812 Zone zone; | 821 Zone zone; |
| 813 | 822 |
| 814 FeedbackVectorSpec feedback_spec(&zone); | 823 FeedbackVectorSpec feedback_spec(&zone); |
| 815 FeedbackVectorSlot slot1 = feedback_spec.AddStoreICSlot(); | 824 FeedbackVectorSlot slot1 = feedback_spec.AddStoreICSlot(); |
| 816 FeedbackVectorSlot slot2 = feedback_spec.AddStoreICSlot(); | 825 FeedbackVectorSlot slot2 = feedback_spec.AddStoreICSlot(); |
| 817 | 826 |
| 818 Handle<i::TypeFeedbackVector> vector = | 827 Handle<i::TypeFeedbackVector> vector = |
| 819 i::NewTypeFeedbackVector(helper.isolate(), &feedback_spec); | 828 i::NewTypeFeedbackVector(helper.isolate(), &feedback_spec); |
| 820 | 829 |
| 821 ExpectedSnippet<const char*> snippets[] = { | 830 ExpectedSnippet<const char*> snippets[] = { |
| 822 {"function f(a) { a.name = \"val\"; }\nf({name : \"test\"})", | 831 {"function f(a) { a.name = \"val\"; }\nf({name : \"test\"})", |
| 823 2 * kPointerSize, | 832 kPointerSize, |
| 824 2, | 833 2, |
| 825 16, | 834 12, |
| 826 { | 835 { |
| 827 B(Ldar), R(helper.kLastParamIndex), // | 836 B(LdaConstant), U8(0), // |
| 828 B(Star), R(0), // | 837 B(Star), R(0), // |
| 829 B(LdaConstant), U8(0), // | 838 B(LdaConstant), U8(1), // |
| 830 B(Star), R(1), // | 839 B(StoreICSloppy), A(1, 2), R(0), U8(vector->GetIndex(slot1)), // |
| 831 B(LdaConstant), U8(1), // | 840 B(LdaUndefined), // |
| 832 B(StoreICSloppy), R(0), R(1), U8(vector->GetIndex(slot1)), // | 841 B(Return), // |
| 833 B(LdaUndefined), // | |
| 834 B(Return) // | |
| 835 }, | 842 }, |
| 836 2, | 843 2, |
| 837 {"name", "val"}}, | 844 {"name", "val"}}, |
| 838 {"function f(a) { a[\"key\"] = \"val\"; }\nf({key : \"test\"})", | 845 {"function f(a) { a[\"key\"] = \"val\"; }\nf({key : \"test\"})", |
| 839 2 * kPointerSize, | 846 kPointerSize, |
| 840 2, | 847 2, |
| 841 16, | 848 12, |
| 842 { | 849 { |
| 843 B(Ldar), R(helper.kLastParamIndex), // | 850 B(LdaConstant), U8(0), // |
| 844 B(Star), R(0), // | 851 B(Star), R(0), // |
| 845 B(LdaConstant), U8(0), // | 852 B(LdaConstant), U8(1), // |
| 846 B(Star), R(1), // | 853 B(StoreICSloppy), A(1, 2), R(0), U8(vector->GetIndex(slot1)), // |
| 847 B(LdaConstant), U8(1), // | 854 B(LdaUndefined), // |
| 848 B(StoreICSloppy), R(0), R(1), U8(vector->GetIndex(slot1)), // | 855 B(Return), // |
| 849 B(LdaUndefined), // | |
| 850 B(Return) // | |
| 851 }, | 856 }, |
| 852 2, | 857 2, |
| 853 {"key", "val"}}, | 858 {"key", "val"}}, |
| 854 {"function f(a) { a[100] = \"val\"; }\nf({100 : \"test\"})", | 859 {"function f(a) { a[100] = \"val\"; }\nf({100 : \"test\"})", |
| 855 2 * kPointerSize, | 860 kPointerSize, |
| 856 2, | 861 2, |
| 857 16, | 862 12, |
| 858 { | 863 { |
| 859 B(Ldar), R(helper.kLastParamIndex), // | 864 B(LdaSmi8), U8(100), // |
| 860 B(Star), R(0), // | 865 B(Star), R(0), // |
| 861 B(LdaSmi8), U8(100), // | 866 B(LdaConstant), U8(0), // |
| 862 B(Star), R(1), // | 867 B(KeyedStoreICSloppy), // |
| 863 B(LdaConstant), U8(0), // | 868 A(1, 2), R(0), U8(vector->GetIndex(slot1)), // |
| 864 B(KeyedStoreICSloppy), R(0), R(1), U8(vector->GetIndex(slot1)), // | 869 B(LdaUndefined), // |
| 865 B(LdaUndefined), // | 870 B(Return), // |
| 866 B(Return) // | |
| 867 }, | 871 }, |
| 868 1, | 872 1, |
| 869 {"val"}}, | 873 {"val"}}, |
| 870 {"function f(a, b) { a[b] = \"val\"; }\nf({arg : \"test\"}, \"arg\")", | 874 {"function f(a, b) { a[b] = \"val\"; }\nf({arg : \"test\"}, \"arg\")", |
| 871 2 * kPointerSize, | 875 0, |
| 872 3, | 876 3, |
| 873 16, | 877 8, |
| 874 { | 878 { |
| 875 B(Ldar), R(helper.kLastParamIndex - 1), // | 879 B(LdaConstant), U8(0), // |
| 876 B(Star), R(0), // | 880 B(KeyedStoreICSloppy), // |
| 877 B(Ldar), R(helper.kLastParamIndex), // | 881 A(1, 3), A(2, 3), U8(vector->GetIndex(slot1)), // |
| 878 B(Star), R(1), // | 882 B(LdaUndefined), // |
| 879 B(LdaConstant), U8(0), // | 883 B(Return), // |
| 880 B(KeyedStoreICSloppy), R(0), R(1), U8(vector->GetIndex(slot1)), // | |
| 881 B(LdaUndefined), // | |
| 882 B(Return) // | |
| 883 }, | 884 }, |
| 884 1, | 885 1, |
| 885 {"val"}}, | 886 {"val"}}, |
| 886 {"function f(a) { a.name = a[-124]; }\n" | 887 {"function f(a) { a.name = a[-124]; }\n" |
| 887 "f({\"-124\" : \"test\", name : 123 })", | 888 "f({\"-124\" : \"test\", name : 123 })", |
| 888 3 * kPointerSize, | 889 kPointerSize, |
| 889 2, | 890 2, |
| 890 23, | 891 15, |
| 891 { | 892 { |
| 892 B(Ldar), R(helper.kLastParamIndex), // | 893 B(LdaConstant), U8(0), // |
| 893 B(Star), R(0), // | 894 B(Star), R(0), // |
| 894 B(LdaConstant), U8(0), // | 895 B(LdaSmi8), U8(-124), // |
| 895 B(Star), R(1), // | 896 B(KeyedLoadICSloppy), A(1, 2), U8(vector->GetIndex(slot1)), // |
| 896 B(Ldar), R(helper.kLastParamIndex), // | 897 B(StoreICSloppy), A(1, 2), R(0), U8(vector->GetIndex(slot2)), // |
| 897 B(Star), R(2), // | 898 B(LdaUndefined), // |
| 898 B(LdaSmi8), U8(-124), // | 899 B(Return), // |
| 899 B(KeyedLoadICSloppy), R(2), U8(vector->GetIndex(slot1)), // | |
| 900 B(StoreICSloppy), R(0), R(1), U8(vector->GetIndex(slot2)), // | |
| 901 B(LdaUndefined), // | |
| 902 B(Return) // | |
| 903 }, | 900 }, |
| 904 1, | 901 1, |
| 905 {"name"}}, | 902 {"name"}}, |
| 906 {"function f(a) { \"use strict\"; a.name = \"val\"; }\n" | 903 {"function f(a) { \"use strict\"; a.name = \"val\"; }\n" |
| 907 "f({name : \"test\"})", | 904 "f({name : \"test\"})", |
| 908 2 * kPointerSize, | 905 kPointerSize, |
| 909 2, | 906 2, |
| 910 18, | 907 12, |
| 911 { | 908 { |
| 912 // TODO(rmcilroy) Avoid unnecessary LdaConstant for "use strict" | 909 B(LdaConstant), U8(0), // |
| 913 // expression, or any other unused literal expression. | 910 B(Star), R(0), // |
| 914 B(LdaConstant), U8(0), // | 911 B(LdaConstant), U8(1), // |
| 915 B(Ldar), R(helper.kLastParamIndex), // | 912 B(StoreICStrict), A(1, 2), R(0), U8(vector->GetIndex(slot1)), // |
| 916 B(Star), R(0), // | 913 B(LdaUndefined), // |
| 917 B(LdaConstant), U8(1), // | 914 B(Return), // |
| 918 B(Star), R(1), // | |
| 919 B(LdaConstant), U8(2), // | |
| 920 B(StoreICStrict), R(0), R(1), U8(vector->GetIndex(slot1)), // | |
| 921 B(LdaUndefined), // | |
| 922 B(Return) // | |
| 923 }, | 915 }, |
| 924 3, | 916 2, |
| 925 {"use strict", "name", "val"}}, | 917 {"name", "val"}}, |
| 926 {"function f(a, b) { \"use strict\"; a[b] = \"val\"; }\n" | 918 {"function f(a, b) { \"use strict\"; a[b] = \"val\"; }\n" |
| 927 "f({arg : \"test\"}, \"arg\")", | 919 "f({arg : \"test\"}, \"arg\")", |
| 928 2 * kPointerSize, | 920 0, |
| 929 3, | 921 3, |
| 930 18, | 922 8, |
| 931 { | 923 { |
| 932 // TODO(rmcilroy) Avoid unnecessary LdaConstant for "use strict" | 924 B(LdaConstant), U8(0), // |
| 933 // expression, or any other unused literal expression. | 925 B(KeyedStoreICStrict), A(1, 3), A(2, 3), // |
| 934 B(LdaConstant), U8(0), // | 926 U8(vector->GetIndex(slot1)), // |
| 935 B(Ldar), R(helper.kLastParamIndex - 1), // | 927 B(LdaUndefined), // |
| 936 B(Star), R(0), // | 928 B(Return), // |
| 937 B(Ldar), R(helper.kLastParamIndex), // | |
| 938 B(Star), R(1), // | |
| 939 B(LdaConstant), U8(1), // | |
| 940 B(KeyedStoreICStrict), R(0), R(1), U8(vector->GetIndex(slot1)), // | |
| 941 B(LdaUndefined), // | |
| 942 B(Return) // | |
| 943 }, | 929 }, |
| 944 2, | 930 1, |
| 945 {"use strict", "val"}}}; | 931 {"val"}}}; |
| 946 for (size_t i = 0; i < arraysize(snippets); i++) { | 932 for (size_t i = 0; i < arraysize(snippets); i++) { |
| 947 Handle<BytecodeArray> bytecode_array = | 933 Handle<BytecodeArray> bytecode_array = |
| 948 helper.MakeBytecode(snippets[i].code_snippet, helper.kFunctionName); | 934 helper.MakeBytecode(snippets[i].code_snippet, helper.kFunctionName); |
| 949 CheckBytecodeArrayEqual(snippets[i], bytecode_array); | 935 CheckBytecodeArrayEqual(snippets[i], bytecode_array); |
| 950 } | 936 } |
| 951 } | 937 } |
| 952 | 938 |
| 953 | 939 |
| 954 #define FUNC_ARG "new (function Obj() { this.func = function() { return; }})()" | 940 #define FUNC_ARG "new (function Obj() { this.func = function() { return; }})()" |
| 955 | 941 |
| (...skipping 10 matching lines...) Expand all Loading... |
| 966 | 952 |
| 967 Handle<i::TypeFeedbackVector> vector = | 953 Handle<i::TypeFeedbackVector> vector = |
| 968 i::NewTypeFeedbackVector(helper.isolate(), &feedback_spec); | 954 i::NewTypeFeedbackVector(helper.isolate(), &feedback_spec); |
| 969 | 955 |
| 970 ExpectedSnippet<const char*> snippets[] = { | 956 ExpectedSnippet<const char*> snippets[] = { |
| 971 {"function f(a) { return a.func(); }\nf(" FUNC_ARG ")", | 957 {"function f(a) { return a.func(); }\nf(" FUNC_ARG ")", |
| 972 2 * kPointerSize, | 958 2 * kPointerSize, |
| 973 2, | 959 2, |
| 974 16, | 960 16, |
| 975 { | 961 { |
| 976 B(Ldar), R(helper.kLastParamIndex), // | 962 B(Ldar), A(1, 2), // |
| 977 B(Star), R(1), // | 963 B(Star), R(1), // |
| 978 B(LdaConstant), U8(0), // | 964 B(LdaConstant), U8(0), // |
| 979 B(LoadICSloppy), R(1), U8(vector->GetIndex(slot2)), // | 965 B(LoadICSloppy), R(1), U8(vector->GetIndex(slot2)), // |
| 980 B(Star), R(0), // | 966 B(Star), R(0), // |
| 981 B(Call), R(0), R(1), U8(0), // | 967 B(Call), R(0), R(1), U8(0), // |
| 982 B(Return) // | 968 B(Return), // |
| 983 }, | 969 }, |
| 984 1, | 970 1, |
| 985 {"func"}}, | 971 {"func"}}, |
| 986 {"function f(a, b, c) { return a.func(b, c); }\nf(" FUNC_ARG ", 1, 2)", | 972 {"function f(a, b, c) { return a.func(b, c); }\nf(" FUNC_ARG ", 1, 2)", |
| 987 4 * kPointerSize, | 973 4 * kPointerSize, |
| 988 4, | 974 4, |
| 989 24, | 975 24, |
| 990 { | 976 { |
| 991 B(Ldar), R(helper.kLastParamIndex - 2), // | 977 B(Ldar), A(1, 4), // |
| 992 B(Star), R(1), // | 978 B(Star), R(1), // |
| 993 B(LdaConstant), U8(0), // | 979 B(LdaConstant), U8(0), // |
| 994 B(LoadICSloppy), R(1), U8(vector->GetIndex(slot2)), // | 980 B(LoadICSloppy), R(1), U8(vector->GetIndex(slot2)), // |
| 995 B(Star), R(0), // | 981 B(Star), R(0), // |
| 996 B(Ldar), R(helper.kLastParamIndex - 1), // | 982 B(Ldar), A(2, 4), // |
| 997 B(Star), R(2), // | 983 B(Star), R(2), // |
| 998 B(Ldar), R(helper.kLastParamIndex), // | 984 B(Ldar), A(3, 4), // |
| 999 B(Star), R(3), // | 985 B(Star), R(3), // |
| 1000 B(Call), R(0), R(1), U8(2), // | 986 B(Call), R(0), R(1), U8(2), // |
| 1001 B(Return) // | 987 B(Return) // |
| 1002 }, | 988 }, |
| 1003 1, | 989 1, |
| 1004 {"func"}}, | 990 {"func"}}, |
| 1005 {"function f(a, b) { return a.func(b + b, b); }\nf(" FUNC_ARG ", 1)", | 991 {"function f(a, b) { return a.func(b + b, b); }\nf(" FUNC_ARG ", 1)", |
| 1006 4 * kPointerSize, | 992 4 * kPointerSize, |
| 1007 3, | 993 3, |
| 1008 30, | 994 26, |
| 1009 { | 995 { |
| 1010 B(Ldar), R(helper.kLastParamIndex - 1), // | 996 B(Ldar), A(1, 3), // |
| 1011 B(Star), R(1), // | 997 B(Star), R(1), // |
| 1012 B(LdaConstant), U8(0), // | 998 B(LdaConstant), U8(0), // |
| 1013 B(LoadICSloppy), R(1), U8(vector->GetIndex(slot2)), // | 999 B(LoadICSloppy), R(1), U8(vector->GetIndex(slot2)), // |
| 1014 B(Star), R(0), // | 1000 B(Star), R(0), // |
| 1015 B(Ldar), R(helper.kLastParamIndex), // | 1001 B(Ldar), A(2, 3), // |
| 1016 B(Star), R(3), // | 1002 B(Add), A(2, 3), // |
| 1017 B(Ldar), R(helper.kLastParamIndex), // | |
| 1018 B(Add), R(3), // | |
| 1019 B(Star), R(2), // | 1003 B(Star), R(2), // |
| 1020 B(Ldar), R(helper.kLastParamIndex), // | 1004 B(Ldar), A(2, 3), // |
| 1021 B(Star), R(3), // | 1005 B(Star), R(3), // |
| 1022 B(Call), R(0), R(1), U8(2), // | 1006 B(Call), R(0), R(1), U8(2), // |
| 1023 B(Return), // | 1007 B(Return), // |
| 1024 }, | 1008 }, |
| 1025 1, | 1009 1, |
| 1026 {"func"}}}; | 1010 {"func"}}}; |
| 1027 for (size_t i = 0; i < arraysize(snippets); i++) { | 1011 for (size_t i = 0; i < arraysize(snippets); i++) { |
| 1028 Handle<BytecodeArray> bytecode_array = | 1012 Handle<BytecodeArray> bytecode_array = |
| 1029 helper.MakeBytecode(snippets[i].code_snippet, helper.kFunctionName); | 1013 helper.MakeBytecode(snippets[i].code_snippet, helper.kFunctionName); |
| 1030 CheckBytecodeArrayEqual(snippets[i], bytecode_array); | 1014 CheckBytecodeArrayEqual(snippets[i], bytecode_array); |
| (...skipping 256 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1287 B(LdaUndefined), // | 1271 B(LdaUndefined), // |
| 1288 B(Return) // | 1272 B(Return) // |
| 1289 }, | 1273 }, |
| 1290 }, | 1274 }, |
| 1291 { | 1275 { |
| 1292 "function f(a) { return %IsArray(a) }\nf(undefined)", | 1276 "function f(a) { return %IsArray(a) }\nf(undefined)", |
| 1293 1 * kPointerSize, | 1277 1 * kPointerSize, |
| 1294 2, | 1278 2, |
| 1295 10, | 1279 10, |
| 1296 { | 1280 { |
| 1297 B(Ldar), R(helper.kLastParamIndex), // | 1281 B(Ldar), A(1, 2), // |
| 1298 B(Star), R(0), // | 1282 B(Star), R(0), // |
| 1299 B(CallRuntime), U16(Runtime::kIsArray), R(0), U8(1), // | 1283 B(CallRuntime), U16(Runtime::kIsArray), R(0), U8(1), // |
| 1300 B(Return) // | 1284 B(Return) // |
| 1301 }, | 1285 }, |
| 1302 }, | 1286 }, |
| 1303 { | 1287 { |
| 1304 "function f() { return %Add(1, 2) }\nf()", | 1288 "function f() { return %Add(1, 2) }\nf()", |
| 1305 2 * kPointerSize, | 1289 2 * kPointerSize, |
| 1306 1, | 1290 1, |
| 1307 14, | 1291 14, |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1374 B(Return), // | 1358 B(Return), // |
| 1375 B(Jump), U8(5), // | 1359 B(Jump), U8(5), // |
| 1376 B(LdaSmi8), U8(-1), // | 1360 B(LdaSmi8), U8(-1), // |
| 1377 B(Return), // | 1361 B(Return), // |
| 1378 B(LdaUndefined), // | 1362 B(LdaUndefined), // |
| 1379 B(Return)}, // | 1363 B(Return)}, // |
| 1380 0, | 1364 0, |
| 1381 {unused, unused, unused, unused, unused, unused}}, | 1365 {unused, unused, unused, unused, unused, unused}}, |
| 1382 {"function f(a) { if (a <= 0) { return 200; } else { return -200; } }" | 1366 {"function f(a) { if (a <= 0) { return 200; } else { return -200; } }" |
| 1383 "f(99);", | 1367 "f(99);", |
| 1384 kPointerSize, | 1368 0, |
| 1385 2, | 1369 2, |
| 1386 19, | 1370 15, |
| 1387 {B(Ldar), R(helper.kLastParamIndex), // | 1371 {B(LdaZero), // |
| 1388 B(Star), R(0), // | 1372 B(TestLessThanOrEqual), A(1, 2), // |
| 1389 B(LdaZero), // | 1373 B(JumpIfFalse), U8(7), // |
| 1390 B(TestLessThanOrEqual), R(0), // | 1374 B(LdaConstant), U8(0), // |
| 1391 B(JumpIfFalse), U8(7), // | 1375 B(Return), // |
| 1392 B(LdaConstant), U8(0), // | 1376 B(Jump), U8(5), // |
| 1393 B(Return), // | 1377 B(LdaConstant), U8(1), // |
| 1394 B(Jump), U8(5), // | 1378 B(Return), // |
| 1395 B(LdaConstant), U8(1), // | 1379 B(LdaUndefined), // |
| 1396 B(Return), // | 1380 B(Return)}, // |
| 1397 B(LdaUndefined), // | |
| 1398 B(Return)}, // | |
| 1399 2, | 1381 2, |
| 1400 {helper.factory()->NewNumberFromInt(200), | 1382 {helper.factory()->NewNumberFromInt(200), |
| 1401 helper.factory()->NewNumberFromInt(-200), unused, unused, unused, | 1383 helper.factory()->NewNumberFromInt(-200), unused, unused, unused, |
| 1402 unused}}, | 1384 unused}}, |
| 1403 {"function f(a, b) { if (a in b) { return 200; } }" | 1385 {"function f(a, b) { if (a in b) { return 200; } }" |
| 1404 "f('prop', { prop: 'yes'});", | 1386 "f('prop', { prop: 'yes'});", |
| 1405 kPointerSize, | 1387 0, |
| 1406 3, | 1388 3, |
| 1407 15, | 1389 11, |
| 1408 {B(Ldar), R(helper.kLastParamIndex - 1), // | 1390 {B(Ldar), A(2, 3), // |
| 1409 B(Star), R(0), // | 1391 B(TestIn), A(1, 3), // |
| 1410 B(Ldar), R(helper.kLastParamIndex), // | 1392 B(JumpIfFalse), U8(5), // |
| 1411 B(TestIn), R(0), // | 1393 B(LdaConstant), U8(0), // |
| 1412 B(JumpIfFalse), U8(5), // | 1394 B(Return), // |
| 1413 B(LdaConstant), U8(0), // | 1395 B(LdaUndefined), // |
| 1414 B(Return), // | 1396 B(Return)}, // |
| 1415 B(LdaUndefined), // | |
| 1416 B(Return)}, // | |
| 1417 1, | 1397 1, |
| 1418 {helper.factory()->NewNumberFromInt(200), unused, unused, unused, unused, | 1398 {helper.factory()->NewNumberFromInt(200), unused, unused, unused, unused, |
| 1419 unused}}, | 1399 unused}}, |
| 1420 {"function f(z) { var a = 0; var b = 0; if (a === 0.01) { " | 1400 {"function f(z) { var a = 0; var b = 0; if (a === 0.01) { " |
| 1421 #define X "b = a; a = b; " | 1401 #define X "b = a; a = b; " |
| 1422 X X X X X X X X X X X X X X X X X X X X X X X X | 1402 X X X X X X X X X X X X X X X X X X X X X X X X |
| 1423 #undef X | 1403 #undef X |
| 1424 " return 200; } else { return -200; } } f(0.001)", | 1404 " return 200; } else { return -200; } } f(0.001)", |
| 1425 3 * kPointerSize, | 1405 2 * kPointerSize, |
| 1426 2, | 1406 2, |
| 1427 218, | 1407 214, |
| 1428 {B(LdaZero), // | 1408 { |
| 1429 B(Star), R(0), // | 1409 #define X B(Ldar), R(0), B(Star), R(1), B(Ldar), R(1), B(Star), R(0) |
| 1430 B(LdaZero), // | 1410 B(LdaZero), // |
| 1431 B(Star), R(1), // | 1411 B(Star), R(0), // |
| 1432 B(Ldar), R(0), // | 1412 B(LdaZero), // |
| 1433 B(Star), R(2), // | 1413 B(Star), R(1), // |
| 1434 B(LdaConstant), U8(0), // | 1414 B(LdaConstant), U8(0), // |
| 1435 B(TestEqualStrict), R(2), // | 1415 B(TestEqualStrict), R(0), // |
| 1436 B(JumpIfFalseConstant), U8(2), // | 1416 B(JumpIfFalseConstant), U8(2), // |
| 1437 #define X B(Ldar), R(0), B(Star), R(1), B(Ldar), R(1), B(Star), R(0), | 1417 X, X, X, X, X, X, X, X, X, X, // |
| 1438 X X X X X X X X X X X X X X X X X X X X X X X X | 1418 X, X, X, X, X, X, X, X, X, X, // |
| 1419 X, X, X, X, // |
| 1420 B(LdaConstant), U8(1), // |
| 1421 B(Return), // |
| 1422 B(Jump), U8(5), // |
| 1423 B(LdaConstant), U8(3), // |
| 1424 B(Return), // |
| 1425 B(LdaUndefined), // |
| 1426 B(Return)}, // |
| 1439 #undef X | 1427 #undef X |
| 1440 B(LdaConstant), U8(1), // | |
| 1441 B(Return), // | |
| 1442 B(Jump), U8(5), // | |
| 1443 B(LdaConstant), U8(3), // | |
| 1444 B(Return), // | |
| 1445 B(LdaUndefined), // | |
| 1446 B(Return)}, // | |
| 1447 4, | 1428 4, |
| 1448 {helper.factory()->NewHeapNumber(0.01), | 1429 {helper.factory()->NewHeapNumber(0.01), |
| 1449 helper.factory()->NewNumberFromInt(200), | 1430 helper.factory()->NewNumberFromInt(200), |
| 1450 helper.factory()->NewNumberFromInt(199), | 1431 helper.factory()->NewNumberFromInt(199), |
| 1451 helper.factory()->NewNumberFromInt(-200), | 1432 helper.factory()->NewNumberFromInt(-200), unused, unused}}, |
| 1452 unused, unused}}, | |
| 1453 {"function f(a, b) {\n" | 1433 {"function f(a, b) {\n" |
| 1454 " if (a == b) { return 1; }\n" | 1434 " if (a == b) { return 1; }\n" |
| 1455 " if (a === b) { return 1; }\n" | 1435 " if (a === b) { return 1; }\n" |
| 1456 " if (a < b) { return 1; }\n" | 1436 " if (a < b) { return 1; }\n" |
| 1457 " if (a > b) { return 1; }\n" | 1437 " if (a > b) { return 1; }\n" |
| 1458 " if (a <= b) { return 1; }\n" | 1438 " if (a <= b) { return 1; }\n" |
| 1459 " if (a >= b) { return 1; }\n" | 1439 " if (a >= b) { return 1; }\n" |
| 1460 " if (a in b) { return 1; }\n" | 1440 " if (a in b) { return 1; }\n" |
| 1461 " if (a instanceof b) { return 1; }\n" | 1441 " if (a instanceof b) { return 1; }\n" |
| 1462 " /* if (a != b) { return 1; } */" // TODO(oth) Ast visitor yields | |
| 1463 " /* if (a !== b) { return 1; } */" // UNARY NOT, rather than !=/!==. | |
| 1464 " return 0;\n" | 1442 " return 0;\n" |
| 1465 "} f(1, 1);", | 1443 "} f(1, 1);", |
| 1466 kPointerSize, | 1444 0, |
| 1467 3, | 1445 3, |
| 1468 106, | 1446 74, |
| 1469 { | 1447 { |
| 1470 #define IF_CONDITION_RETURN(condition) \ | 1448 #define IF_CONDITION_RETURN(condition) \ |
| 1471 B(Ldar), R(helper.kLastParamIndex - 1), \ | 1449 B(Ldar), A(2, 3), \ |
| 1472 B(Star), R(0), \ | 1450 B(condition), A(1, 3), \ |
| 1473 B(Ldar), R(helper.kLastParamIndex), \ | 1451 B(JumpIfFalse), U8(5), \ |
| 1474 B(condition), R(0), \ | 1452 B(LdaSmi8), U8(1), \ |
| 1475 B(JumpIfFalse), U8(5), \ | 1453 B(Return), |
| 1476 B(LdaSmi8), U8(1), \ | |
| 1477 B(Return), | |
| 1478 IF_CONDITION_RETURN(TestEqual) // | 1454 IF_CONDITION_RETURN(TestEqual) // |
| 1479 IF_CONDITION_RETURN(TestEqualStrict) // | 1455 IF_CONDITION_RETURN(TestEqualStrict) // |
| 1480 IF_CONDITION_RETURN(TestLessThan) // | 1456 IF_CONDITION_RETURN(TestLessThan) // |
| 1481 IF_CONDITION_RETURN(TestGreaterThan) // | 1457 IF_CONDITION_RETURN(TestGreaterThan) // |
| 1482 IF_CONDITION_RETURN(TestLessThanOrEqual) // | 1458 IF_CONDITION_RETURN(TestLessThanOrEqual) // |
| 1483 IF_CONDITION_RETURN(TestGreaterThanOrEqual) // | 1459 IF_CONDITION_RETURN(TestGreaterThanOrEqual) // |
| 1484 IF_CONDITION_RETURN(TestIn) // | 1460 IF_CONDITION_RETURN(TestIn) // |
| 1485 IF_CONDITION_RETURN(TestInstanceOf) // | 1461 IF_CONDITION_RETURN(TestInstanceOf) // |
| 1462 B(LdaZero), // |
| 1463 B(Return)}, // |
| 1486 #undef IF_CONDITION_RETURN | 1464 #undef IF_CONDITION_RETURN |
| 1487 B(LdaZero), // | |
| 1488 B(Return)}, // | |
| 1489 0, | 1465 0, |
| 1490 {unused, unused, unused, unused, unused, unused}}, | 1466 {unused, unused, unused, unused, unused, unused}}, |
| 1491 }; | 1467 }; |
| 1492 | 1468 |
| 1493 for (size_t i = 0; i < arraysize(snippets); i++) { | 1469 for (size_t i = 0; i < arraysize(snippets); i++) { |
| 1494 Handle<BytecodeArray> bytecode_array = | 1470 Handle<BytecodeArray> bytecode_array = |
| 1495 helper.MakeBytecode(snippets[i].code_snippet, helper.kFunctionName); | 1471 helper.MakeBytecode(snippets[i].code_snippet, helper.kFunctionName); |
| 1496 CheckBytecodeArrayEqual(snippets[i], bytecode_array); | 1472 CheckBytecodeArrayEqual(snippets[i], bytecode_array); |
| 1497 } | 1473 } |
| 1498 } | 1474 } |
| 1499 | 1475 |
| 1500 | 1476 |
| 1501 TEST(DeclareGlobals) { | 1477 TEST(DeclareGlobals) { |
| 1502 InitializedHandleScope handle_scope; | 1478 InitializedHandleScope handle_scope; |
| 1503 BytecodeGeneratorHelper helper; | 1479 BytecodeGeneratorHelper helper; |
| 1504 | 1480 |
| 1505 ExpectedSnippet<InstanceType> snippets[] = { | 1481 ExpectedSnippet<InstanceType> snippets[] = { |
| 1506 {"var a = 1;", | 1482 {"var a = 1;", |
| 1507 5 * kPointerSize, | 1483 5 * kPointerSize, |
| 1508 1, | 1484 1, |
| 1509 45, | 1485 45, |
| 1510 { | 1486 { |
| 1511 B(Ldar), R(Register::function_closure().index()), // | 1487 B(Ldar), R(Register::function_closure().index()), // |
| 1512 B(Star), R(2), // | 1488 B(Star), R(2), // |
| 1513 B(LdaConstant), U8(0), // | 1489 B(LdaConstant), U8(0), // |
| 1514 B(Star), R(3), // | 1490 B(Star), R(3), // |
| 1515 B(CallRuntime), U16(Runtime::kNewScriptContext), R(2), U8(2), // | 1491 B(CallRuntime), U16(Runtime::kNewScriptContext), R(2), U8(2), // |
| 1516 B(PushContext), R(1), // | 1492 B(PushContext), R(1), // |
| 1517 B(LdaConstant), U8(1), // | 1493 B(LdaConstant), U8(1), // |
| 1518 B(Star), R(2), // | 1494 B(Star), R(2), // |
| 1519 B(LdaZero), // | 1495 B(LdaZero), // |
| 1520 B(Star), R(3), // | 1496 B(Star), R(3), // |
| 1521 B(CallRuntime), U16(Runtime::kDeclareGlobals), R(2), U8(2), // | 1497 B(CallRuntime), U16(Runtime::kDeclareGlobals), R(2), U8(2), // |
| 1522 B(LdaConstant), U8(2), // | 1498 B(LdaConstant), U8(2), // |
| 1523 B(Star), R(2), // | 1499 B(Star), R(2), // |
| 1524 B(LdaZero), // | 1500 B(LdaZero), // |
| 1525 B(Star), R(3), // | 1501 B(Star), R(3), // |
| 1526 B(LdaSmi8), U8(1), // | 1502 B(LdaSmi8), U8(1), // |
| 1527 B(Star), R(4), // | 1503 B(Star), R(4), // |
| 1528 B(CallRuntime), U16(Runtime::kInitializeVarGlobal), R(2), // | 1504 B(CallRuntime), U16(Runtime::kInitializeVarGlobal), R(2), U8(3), // |
| 1529 U8(3), // | 1505 B(LdaUndefined), // |
| 1530 B(LdaUndefined), // | 1506 B(Return), // |
| 1531 B(Return) // | |
| 1532 }, | 1507 }, |
| 1533 3, | 1508 3, |
| 1534 {InstanceType::FIXED_ARRAY_TYPE, | 1509 {InstanceType::FIXED_ARRAY_TYPE, InstanceType::FIXED_ARRAY_TYPE, |
| 1535 InstanceType::FIXED_ARRAY_TYPE, | |
| 1536 InstanceType::ONE_BYTE_INTERNALIZED_STRING_TYPE}}, | 1510 InstanceType::ONE_BYTE_INTERNALIZED_STRING_TYPE}}, |
| 1537 {"function f() {}", | 1511 {"function f() {}", |
| 1538 3 * kPointerSize, | 1512 3 * kPointerSize, |
| 1539 1, | 1513 1, |
| 1540 29, | 1514 29, |
| 1541 { | 1515 { |
| 1542 B(Ldar), R(Register::function_closure().index()), // | 1516 B(Ldar), R(Register::function_closure().index()), // |
| 1543 B(Star), R(1), // | 1517 B(Star), R(1), // |
| 1544 B(LdaConstant), U8(0), // | 1518 B(LdaConstant), U8(0), // |
| 1545 B(Star), R(2), // | 1519 B(Star), R(2), // |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1579 B(Star), R(4), // | 1553 B(Star), R(4), // |
| 1580 B(CallRuntime), U16(Runtime::kInitializeVarGlobal), R(2), // | 1554 B(CallRuntime), U16(Runtime::kInitializeVarGlobal), R(2), // |
| 1581 U8(3), // | 1555 U8(3), // |
| 1582 B(LdaSmi8), U8(2), // | 1556 B(LdaSmi8), U8(2), // |
| 1583 B(StaGlobalSloppy), _, // | 1557 B(StaGlobalSloppy), _, // |
| 1584 B(Star), R(0), // | 1558 B(Star), R(0), // |
| 1585 B(Ldar), R(0), // | 1559 B(Ldar), R(0), // |
| 1586 B(Return) // | 1560 B(Return) // |
| 1587 }, | 1561 }, |
| 1588 3, | 1562 3, |
| 1589 {InstanceType::FIXED_ARRAY_TYPE, | 1563 {InstanceType::FIXED_ARRAY_TYPE, InstanceType::FIXED_ARRAY_TYPE, |
| 1590 InstanceType::FIXED_ARRAY_TYPE, | |
| 1591 InstanceType::ONE_BYTE_INTERNALIZED_STRING_TYPE}}, | 1564 InstanceType::ONE_BYTE_INTERNALIZED_STRING_TYPE}}, |
| 1592 {"function f() {}\nf();", | 1565 {"function f() {}\nf();", |
| 1593 4 * kPointerSize, | 1566 4 * kPointerSize, |
| 1594 1, | 1567 1, |
| 1595 43, | 1568 43, |
| 1596 { | 1569 { |
| 1597 B(Ldar), R(Register::function_closure().index()), // | 1570 B(Ldar), R(Register::function_closure().index()), // |
| 1598 B(Star), R(2), // | 1571 B(Star), R(2), // |
| 1599 B(LdaConstant), U8(0), // | 1572 B(LdaConstant), U8(0), // |
| 1600 B(Star), R(3), // | 1573 B(Star), R(3), // |
| (...skipping 26 matching lines...) Expand all Loading... |
| 1627 | 1600 |
| 1628 | 1601 |
| 1629 TEST(BasicLoops) { | 1602 TEST(BasicLoops) { |
| 1630 InitializedHandleScope handle_scope; | 1603 InitializedHandleScope handle_scope; |
| 1631 BytecodeGeneratorHelper helper; | 1604 BytecodeGeneratorHelper helper; |
| 1632 | 1605 |
| 1633 ExpectedSnippet<int> snippets[] = { | 1606 ExpectedSnippet<int> snippets[] = { |
| 1634 {"var x = 0;" | 1607 {"var x = 0;" |
| 1635 "var y = 1;" | 1608 "var y = 1;" |
| 1636 "while (x < 10) {" | 1609 "while (x < 10) {" |
| 1637 " y = y * 10;" | 1610 " y = y * 12;" |
| 1638 " x = x + 1;" | 1611 " x = x + 1;" |
| 1639 "}" | 1612 "}" |
| 1640 "return y;", | 1613 "return y;", |
| 1641 3 * kPointerSize, | 1614 2 * kPointerSize, |
| 1642 1, | 1615 1, |
| 1643 42, | 1616 30, |
| 1644 { | 1617 { |
| 1645 B(LdaZero), // | 1618 B(LdaZero), // |
| 1646 B(Star), R(0), // | 1619 B(Star), R(0), // |
| 1647 B(LdaSmi8), U8(1), // | 1620 B(LdaSmi8), U8(1), // |
| 1648 B(Star), R(1), // | 1621 B(Star), R(1), // |
| 1649 B(Jump), U8(22), // | 1622 B(Jump), U8(14), // |
| 1650 B(Ldar), R(1), // | 1623 B(LdaSmi8), U8(12), // |
| 1651 B(Star), R(2), // | 1624 B(Mul), R(1), // |
| 1625 B(Star), R(1), // |
| 1626 B(LdaSmi8), U8(1), // |
| 1627 B(Add), R(0), // |
| 1628 B(Star), R(0), // |
| 1652 B(LdaSmi8), U8(10), // | 1629 B(LdaSmi8), U8(10), // |
| 1653 B(Mul), R(2), // | 1630 B(TestLessThan), R(0), // |
| 1654 B(Star), R(1), // | 1631 B(JumpIfTrue), U8(-16), // |
| 1655 B(Ldar), R(0), // | |
| 1656 B(Star), R(2), // | |
| 1657 B(LdaSmi8), U8(1), // | |
| 1658 B(Add), R(2), // | |
| 1659 B(Star), R(0), // | |
| 1660 B(Ldar), R(0), // | |
| 1661 B(Star), R(2), // | |
| 1662 B(LdaSmi8), U8(10), // | |
| 1663 B(TestLessThan), R(2), // | |
| 1664 B(JumpIfTrue), U8(-28), // | |
| 1665 B(Ldar), R(1), // | 1632 B(Ldar), R(1), // |
| 1666 B(Return), // | 1633 B(Return), // |
| 1667 }, | 1634 }, |
| 1668 0}, | 1635 0}, |
| 1669 {"var i = 0;" | 1636 {"var i = 0;" |
| 1670 "while(true) {" | 1637 "while(true) {" |
| 1671 " if (i < 0) continue;" | 1638 " if (i < 0) continue;" |
| 1672 " if (i == 3) break;" | 1639 " if (i == 3) break;" |
| 1673 " if (i == 4) break;" | 1640 " if (i == 4) break;" |
| 1674 " if (i == 10) continue;" | 1641 " if (i == 10) continue;" |
| 1675 " if (i == 5) break;" | 1642 " if (i == 5) break;" |
| 1676 " i = i + 1;" | 1643 " i = i + 1;" |
| 1677 "}" | 1644 "}" |
| 1678 "return i;", | 1645 "return i;", |
| 1679 2 * kPointerSize, | 1646 1 * kPointerSize, |
| 1680 1, | 1647 1, |
| 1681 80, | 1648 56, |
| 1682 { | 1649 { |
| 1683 B(LdaZero), // | 1650 B(LdaZero), // |
| 1684 B(Star), R(0), // | 1651 B(Star), R(0), // |
| 1685 B(Jump), U8(71), // | 1652 B(Jump), U8(47), // |
| 1686 B(Ldar), R(0), // | |
| 1687 B(Star), R(1), // | |
| 1688 B(LdaZero), // | 1653 B(LdaZero), // |
| 1689 B(TestLessThan), R(1), // | 1654 B(TestLessThan), R(0), // |
| 1690 B(JumpIfFalse), U8(4), // | 1655 B(JumpIfFalse), U8(4), // |
| 1691 B(Jump), U8(60), // | 1656 B(Jump), U8(40), // |
| 1692 B(Ldar), R(0), // | |
| 1693 B(Star), R(1), // | |
| 1694 B(LdaSmi8), U8(3), // | 1657 B(LdaSmi8), U8(3), // |
| 1695 B(TestEqual), R(1), // | 1658 B(TestEqual), R(0), // |
| 1696 B(JumpIfFalse), U8(4), // | 1659 B(JumpIfFalse), U8(4), // |
| 1697 B(Jump), U8(51), // | 1660 B(Jump), U8(35), // |
| 1698 B(Ldar), R(0), // | |
| 1699 B(Star), R(1), // | |
| 1700 B(LdaSmi8), U8(4), // | 1661 B(LdaSmi8), U8(4), // |
| 1701 B(TestEqual), R(1), // | 1662 B(TestEqual), R(0), // |
| 1702 B(JumpIfFalse), U8(4), // | 1663 B(JumpIfFalse), U8(4), // |
| 1703 B(Jump), U8(39), // | 1664 B(Jump), U8(27), // |
| 1704 B(Ldar), R(0), // | |
| 1705 B(Star), R(1), // | |
| 1706 B(LdaSmi8), U8(10), // | 1665 B(LdaSmi8), U8(10), // |
| 1707 B(TestEqual), R(1), // | 1666 B(TestEqual), R(0), // |
| 1708 B(JumpIfFalse), U8(4), // | 1667 B(JumpIfFalse), U8(4), // |
| 1709 B(Jump), U8(24), // | 1668 B(Jump), U8(16), // |
| 1710 B(Ldar), R(0), // | |
| 1711 B(Star), R(1), // | |
| 1712 B(LdaSmi8), U8(5), // | 1669 B(LdaSmi8), U8(5), // |
| 1713 B(TestEqual), R(1), // | 1670 B(TestEqual), R(0), // |
| 1714 B(JumpIfFalse), U8(4), // | 1671 B(JumpIfFalse), U8(4), // |
| 1715 B(Jump), U8(15), // | 1672 B(Jump), U8(11), // |
| 1716 B(Ldar), R(0), // | |
| 1717 B(Star), R(1), // | |
| 1718 B(LdaSmi8), U8(1), // | 1673 B(LdaSmi8), U8(1), // |
| 1719 B(Add), R(1), // | 1674 B(Add), R(0), // |
| 1720 B(Star), R(0), // | 1675 B(Star), R(0), // |
| 1721 B(LdaTrue), // | 1676 B(LdaTrue), // |
| 1722 B(JumpIfTrue), U8(-70), // | 1677 B(JumpIfTrue), U8(-46), // |
| 1723 B(Ldar), R(0), // | 1678 B(Ldar), R(0), // |
| 1724 B(Return) // | 1679 B(Return), // |
| 1725 }, | 1680 }, |
| 1726 0}, | 1681 0}, |
| 1727 {"var x = 0; var y = 1;" | 1682 {"var x = 0; var y = 1;" |
| 1728 "do {" | 1683 "do {" |
| 1729 " y = y * 10;" | 1684 " y = y * 10;" |
| 1730 " if (x == 5) break;" | 1685 " if (x == 5) break;" |
| 1731 " if (x == 6) continue;" | 1686 " if (x == 6) continue;" |
| 1732 " x = x + 1;" | 1687 " x = x + 1;" |
| 1733 "} while (x < 10);" | 1688 "} while (x < 10);" |
| 1734 "return y;", | 1689 "return y;", |
| 1735 3 * kPointerSize, | 1690 2 * kPointerSize, |
| 1736 1, | 1691 1, |
| 1737 64, | 1692 44, |
| 1738 { | 1693 { |
| 1739 B(LdaZero), // | 1694 B(LdaZero), // |
| 1740 B(Star), R(0), // | 1695 B(Star), R(0), // |
| 1741 B(LdaSmi8), U8(1), // | 1696 B(LdaSmi8), U8(1), // |
| 1742 B(Star), R(1), // | 1697 B(Star), R(1), // |
| 1698 B(LdaSmi8), U8(10), // |
| 1699 B(Mul), R(1), // |
| 1700 B(Star), R(1), // |
| 1701 B(LdaSmi8), U8(5), // |
| 1702 B(TestEqual), R(0), // |
| 1703 B(JumpIfFalse), U8(4), // |
| 1704 B(Jump), U8(22), // |
| 1705 B(LdaSmi8), U8(6), // |
| 1706 B(TestEqual), R(0), // |
| 1707 B(JumpIfFalse), U8(4), // |
| 1708 B(Jump), U8(8), // |
| 1709 B(LdaSmi8), U8(1), // |
| 1710 B(Add), R(0), // |
| 1711 B(Star), R(0), // |
| 1712 B(LdaSmi8), U8(10), // |
| 1713 B(TestLessThan), R(0), // |
| 1714 B(JumpIfTrue), U8(-32), // |
| 1743 B(Ldar), R(1), // | 1715 B(Ldar), R(1), // |
| 1744 B(Star), R(2), // | 1716 B(Return), // |
| 1745 B(LdaSmi8), U8(10), // | |
| 1746 B(Mul), R(2), // | |
| 1747 B(Star), R(1), // | |
| 1748 B(Ldar), R(0), // | |
| 1749 B(Star), R(2), // | |
| 1750 B(LdaSmi8), U8(5), // | |
| 1751 B(TestEqual), R(2), // | |
| 1752 B(JumpIfFalse), U8(4), // | |
| 1753 B(Jump), U8(34), // | |
| 1754 B(Ldar), R(0), // | |
| 1755 B(Star), R(2), // | |
| 1756 B(LdaSmi8), U8(6), // | |
| 1757 B(TestEqual), R(2), // | |
| 1758 B(JumpIfFalse), U8(4), // | |
| 1759 B(Jump), U8(12), // | |
| 1760 B(Ldar), R(0), // | |
| 1761 B(Star), R(2), // | |
| 1762 B(LdaSmi8), U8(1), // | |
| 1763 B(Add), R(2), // | |
| 1764 B(Star), R(0), // | |
| 1765 B(Ldar), R(0), // | |
| 1766 B(Star), R(2), // | |
| 1767 B(LdaSmi8), U8(10), // | |
| 1768 B(TestLessThan), R(2), // | |
| 1769 B(JumpIfTrue), U8(-52), // | |
| 1770 B(Ldar), R(1), // | |
| 1771 B(Return) // | |
| 1772 }, | 1717 }, |
| 1773 0}, | 1718 0}, |
| 1774 {"var x = 0; " | 1719 {"var x = 0; " |
| 1775 "for(;;) {" | 1720 "for(;;) {" |
| 1776 " if (x == 1) break;" | 1721 " if (x == 1) break;" |
| 1777 " x = x + 1;" | 1722 " x = x + 1;" |
| 1778 "}", | 1723 "}", |
| 1779 2 * kPointerSize, | 1724 1 * kPointerSize, |
| 1780 1, | 1725 1, |
| 1781 29, | 1726 21, |
| 1782 { | 1727 { |
| 1783 B(LdaZero), // | 1728 B(LdaZero), // |
| 1784 B(Star), R(0), // | 1729 B(Star), R(0), // |
| 1785 B(Ldar), R(0), // | |
| 1786 B(Star), R(1), // | |
| 1787 B(LdaSmi8), U8(1), // | 1730 B(LdaSmi8), U8(1), // |
| 1788 B(TestEqual), R(1), // | 1731 B(TestEqual), R(0), // |
| 1789 B(JumpIfFalse), U8(4), // | 1732 B(JumpIfFalse), U8(4), // |
| 1790 B(Jump), U8(14), // | 1733 B(Jump), U8(10), // |
| 1791 B(Ldar), R(0), // | |
| 1792 B(Star), R(1), // | |
| 1793 B(LdaSmi8), U8(1), // | 1734 B(LdaSmi8), U8(1), // |
| 1794 B(Add), R(1), // | 1735 B(Add), R(0), // |
| 1795 B(Star), R(0), // | 1736 B(Star), R(0), // |
| 1796 B(Jump), U8(-22), // | 1737 B(Jump), U8(-14), // |
| 1797 B(LdaUndefined), // | 1738 B(LdaUndefined), // |
| 1798 B(Return), // | 1739 B(Return), // |
| 1799 }, | 1740 }, |
| 1800 0}, | 1741 0}, |
| 1801 {"var u = 0;" | 1742 {"var u = 0;" |
| 1802 "for(var i = 0; i < 100; i = i + 1) {" | 1743 "for(var i = 0; i < 100; i = i + 1) {" |
| 1803 " u = u + 1;" | 1744 " u = u + 1;" |
| 1804 " continue;" | 1745 " continue;" |
| 1805 "}", | 1746 "}", |
| 1806 3 * kPointerSize, | 1747 2 * kPointerSize, |
| 1807 1, | 1748 1, |
| 1808 42, | 1749 30, |
| 1809 { | 1750 { |
| 1810 B(LdaZero), // | 1751 B(LdaZero), // |
| 1811 B(Star), R(0), // | 1752 B(Star), R(0), // |
| 1812 B(LdaZero), // | 1753 B(LdaZero), // |
| 1813 B(Star), R(1), // | 1754 B(Star), R(1), // |
| 1814 B(Jump), U8(24), // | 1755 B(Jump), U8(16), // |
| 1815 B(Ldar), R(0), // | |
| 1816 B(Star), R(2), // | |
| 1817 B(LdaSmi8), U8(1), // | 1756 B(LdaSmi8), U8(1), // |
| 1818 B(Add), R(2), // | 1757 B(Add), R(0), // |
| 1819 B(Star), R(0), // | 1758 B(Star), R(0), // |
| 1820 B(Jump), U8(2), // | 1759 B(Jump), U8(2), // |
| 1821 B(Ldar), R(1), // | |
| 1822 B(Star), R(2), // | |
| 1823 B(LdaSmi8), U8(1), // | 1760 B(LdaSmi8), U8(1), // |
| 1824 B(Add), R(2), // | 1761 B(Add), R(1), // |
| 1825 B(Star), R(1), // | 1762 B(Star), R(1), // |
| 1826 B(Ldar), R(1), // | |
| 1827 B(Star), R(2), // | |
| 1828 B(LdaSmi8), U8(100), // | 1763 B(LdaSmi8), U8(100), // |
| 1829 B(TestLessThan), R(2), // | 1764 B(TestLessThan), R(1), // |
| 1830 B(JumpIfTrue), U8(-30), // | 1765 B(JumpIfTrue), U8(-18), // |
| 1831 B(LdaUndefined), // | 1766 B(LdaUndefined), // |
| 1832 B(Return), // | 1767 B(Return), // |
| 1833 }, | 1768 }, |
| 1834 0}, | 1769 0}, |
| 1835 {"var i = 0;" | 1770 {"var i = 0;" |
| 1836 "while(true) {" | 1771 "while(true) {" |
| 1837 " while (i < 3) {" | 1772 " while (i < 3) {" |
| 1838 " if (i == 2) break;" | 1773 " if (i == 2) break;" |
| 1839 " i = i + 1;" | 1774 " i = i + 1;" |
| 1840 " }" | 1775 " }" |
| 1841 " i = i + 1;" | 1776 " i = i + 1;" |
| 1842 " break;" | 1777 " break;" |
| 1843 "}" | 1778 "}" |
| 1844 "return i;", | 1779 "return i;", |
| 1845 2 * kPointerSize, | 1780 1 * kPointerSize, |
| 1846 1, | 1781 1, |
| 1847 57, | 1782 41, |
| 1848 { | 1783 { |
| 1849 B(LdaZero), // | 1784 B(LdaZero), // |
| 1850 B(Star), R(0), // | 1785 B(Star), R(0), // |
| 1851 B(Jump), U8(48), // | 1786 B(Jump), U8(32), // |
| 1852 B(Jump), U8(24), // | 1787 B(Jump), U8(16), // |
| 1853 B(Ldar), R(0), // | |
| 1854 B(Star), R(1), // | |
| 1855 B(LdaSmi8), U8(2), // | 1788 B(LdaSmi8), U8(2), // |
| 1856 B(TestEqual), R(1), // | 1789 B(TestEqual), R(0), // |
| 1857 B(JumpIfFalse), U8(4), // | 1790 B(JumpIfFalse), U8(4), // |
| 1858 B(Jump), U8(22), // | 1791 B(Jump), U8(14), // |
| 1859 B(Ldar), R(0), // | |
| 1860 B(Star), R(1), // | |
| 1861 B(LdaSmi8), U8(1), // | 1792 B(LdaSmi8), U8(1), // |
| 1862 B(Add), R(1), // | 1793 B(Add), R(0), // |
| 1863 B(Star), R(0), // | 1794 B(Star), R(0), // |
| 1864 B(Ldar), R(0), // | |
| 1865 B(Star), R(1), // | |
| 1866 B(LdaSmi8), U8(3), // | 1795 B(LdaSmi8), U8(3), // |
| 1867 B(TestLessThan), R(1), // | 1796 B(TestLessThan), R(0), // |
| 1868 B(JumpIfTrue), U8(-30), // | 1797 B(JumpIfTrue), U8(-18), // |
| 1869 B(Ldar), R(0), // | |
| 1870 B(Star), R(1), // | |
| 1871 B(LdaSmi8), U8(1), // | 1798 B(LdaSmi8), U8(1), // |
| 1872 B(Add), R(1), // | 1799 B(Add), R(0), // |
| 1873 B(Star), R(0), // | 1800 B(Star), R(0), // |
| 1874 B(Jump), U8(5), // | 1801 B(Jump), U8(5), // |
| 1875 B(LdaTrue), // | 1802 B(LdaTrue), // |
| 1876 B(JumpIfTrue), U8(-47), // | 1803 B(JumpIfTrue), U8(-31), // |
| 1877 B(Ldar), R(0), // | 1804 B(Ldar), R(0), // |
| 1878 B(Return), // | 1805 B(Return), // |
| 1879 }, | 1806 }, |
| 1880 0}, | 1807 0}, |
| 1881 }; | 1808 }; |
| 1882 | 1809 |
| 1883 for (size_t i = 0; i < arraysize(snippets); i++) { | 1810 for (size_t i = 0; i < arraysize(snippets); i++) { |
| 1884 Handle<BytecodeArray> bytecode_array = | 1811 Handle<BytecodeArray> bytecode_array = |
| 1885 helper.MakeBytecodeForFunctionBody(snippets[i].code_snippet); | 1812 helper.MakeBytecodeForFunctionBody(snippets[i].code_snippet); |
| 1886 CheckBytecodeArrayEqual(snippets[i], bytecode_array); | 1813 CheckBytecodeArrayEqual(snippets[i], bytecode_array); |
| 1887 } | 1814 } |
| 1888 } | 1815 } |
| 1889 | 1816 |
| 1890 | 1817 |
| 1891 TEST(UnaryOperators) { | 1818 TEST(UnaryOperators) { |
| 1892 InitializedHandleScope handle_scope; | 1819 InitializedHandleScope handle_scope; |
| 1893 BytecodeGeneratorHelper helper; | 1820 BytecodeGeneratorHelper helper; |
| 1894 | 1821 |
| 1895 ExpectedSnippet<int> snippets[] = { | 1822 ExpectedSnippet<int> snippets[] = { |
| 1896 {"var x = 0;" | 1823 {"var x = 0;" |
| 1897 "while (x != 10) {" | 1824 "while (x != 10) {" |
| 1898 " x = x + 10;" | 1825 " x = x + 10;" |
| 1899 "}" | 1826 "}" |
| 1900 "return x;", | 1827 "return x;", |
| 1901 2 * kPointerSize, | 1828 kPointerSize, |
| 1902 1, | 1829 1, |
| 1903 29, | 1830 21, |
| 1904 { | 1831 { |
| 1905 B(LdaZero), // | 1832 B(LdaZero), // |
| 1906 B(Star), R(0), // | 1833 B(Star), R(0), // |
| 1907 B(Jump), U8(12), // | 1834 B(Jump), U8(8), // |
| 1908 B(Ldar), R(0), // | |
| 1909 B(Star), R(1), // | |
| 1910 B(LdaSmi8), U8(10), // | 1835 B(LdaSmi8), U8(10), // |
| 1911 B(Add), R(1), // | 1836 B(Add), R(0), // |
| 1912 B(Star), R(0), // | 1837 B(Star), R(0), // |
| 1913 B(Ldar), R(0), // | |
| 1914 B(Star), R(1), // | |
| 1915 B(LdaSmi8), U8(10), // | 1838 B(LdaSmi8), U8(10), // |
| 1916 B(TestEqual), R(1), // | 1839 B(TestEqual), R(0), // |
| 1917 B(LogicalNot), // | 1840 B(LogicalNot), // |
| 1918 B(JumpIfTrue), U8(-19), // | 1841 B(JumpIfTrue), U8(-11), // |
| 1919 B(Ldar), R(0), // | 1842 B(Ldar), R(0), // |
| 1920 B(Return), // | 1843 B(Return), // |
| 1921 }, | 1844 }, |
| 1922 0}, | 1845 0}, |
| 1923 {"var x = false;" | 1846 {"var x = false;" |
| 1924 "do {" | 1847 "do {" |
| 1925 " x = !x;" | 1848 " x = !x;" |
| 1926 "} while(x == false);" | 1849 "} while(x == false);" |
| 1927 "return x;", | 1850 "return x;", |
| 1928 2 * kPointerSize, | 1851 kPointerSize, |
| 1929 1, | 1852 1, |
| 1930 20, | 1853 16, |
| 1931 { | 1854 { |
| 1932 B(LdaFalse), // | 1855 B(LdaFalse), // |
| 1933 B(Star), R(0), // | 1856 B(Star), R(0), // |
| 1934 B(Ldar), R(0), // | 1857 B(Ldar), R(0), // |
| 1935 B(LogicalNot), // | 1858 B(LogicalNot), // |
| 1936 B(Star), R(0), // | 1859 B(Star), R(0), // |
| 1937 B(Ldar), R(0), // | 1860 B(LdaFalse), // |
| 1938 B(Star), R(1), // | 1861 B(TestEqual), R(0), // |
| 1939 B(LdaFalse), // | 1862 B(JumpIfTrue), U8(-8), // |
| 1940 B(TestEqual), R(1), // | 1863 B(Ldar), R(0), // |
| 1941 B(JumpIfTrue), U8(-12), // | 1864 B(Return), // |
| 1942 B(Ldar), R(0), // | |
| 1943 B(Return), // | |
| 1944 }, | 1865 }, |
| 1945 0}, | 1866 0}, |
| 1946 {"var x = 101;" | 1867 {"var x = 101;" |
| 1947 "return void(x * 3);", | 1868 "return void(x * 3);", |
| 1948 2 * kPointerSize, | 1869 kPointerSize, |
| 1949 1, | 1870 1, |
| 1950 14, | 1871 10, |
| 1951 { | 1872 { |
| 1952 B(LdaSmi8), U8(101), // | 1873 B(LdaSmi8), U8(101), // |
| 1953 B(Star), R(0), // | 1874 B(Star), R(0), // |
| 1954 B(Ldar), R(0), // | |
| 1955 B(Star), R(1), // | |
| 1956 B(LdaSmi8), U8(3), // | 1875 B(LdaSmi8), U8(3), // |
| 1957 B(Mul), R(1), // | 1876 B(Mul), R(0), // |
| 1958 B(LdaUndefined), // | 1877 B(LdaUndefined), // |
| 1959 B(Return), // | 1878 B(Return), // |
| 1960 }, | 1879 }, |
| 1961 0}, | 1880 0}, |
| 1962 {"var x = 1234;" | 1881 {"var x = 1234;" |
| 1963 "var y = void (x * x - 1);" | 1882 "var y = void (x * x - 1);" |
| 1964 "return y;", | 1883 "return y;", |
| 1965 4 * kPointerSize, | 1884 3 * kPointerSize, |
| 1966 1, | 1885 1, |
| 1967 24, | 1886 20, |
| 1968 { | 1887 { |
| 1969 B(LdaConstant), U8(0), // | 1888 B(LdaConstant), U8(0), // |
| 1970 B(Star), R(0), // | 1889 B(Star), R(0), // |
| 1971 B(Ldar), R(0), // | 1890 B(Ldar), R(0), // |
| 1972 B(Star), R(3), // | 1891 B(Mul), R(0), // |
| 1973 B(Ldar), R(0), // | |
| 1974 B(Mul), R(3), // | |
| 1975 B(Star), R(2), // | 1892 B(Star), R(2), // |
| 1976 B(LdaSmi8), U8(1), // | 1893 B(LdaSmi8), U8(1), // |
| 1977 B(Sub), R(2), // | 1894 B(Sub), R(2), // |
| 1978 B(LdaUndefined), // | 1895 B(LdaUndefined), // |
| 1979 B(Star), R(1), // | 1896 B(Star), R(1), // |
| 1980 B(Ldar), R(1), // | 1897 B(Ldar), R(1), // |
| 1981 B(Return), // | 1898 B(Return), // |
| 1982 }, | 1899 }, |
| 1983 1, | 1900 1, |
| 1984 {1234}}, | 1901 {1234}}, |
| 1985 {"var x = 13;" | 1902 {"var x = 13;" |
| 1986 "return typeof(x);", | 1903 "return typeof(x);", |
| 1987 1 * kPointerSize, | 1904 kPointerSize, |
| 1988 1, | 1905 1, |
| 1989 8, | 1906 8, |
| 1990 { | 1907 { |
| 1991 B(LdaSmi8), U8(13), // | 1908 B(LdaSmi8), U8(13), // |
| 1992 B(Star), R(0), // | 1909 B(Star), R(0), // TODO(oth): Ldar R(X) following Star R(X) |
| 1993 B(Ldar), R(0), // | 1910 B(Ldar), R(0), // could be culled in bytecode array builder. |
| 1994 B(TypeOf), // | 1911 B(TypeOf), // |
| 1995 B(Return), // | 1912 B(Return), // |
| 1996 }, | 1913 }, |
| 1997 0}, | 1914 0}, |
| 1998 }; | 1915 }; |
| 1999 | 1916 |
| 2000 for (size_t i = 0; i < arraysize(snippets); i++) { | 1917 for (size_t i = 0; i < arraysize(snippets); i++) { |
| 2001 Handle<BytecodeArray> bytecode_array = | 1918 Handle<BytecodeArray> bytecode_array = |
| 2002 helper.MakeBytecodeForFunctionBody(snippets[i].code_snippet); | 1919 helper.MakeBytecodeForFunctionBody(snippets[i].code_snippet); |
| 2003 CheckBytecodeArrayEqual(snippets[i], bytecode_array); | 1920 CheckBytecodeArrayEqual(snippets[i], bytecode_array); |
| (...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2154 1, | 2071 1, |
| 2155 6, | 2072 6, |
| 2156 { | 2073 { |
| 2157 B(LdaConstant), U8(0), // | 2074 B(LdaConstant), U8(0), // |
| 2158 B(CreateArrayLiteral), U8(0), U8(simple_flags), // | 2075 B(CreateArrayLiteral), U8(0), U8(simple_flags), // |
| 2159 B(Return) // | 2076 B(Return) // |
| 2160 }, | 2077 }, |
| 2161 1, | 2078 1, |
| 2162 {InstanceType::FIXED_ARRAY_TYPE}}, | 2079 {InstanceType::FIXED_ARRAY_TYPE}}, |
| 2163 {"var a = 1; return [ a, a + 1 ];", | 2080 {"var a = 1; return [ a, a + 1 ];", |
| 2164 4 * kPointerSize, | 2081 3 * kPointerSize, |
| 2165 1, | 2082 1, |
| 2166 39, | 2083 35, |
| 2167 { | 2084 { |
| 2168 B(LdaSmi8), U8(1), // | 2085 B(LdaSmi8), U8(1), // |
| 2169 B(Star), R(0), // | 2086 B(Star), R(0), // |
| 2170 B(LdaConstant), U8(0), // | 2087 B(LdaConstant), U8(0), // |
| 2171 B(CreateArrayLiteral), U8(0), U8(3), // | 2088 B(CreateArrayLiteral), U8(0), U8(3), // |
| 2172 B(Star), R(2), // | 2089 B(Star), R(2), // |
| 2173 B(LdaZero), // | 2090 B(LdaZero), // |
| 2174 B(Star), R(1), // | 2091 B(Star), R(1), // |
| 2175 B(Ldar), R(0), // | 2092 B(Ldar), R(0), // |
| 2176 B(KeyedStoreICSloppy), R(2), R(1), U8(vector->GetIndex(slot1)), // | 2093 B(KeyedStoreICSloppy), R(2), R(1), U8(vector->GetIndex(slot1)), // |
| 2177 B(LdaSmi8), U8(1), // | 2094 B(LdaSmi8), U8(1), // |
| 2178 B(Star), R(1), // | 2095 B(Star), R(1), // |
| 2179 B(Ldar), R(0), // | |
| 2180 B(Star), R(3), // | |
| 2181 B(LdaSmi8), U8(1), // | 2096 B(LdaSmi8), U8(1), // |
| 2182 B(Add), R(3), // | 2097 B(Add), R(0), // |
| 2183 B(KeyedStoreICSloppy), R(2), R(1), U8(vector->GetIndex(slot1)), // | 2098 B(KeyedStoreICSloppy), R(2), R(1), U8(vector->GetIndex(slot1)), // |
| 2184 B(Ldar), R(2), // | 2099 B(Ldar), R(2), // |
| 2185 B(Return) // | 2100 B(Return), // |
| 2186 }, | 2101 }, |
| 2187 1, | 2102 1, |
| 2188 {InstanceType::FIXED_ARRAY_TYPE}}, | 2103 {InstanceType::FIXED_ARRAY_TYPE}}, |
| 2189 {"return [ [ 1, 2 ], [ 3 ] ];", | 2104 {"return [ [ 1, 2 ], [ 3 ] ];", |
| 2190 0, | 2105 0, |
| 2191 1, | 2106 1, |
| 2192 6, | 2107 6, |
| 2193 { | 2108 { |
| 2194 B(LdaConstant), U8(0), // | 2109 B(LdaConstant), U8(0), // |
| 2195 B(CreateArrayLiteral), U8(2), U8(deep_elements_flags), // | 2110 B(CreateArrayLiteral), U8(2), U8(deep_elements_flags), // |
| 2196 B(Return) // | 2111 B(Return) // |
| 2197 }, | 2112 }, |
| 2198 1, | 2113 1, |
| 2199 {InstanceType::FIXED_ARRAY_TYPE}}, | 2114 {InstanceType::FIXED_ARRAY_TYPE}}, |
| 2200 {"var a = 1; return [ [ a, 2 ], [ a + 2 ] ];", | 2115 {"var a = 1; return [ [ a, 2 ], [ a + 2 ] ];", |
| 2201 6 * kPointerSize, | 2116 5 * kPointerSize, |
| 2202 1, | 2117 1, |
| 2203 71, | 2118 67, |
| 2204 { | 2119 { |
| 2205 B(LdaSmi8), U8(1), // | 2120 B(LdaSmi8), U8(1), // |
| 2206 B(Star), R(0), // | 2121 B(Star), R(0), // |
| 2207 B(LdaConstant), U8(0), // | 2122 B(LdaConstant), U8(0), // |
| 2208 B(CreateArrayLiteral), U8(2), U8(deep_elements_flags), // | 2123 B(CreateArrayLiteral), U8(2), U8(deep_elements_flags), // |
| 2209 B(Star), R(2), // | 2124 B(Star), R(2), // |
| 2210 B(LdaZero), // | 2125 B(LdaZero), // |
| 2211 B(Star), R(1), // | 2126 B(Star), R(1), // |
| 2212 B(LdaConstant), U8(1), // | 2127 B(LdaConstant), U8(1), // |
| 2213 B(CreateArrayLiteral), U8(0), U8(simple_flags), // | 2128 B(CreateArrayLiteral), U8(0), U8(simple_flags), // |
| 2214 B(Star), R(4), // | 2129 B(Star), R(4), // |
| 2215 B(LdaZero), // | 2130 B(LdaZero), // |
| 2216 B(Star), R(3), // | 2131 B(Star), R(3), // |
| 2217 B(Ldar), R(0), // | 2132 B(Ldar), R(0), // |
| 2218 B(KeyedStoreICSloppy), R(4), R(3), U8(vector->GetIndex(slot1)), // | 2133 B(KeyedStoreICSloppy), R(4), R(3), U8(vector->GetIndex(slot1)), // |
| 2219 B(Ldar), R(4), // | 2134 B(Ldar), R(4), // |
| 2220 B(KeyedStoreICSloppy), R(2), R(1), U8(vector->GetIndex(slot3)), // | 2135 B(KeyedStoreICSloppy), R(2), R(1), U8(vector->GetIndex(slot3)), // |
| 2221 B(LdaSmi8), U8(1), // | 2136 B(LdaSmi8), U8(1), // |
| 2222 B(Star), R(1), // | 2137 B(Star), R(1), // |
| 2223 B(LdaConstant), U8(2), // | 2138 B(LdaConstant), U8(2), // |
| 2224 B(CreateArrayLiteral), U8(1), U8(simple_flags), // | 2139 B(CreateArrayLiteral), U8(1), U8(simple_flags), // |
| 2225 B(Star), R(4), // | 2140 B(Star), R(4), // |
| 2226 B(LdaZero), // | 2141 B(LdaZero), // |
| 2227 B(Star), R(3), // | 2142 B(Star), R(3), // |
| 2228 B(Ldar), R(0), // | |
| 2229 B(Star), R(5), // | |
| 2230 B(LdaSmi8), U8(2), // | 2143 B(LdaSmi8), U8(2), // |
| 2231 B(Add), R(5), // | 2144 B(Add), R(0), // |
| 2232 B(KeyedStoreICSloppy), R(4), R(3), U8(vector->GetIndex(slot2)), // | 2145 B(KeyedStoreICSloppy), R(4), R(3), U8(vector->GetIndex(slot2)), // |
| 2233 B(Ldar), R(4), // | 2146 B(Ldar), R(4), // |
| 2234 B(KeyedStoreICSloppy), R(2), R(1), U8(vector->GetIndex(slot3)), // | 2147 B(KeyedStoreICSloppy), R(2), R(1), U8(vector->GetIndex(slot3)), // |
| 2235 B(Ldar), R(2), // | 2148 B(Ldar), R(2), // |
| 2236 B(Return), // | 2149 B(Return), // |
| 2237 }, | 2150 }, |
| 2238 3, | 2151 3, |
| 2239 {InstanceType::FIXED_ARRAY_TYPE, InstanceType::FIXED_ARRAY_TYPE, | 2152 {InstanceType::FIXED_ARRAY_TYPE, InstanceType::FIXED_ARRAY_TYPE, |
| 2240 InstanceType::FIXED_ARRAY_TYPE}}, | 2153 InstanceType::FIXED_ARRAY_TYPE}}, |
| 2241 }; | 2154 }; |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2294 B(Star), R(2), // | 2207 B(Star), R(2), // |
| 2295 B(Ldar), R(0), // | 2208 B(Ldar), R(0), // |
| 2296 B(StoreICSloppy), R(1), R(2), U8(3), // | 2209 B(StoreICSloppy), R(1), R(2), U8(3), // |
| 2297 B(Ldar), R(1), // | 2210 B(Ldar), R(1), // |
| 2298 B(Return), // | 2211 B(Return), // |
| 2299 }, | 2212 }, |
| 2300 2, | 2213 2, |
| 2301 {InstanceType::FIXED_ARRAY_TYPE, | 2214 {InstanceType::FIXED_ARRAY_TYPE, |
| 2302 InstanceType::ONE_BYTE_INTERNALIZED_STRING_TYPE}}, | 2215 InstanceType::ONE_BYTE_INTERNALIZED_STRING_TYPE}}, |
| 2303 {"var a = 1; return { val: a, val: a + 1 };", | 2216 {"var a = 1; return { val: a, val: a + 1 };", |
| 2304 4 * kPointerSize, | 2217 3 * kPointerSize, |
| 2305 1, | 2218 1, |
| 2306 32, | 2219 26, |
| 2307 { | 2220 { |
| 2308 B(LdaSmi8), U8(1), // | 2221 B(LdaSmi8), U8(1), // |
| 2309 B(Star), R(0), // | 2222 B(Star), R(0), // |
| 2310 B(LdaConstant), U8(0), // | 2223 B(LdaConstant), U8(0), // |
| 2311 B(CreateObjectLiteral), U8(0), U8(deep_elements_flags), // | 2224 B(CreateObjectLiteral), U8(0), U8(deep_elements_flags), // |
| 2312 B(Star), R(1), // | 2225 B(Star), R(1), // |
| 2313 B(Ldar), R(0), // | |
| 2314 B(LdaConstant), U8(1), // | 2226 B(LdaConstant), U8(1), // |
| 2315 B(Star), R(2), // | 2227 B(Star), R(2), // |
| 2316 B(Ldar), R(0), // | |
| 2317 B(Star), R(3), // | |
| 2318 B(LdaSmi8), U8(1), // | 2228 B(LdaSmi8), U8(1), // |
| 2319 B(Add), R(3), // | 2229 B(Add), R(0), // |
| 2320 B(StoreICSloppy), R(1), R(2), U8(3), // | 2230 B(StoreICSloppy), R(1), R(2), U8(3), // |
| 2321 B(Ldar), R(1), // | 2231 B(Ldar), R(1), // |
| 2322 B(Return), // | 2232 B(Return), // |
| 2323 }, | 2233 }, |
| 2324 2, | 2234 2, |
| 2325 {InstanceType::FIXED_ARRAY_TYPE, | 2235 {InstanceType::FIXED_ARRAY_TYPE, |
| 2326 InstanceType::ONE_BYTE_INTERNALIZED_STRING_TYPE}}, | 2236 InstanceType::ONE_BYTE_INTERNALIZED_STRING_TYPE}}, |
| 2327 {"return { func: function() { } };", | 2237 {"return { func: function() { } };", |
| 2328 2 * kPointerSize, | 2238 2 * kPointerSize, |
| 2329 1, | 2239 1, |
| (...skipping 256 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2586 U8(4), // | 2496 U8(4), // |
| 2587 B(LdaConstant), U8(3), // | 2497 B(LdaConstant), U8(3), // |
| 2588 B(ToName), // | 2498 B(ToName), // |
| 2589 B(Star), R(2), // | 2499 B(Star), R(2), // |
| 2590 B(LdaConstant), U8(4), // | 2500 B(LdaConstant), U8(4), // |
| 2591 B(CreateClosure), U8(0), // | 2501 B(CreateClosure), U8(0), // |
| 2592 B(Star), R(3), // | 2502 B(Star), R(3), // |
| 2593 B(LdaZero), // | 2503 B(LdaZero), // |
| 2594 B(Star), R(4), // | 2504 B(Star), R(4), // |
| 2595 B(CallRuntime), U16(Runtime::kDefineGetterPropertyUnchecked), // | 2505 B(CallRuntime), U16(Runtime::kDefineGetterPropertyUnchecked), // |
| 2596 R(1), U8(4), // | 2506 R(1), U8(4), // |
| 2597 B(LdaConstant), U8(3), // | 2507 B(LdaConstant), U8(3), // |
| 2598 B(ToName), // | 2508 B(ToName), // |
| 2599 B(Star), R(2), // | 2509 B(Star), R(2), // |
| 2600 B(LdaConstant), U8(5), // | 2510 B(LdaConstant), U8(5), // |
| 2601 B(CreateClosure), U8(0), // | 2511 B(CreateClosure), U8(0), // |
| 2602 B(Star), R(3), // | 2512 B(Star), R(3), // |
| 2603 B(LdaZero), // | 2513 B(LdaZero), // |
| 2604 B(Star), R(4), // | 2514 B(Star), R(4), // |
| 2605 B(CallRuntime), U16(Runtime::kDefineSetterPropertyUnchecked), // | 2515 B(CallRuntime), U16(Runtime::kDefineSetterPropertyUnchecked), // |
| 2606 R(1), U8(4), // | 2516 R(1), U8(4), // |
| 2607 B(Ldar), R(1), // | 2517 B(Ldar), R(1), // |
| 2608 B(Return), // | 2518 B(Return), // |
| 2609 }, | 2519 }, |
| 2610 6, | 2520 6, |
| 2611 {InstanceType::ONE_BYTE_INTERNALIZED_STRING_TYPE, | 2521 {InstanceType::ONE_BYTE_INTERNALIZED_STRING_TYPE, |
| 2612 InstanceType::FIXED_ARRAY_TYPE, | 2522 InstanceType::FIXED_ARRAY_TYPE, |
| 2613 InstanceType::ONE_BYTE_INTERNALIZED_STRING_TYPE, | 2523 InstanceType::ONE_BYTE_INTERNALIZED_STRING_TYPE, |
| 2614 InstanceType::ONE_BYTE_INTERNALIZED_STRING_TYPE, | 2524 InstanceType::ONE_BYTE_INTERNALIZED_STRING_TYPE, |
| 2615 InstanceType::SHARED_FUNCTION_INFO_TYPE, | 2525 InstanceType::SHARED_FUNCTION_INFO_TYPE, |
| 2616 InstanceType::SHARED_FUNCTION_INFO_TYPE}}, | 2526 InstanceType::SHARED_FUNCTION_INFO_TYPE}}, |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2658 B(LdaConstant), U8(4), // | 2568 B(LdaConstant), U8(4), // |
| 2659 B(Star), R(6), // | 2569 B(Star), R(6), // |
| 2660 B(LdaConstant), U8(5), // | 2570 B(LdaConstant), U8(5), // |
| 2661 B(CreateClosure), U8(1), // | 2571 B(CreateClosure), U8(1), // |
| 2662 B(StoreICSloppy), R(5), R(6), U8(3), // | 2572 B(StoreICSloppy), R(5), R(6), U8(3), // |
| 2663 B(CallRuntime), U16(Runtime::kToFastProperties), R(5), U8(1), // | 2573 B(CallRuntime), U16(Runtime::kToFastProperties), R(5), U8(1), // |
| 2664 B(Ldar), R(5), // | 2574 B(Ldar), R(5), // |
| 2665 B(Star), R(4), // | 2575 B(Star), R(4), // |
| 2666 B(CallRuntime), U16(Runtime::kInitializeVarGlobal), R(2), U8(3), // | 2576 B(CallRuntime), U16(Runtime::kInitializeVarGlobal), R(2), U8(3), // |
| 2667 B(LdaUndefined), // | 2577 B(LdaUndefined), // |
| 2668 B(Return), // | 2578 B(Return), |
| 2669 }, | 2579 }, |
| 2670 6, | 2580 6, |
| 2671 {InstanceType::FIXED_ARRAY_TYPE, | 2581 {InstanceType::FIXED_ARRAY_TYPE, |
| 2672 InstanceType::FIXED_ARRAY_TYPE, | 2582 InstanceType::FIXED_ARRAY_TYPE, |
| 2673 InstanceType::ONE_BYTE_INTERNALIZED_STRING_TYPE, | 2583 InstanceType::ONE_BYTE_INTERNALIZED_STRING_TYPE, |
| 2674 InstanceType::FIXED_ARRAY_TYPE, | 2584 InstanceType::FIXED_ARRAY_TYPE, |
| 2675 InstanceType::ONE_BYTE_INTERNALIZED_STRING_TYPE, | 2585 InstanceType::ONE_BYTE_INTERNALIZED_STRING_TYPE, |
| 2676 InstanceType::SHARED_FUNCTION_INFO_TYPE}}, | 2586 InstanceType::SHARED_FUNCTION_INFO_TYPE}}, |
| 2677 }; | 2587 }; |
| 2678 | 2588 |
| 2679 for (size_t i = 0; i < arraysize(snippets); i++) { | 2589 for (size_t i = 0; i < arraysize(snippets); i++) { |
| 2680 Handle<BytecodeArray> bytecode_array = | 2590 Handle<BytecodeArray> bytecode_array = |
| 2681 helper.MakeTopLevelBytecode(snippets[i].code_snippet); | 2591 helper.MakeTopLevelBytecode(snippets[i].code_snippet); |
| 2682 CheckBytecodeArrayEqual(snippets[i], bytecode_array); | 2592 CheckBytecodeArrayEqual(snippets[i], bytecode_array); |
| 2683 } | 2593 } |
| 2684 } | 2594 } |
| 2685 | 2595 |
| 2686 | 2596 |
| 2687 TEST(TryCatch) { | 2597 TEST(TryCatch) { |
| 2688 InitializedHandleScope handle_scope; | 2598 InitializedHandleScope handle_scope; |
| 2689 BytecodeGeneratorHelper helper; | 2599 BytecodeGeneratorHelper helper; |
| 2690 | 2600 |
| 2691 // TODO(rmcilroy): modify tests when we have real try catch support. | 2601 // TODO(rmcilroy): modify tests when we have real try catch support. |
| 2692 ExpectedSnippet<int> snippets[] = { | 2602 ExpectedSnippet<int> snippets[] = { |
| 2693 {"try { return 1; } catch(e) { return 2; }", | 2603 {"try { return 1; } catch(e) { return 2; }", |
| 2694 1 * kPointerSize, | 2604 kPointerSize, |
| 2695 1, | 2605 1, |
| 2696 5, | 2606 5, |
| 2697 { | 2607 { |
| 2698 B(LdaSmi8), U8(1), // | 2608 B(LdaSmi8), U8(1), // |
| 2699 B(Return), // | 2609 B(Return), // |
| 2700 B(LdaUndefined), // | 2610 B(LdaUndefined), // |
| 2701 B(Return), // | 2611 B(Return), // |
| 2702 }, | 2612 }, |
| 2703 0}, | 2613 0}, |
| 2704 }; | 2614 }; |
| 2705 | 2615 |
| 2706 for (size_t i = 0; i < arraysize(snippets); i++) { | 2616 for (size_t i = 0; i < arraysize(snippets); i++) { |
| 2707 Handle<BytecodeArray> bytecode_array = | 2617 Handle<BytecodeArray> bytecode_array = |
| 2708 helper.MakeBytecodeForFunctionBody(snippets[i].code_snippet); | 2618 helper.MakeBytecodeForFunctionBody(snippets[i].code_snippet); |
| 2709 CheckBytecodeArrayEqual(snippets[i], bytecode_array); | 2619 CheckBytecodeArrayEqual(snippets[i], bytecode_array); |
| 2710 } | 2620 } |
| 2711 } | 2621 } |
| 2712 | 2622 |
| 2713 | 2623 |
| 2714 TEST(TryFinally) { | 2624 TEST(TryFinally) { |
| 2715 InitializedHandleScope handle_scope; | 2625 InitializedHandleScope handle_scope; |
| 2716 BytecodeGeneratorHelper helper; | 2626 BytecodeGeneratorHelper helper; |
| 2717 | 2627 |
| 2718 // TODO(rmcilroy): modify tests when we have real try finally support. | 2628 // TODO(rmcilroy): modify tests when we have real try finally support. |
| 2719 ExpectedSnippet<int> snippets[] = { | 2629 ExpectedSnippet<int> snippets[] = { |
| 2720 {"var a = 1; try { a = 2; } finally { a = 3; }", | 2630 {"var a = 1; try { a = 2; } finally { a = 3; }", |
| 2721 1 * kPointerSize, | 2631 kPointerSize, |
| 2722 1, | 2632 1, |
| 2723 14, | 2633 14, |
| 2724 { | 2634 { |
| 2725 B(LdaSmi8), U8(1), // | 2635 B(LdaSmi8), U8(1), // |
| 2726 B(Star), R(0), // | 2636 B(Star), R(0), // |
| 2727 B(LdaSmi8), U8(2), // | 2637 B(LdaSmi8), U8(2), // |
| 2728 B(Star), R(0), // | 2638 B(Star), R(0), // |
| 2729 B(LdaSmi8), U8(3), // | 2639 B(LdaSmi8), U8(3), // |
| 2730 B(Star), R(0), // | 2640 B(Star), R(0), // |
| 2731 B(LdaUndefined), // | 2641 B(LdaUndefined), // |
| (...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2943 B(Star), R(1), // | 2853 B(Star), R(1), // |
| 2944 B(Call), R(1), R(2), U8(0), // | 2854 B(Call), R(1), R(2), U8(0), // |
| 2945 B(LdaContextSlot), R(0), U8(first_context_slot), // | 2855 B(LdaContextSlot), R(0), U8(first_context_slot), // |
| 2946 B(Return), // | 2856 B(Return), // |
| 2947 }, | 2857 }, |
| 2948 1, | 2858 1, |
| 2949 {InstanceType::SHARED_FUNCTION_INFO_TYPE}}, | 2859 {InstanceType::SHARED_FUNCTION_INFO_TYPE}}, |
| 2950 {"'use strict'; let a = 1; { let b = 2; return function() { a + b; }; }", | 2860 {"'use strict'; let a = 1; { let b = 2; return function() { a + b; }; }", |
| 2951 4 * kPointerSize, | 2861 4 * kPointerSize, |
| 2952 1, | 2862 1, |
| 2953 51, | 2863 49, |
| 2954 { | 2864 { |
| 2955 B(CallRuntime), U16(Runtime::kNewFunctionContext), // | 2865 B(CallRuntime), U16(Runtime::kNewFunctionContext), // |
| 2956 R(closure), U8(1), // | 2866 R(closure), U8(1), // |
| 2957 B(PushContext), R(0), // | 2867 B(PushContext), R(0), // |
| 2958 B(LdaTheHole), // | 2868 B(LdaTheHole), // |
| 2959 B(StaContextSlot), R(0), U8(first_context_slot), // | 2869 B(StaContextSlot), R(0), U8(first_context_slot), // |
| 2960 B(LdaConstant), U8(0), // | |
| 2961 B(LdaSmi8), U8(1), // | 2870 B(LdaSmi8), U8(1), // |
| 2962 B(StaContextSlot), R(0), U8(first_context_slot), // | 2871 B(StaContextSlot), R(0), U8(first_context_slot), // |
| 2963 B(LdaConstant), U8(1), // | 2872 B(LdaConstant), U8(0), // |
| 2964 B(Star), R(2), // | 2873 B(Star), R(2), // |
| 2965 B(Ldar), R(closure), // | 2874 B(Ldar), R(closure), // |
| 2966 B(Star), R(3), // | 2875 B(Star), R(3), // |
| 2967 B(CallRuntime), U16(Runtime::kPushBlockContext), R(2), U8(2), // | 2876 B(CallRuntime), U16(Runtime::kPushBlockContext), R(2), U8(2), // |
| 2968 B(PushContext), R(1), // | 2877 B(PushContext), R(1), // |
| 2969 B(LdaTheHole), // | 2878 B(LdaTheHole), // |
| 2970 B(StaContextSlot), R(1), U8(first_context_slot), // | 2879 B(StaContextSlot), R(1), U8(first_context_slot), // |
| 2971 B(LdaSmi8), U8(2), // | 2880 B(LdaSmi8), U8(2), // |
| 2972 B(StaContextSlot), R(1), U8(first_context_slot), // | 2881 B(StaContextSlot), R(1), U8(first_context_slot), // |
| 2973 B(LdaConstant), U8(2), // | 2882 B(LdaConstant), U8(1), // |
| 2974 B(CreateClosure), U8(0), // | 2883 B(CreateClosure), U8(0), // |
| 2975 B(Return), // | 2884 B(Return), // |
| 2976 // TODO(rmcilroy): Dead code after this point due to return in nested | 2885 // TODO(rmcilroy): Dead code after this point due to return in nested |
| 2977 // block - investigate eliminating this. | 2886 // block - investigate eliminating this. |
| 2978 B(PopContext), R(0), | 2887 B(PopContext), R(0), |
| 2979 B(LdaUndefined), // | 2888 B(LdaUndefined), // |
| 2980 B(Return), // | 2889 B(Return), // |
| 2981 }, | 2890 }, |
| 2982 3, | 2891 2, |
| 2983 {InstanceType::ONE_BYTE_INTERNALIZED_STRING_TYPE, | 2892 {InstanceType::FIXED_ARRAY_TYPE, |
| 2984 InstanceType::FIXED_ARRAY_TYPE, | |
| 2985 InstanceType::SHARED_FUNCTION_INFO_TYPE}}, | 2893 InstanceType::SHARED_FUNCTION_INFO_TYPE}}, |
| 2986 }; | 2894 }; |
| 2987 | 2895 |
| 2988 for (size_t i = 0; i < arraysize(snippets); i++) { | 2896 for (size_t i = 0; i < arraysize(snippets); i++) { |
| 2989 Handle<BytecodeArray> bytecode_array = | 2897 Handle<BytecodeArray> bytecode_array = |
| 2990 helper.MakeBytecodeForFunctionBody(snippets[i].code_snippet); | 2898 helper.MakeBytecodeForFunctionBody(snippets[i].code_snippet); |
| 2991 CheckBytecodeArrayEqual(snippets[i], bytecode_array); | 2899 CheckBytecodeArrayEqual(snippets[i], bytecode_array); |
| 2992 } | 2900 } |
| 2993 } | 2901 } |
| 2994 | 2902 |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3073 for (size_t i = 0; i < arraysize(snippets); i++) { | 2981 for (size_t i = 0; i < arraysize(snippets); i++) { |
| 3074 Handle<BytecodeArray> bytecode_array = | 2982 Handle<BytecodeArray> bytecode_array = |
| 3075 helper.MakeBytecodeForFunction(snippets[i].code_snippet); | 2983 helper.MakeBytecodeForFunction(snippets[i].code_snippet); |
| 3076 CheckBytecodeArrayEqual(snippets[i], bytecode_array); | 2984 CheckBytecodeArrayEqual(snippets[i], bytecode_array); |
| 3077 } | 2985 } |
| 3078 } | 2986 } |
| 3079 | 2987 |
| 3080 } // namespace interpreter | 2988 } // namespace interpreter |
| 3081 } // namespace internal | 2989 } // namespace internal |
| 3082 } // namespace v8 | 2990 } // namespace v8 |
| OLD | NEW |