| 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 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 222 helper.MakeBytecodeForFunctionBody(snippets[i].code_snippet); | 224 helper.MakeBytecodeForFunctionBody(snippets[i].code_snippet); |
| 223 CheckBytecodeArrayEqual(snippets[i], bytecode_array); | 225 CheckBytecodeArrayEqual(snippets[i], bytecode_array); |
| 224 } | 226 } |
| 225 } | 227 } |
| 226 | 228 |
| 227 | 229 |
| 228 TEST(PrimitiveExpressions) { | 230 TEST(PrimitiveExpressions) { |
| 229 InitializedHandleScope handle_scope; | 231 InitializedHandleScope handle_scope; |
| 230 BytecodeGeneratorHelper helper; | 232 BytecodeGeneratorHelper helper; |
| 231 | 233 |
| 232 ExpectedSnippet<int> snippets[] = { | 234 ExpectedSnippet<int> snippets[] = {{"var x = 0; return x;", |
| 233 {"var x = 0; return x;", | 235 kPointerSize, |
| 234 kPointerSize, | 236 1, |
| 235 1, | 237 6, |
| 236 6, | 238 {B(LdaZero), // |
| 237 {B(LdaZero), // | 239 B(Star), R(0), // |
| 238 B(Star), R(0), // | 240 B(Ldar), R(0), // |
| 239 B(Ldar), R(0), // | 241 B(Return)}, |
| 240 B(Return)}, | 242 0}, |
| 241 0}, | 243 {"var x = 0; return x + 3;", |
| 242 {"var x = 0; return x + 3;", | 244 kPointerSize, |
| 243 2 * kPointerSize, | 245 1, |
| 244 1, | 246 8, |
| 245 12, | 247 {B(LdaZero), // |
| 246 {B(LdaZero), // | 248 B(Star), R(0), // |
| 247 B(Star), R(0), // | 249 B(LdaSmi8), U8(3), // |
| 248 B(Ldar), R(0), // Easy to spot r1 not really needed here. | 250 B(Add), R(0), // |
| 249 B(Star), R(1), // Dead store. | 251 B(Return)}, |
| 250 B(LdaSmi8), U8(3), // | 252 0}, |
| 251 B(Add), R(1), // | 253 {"var x = 0; return x - 3;", |
| 252 B(Return)}, | 254 kPointerSize, |
| 253 0}, | 255 1, |
| 254 {"var x = 0; return x - 3;", | 256 8, |
| 255 2 * kPointerSize, | 257 {B(LdaZero), // |
| 256 1, | 258 B(Star), R(0), // |
| 257 12, | 259 B(LdaSmi8), U8(3), // |
| 258 {B(LdaZero), // | 260 B(Sub), R(0), // |
| 259 B(Star), R(0), // | 261 B(Return)}, |
| 260 B(Ldar), R(0), // Easy to spot r1 not really needed here. | 262 0}, |
| 261 B(Star), R(1), // Dead store. | 263 {"var x = 4; return x * 3;", |
| 262 B(LdaSmi8), U8(3), // | 264 kPointerSize, |
| 263 B(Sub), R(1), // | 265 1, |
| 264 B(Return)}, | 266 9, |
| 265 0}, | 267 {B(LdaSmi8), U8(4), // |
| 266 {"var x = 4; return x * 3;", | 268 B(Star), R(0), // |
| 267 2 * kPointerSize, | 269 B(LdaSmi8), U8(3), // |
| 268 1, | 270 B(Mul), R(0), // |
| 269 13, | 271 B(Return)}, |
| 270 {B(LdaSmi8), U8(4), // | 272 0}, |
| 271 B(Star), R(0), // | 273 {"var x = 4; return x / 3;", |
| 272 B(Ldar), R(0), // Easy to spot r1 not really needed here. | 274 kPointerSize, |
| 273 B(Star), R(1), // Dead store. | 275 1, |
| 274 B(LdaSmi8), U8(3), // | 276 9, |
| 275 B(Mul), R(1), // | 277 {B(LdaSmi8), U8(4), // |
| 276 B(Return)}, | 278 B(Star), R(0), // |
| 277 0}, | 279 B(LdaSmi8), U8(3), // |
| 278 {"var x = 4; return x / 3;", | 280 B(Div), R(0), // |
| 279 2 * kPointerSize, | 281 B(Return)}, |
| 280 1, | 282 0}, |
| 281 13, | 283 {"var x = 4; return x % 3;", |
| 282 {B(LdaSmi8), U8(4), // | 284 kPointerSize, |
| 283 B(Star), R(0), // | 285 1, |
| 284 B(Ldar), R(0), // Easy to spot r1 not really needed here. | 286 9, |
| 285 B(Star), R(1), // Dead store. | 287 {B(LdaSmi8), U8(4), // |
| 286 B(LdaSmi8), U8(3), // | 288 B(Star), R(0), // |
| 287 B(Div), R(1), // | 289 B(LdaSmi8), U8(3), // |
| 288 B(Return)}, | 290 B(Mod), R(0), // |
| 289 0}, | 291 B(Return)}, |
| 290 {"var x = 4; return x % 3;", | 292 0}, |
| 291 2 * kPointerSize, | 293 {"var x = 1; return x | 2;", |
| 292 1, | 294 kPointerSize, |
| 293 13, | 295 1, |
| 294 {B(LdaSmi8), U8(4), // | 296 9, |
| 295 B(Star), R(0), // | 297 {B(LdaSmi8), U8(1), // |
| 296 B(Ldar), R(0), // Easy to spot r1 not really needed here. | 298 B(Star), R(0), // |
| 297 B(Star), R(1), // Dead store. | 299 B(LdaSmi8), U8(2), // |
| 298 B(LdaSmi8), U8(3), // | 300 B(BitwiseOr), R(0), // |
| 299 B(Mod), R(1), // | 301 B(Return)}, |
| 300 B(Return)}, | 302 0}, |
| 301 0}, | 303 {"var x = 1; return x ^ 2;", |
| 302 {"var x = 1; return x | 2;", | 304 kPointerSize, |
| 303 2 * kPointerSize, | 305 1, |
| 304 1, | 306 9, |
| 305 13, | 307 {B(LdaSmi8), U8(1), // |
| 306 {B(LdaSmi8), U8(1), // | 308 B(Star), R(0), // |
| 307 B(Star), R(0), // | 309 B(LdaSmi8), U8(2), // |
| 308 B(Ldar), R(0), // Easy to spot r1 not really needed here. | 310 B(BitwiseXor), R(0), // |
| 309 B(Star), R(1), // Dead store. | 311 B(Return)}, |
| 310 B(LdaSmi8), U8(2), // | 312 0}, |
| 311 B(BitwiseOr), R(1), // | 313 {"var x = 1; return x & 2;", |
| 312 B(Return)}, | 314 kPointerSize, |
| 313 0}, | 315 1, |
| 314 {"var x = 1; return x ^ 2;", | 316 9, |
| 315 2 * kPointerSize, | 317 {B(LdaSmi8), U8(1), // |
| 316 1, | 318 B(Star), R(0), // |
| 317 13, | 319 B(LdaSmi8), U8(2), // |
| 318 {B(LdaSmi8), U8(1), // | 320 B(BitwiseAnd), R(0), // |
| 319 B(Star), R(0), // | 321 B(Return)}, |
| 320 B(Ldar), R(0), // Easy to spot r1 not really needed here. | 322 0}, |
| 321 B(Star), R(1), // Dead store. | 323 {"var x = 10; return x << 3;", |
| 322 B(LdaSmi8), U8(2), // | 324 kPointerSize, |
| 323 B(BitwiseXor), R(1), // | 325 1, |
| 324 B(Return)}, | 326 9, |
| 325 0}, | 327 {B(LdaSmi8), U8(10), // |
| 326 {"var x = 1; return x & 2;", | 328 B(Star), R(0), // |
| 327 2 * kPointerSize, | 329 B(LdaSmi8), U8(3), // |
| 328 1, | 330 B(ShiftLeft), R(0), // |
| 329 13, | 331 B(Return)}, |
| 330 {B(LdaSmi8), U8(1), // | 332 0}, |
| 331 B(Star), R(0), // | 333 {"var x = 10; return x >> 3;", |
| 332 B(Ldar), R(0), // Easy to spot r1 not really needed here. | 334 kPointerSize, |
| 333 B(Star), R(1), // Dead store. | 335 1, |
| 334 B(LdaSmi8), U8(2), // | 336 9, |
| 335 B(BitwiseAnd), R(1), // | 337 {B(LdaSmi8), U8(10), // |
| 336 B(Return)}, | 338 B(Star), R(0), // |
| 337 0}, | 339 B(LdaSmi8), U8(3), // |
| 338 {"var x = 10; return x << 3;", | 340 B(ShiftRight), R(0), // |
| 339 2 * kPointerSize, | 341 B(Return)}, |
| 340 1, | 342 0}, |
| 341 13, | 343 {"var x = 10; return x >>> 3;", |
| 342 {B(LdaSmi8), U8(10), // | 344 kPointerSize, |
| 343 B(Star), R(0), // | 345 1, |
| 344 B(Ldar), R(0), // Easy to spot r1 not really needed here. | 346 9, |
| 345 B(Star), R(1), // Dead store. | 347 {B(LdaSmi8), U8(10), // |
| 346 B(LdaSmi8), U8(3), // | 348 B(Star), R(0), // |
| 347 B(ShiftLeft), R(1), // | 349 B(LdaSmi8), U8(3), // |
| 348 B(Return)}, | 350 B(ShiftRightLogical), R(0), // |
| 349 0}, | 351 B(Return)}, |
| 350 {"var x = 10; return x >> 3;", | 352 0}, |
| 351 2 * kPointerSize, | 353 {"var x = 0; return (x, 3);", |
| 352 1, | 354 kPointerSize, |
| 353 13, | 355 1, |
| 354 {B(LdaSmi8), U8(10), // | 356 6, |
| 355 B(Star), R(0), // | 357 {B(LdaZero), // |
| 356 B(Ldar), R(0), // Easy to spot r1 not really needed here. | 358 B(Star), R(0), // |
| 357 B(Star), R(1), // Dead store. | 359 B(LdaSmi8), U8(3), // |
| 358 B(LdaSmi8), U8(3), // | 360 B(Return)}, |
| 359 B(ShiftRight), R(1), // | 361 0}}; |
| 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, | |
| 377 8, | |
| 378 {B(LdaZero), // | |
| 379 B(Star), R(0), // | |
| 380 B(Ldar), R(0), // | |
| 381 B(LdaSmi8), U8(3), // | |
| 382 B(Return)}, | |
| 383 0}}; | |
| 384 | 362 |
| 385 for (size_t i = 0; i < arraysize(snippets); i++) { | 363 for (size_t i = 0; i < arraysize(snippets); i++) { |
| 386 Handle<BytecodeArray> bytecode_array = | 364 Handle<BytecodeArray> bytecode_array = |
| 387 helper.MakeBytecodeForFunctionBody(snippets[i].code_snippet); | 365 helper.MakeBytecodeForFunctionBody(snippets[i].code_snippet); |
| 388 CheckBytecodeArrayEqual(snippets[i], bytecode_array); | 366 CheckBytecodeArrayEqual(snippets[i], bytecode_array); |
| 389 } | 367 } |
| 390 } | 368 } |
| 391 | 369 |
| 392 | 370 |
| 393 TEST(LogicalExpressions) { | 371 TEST(LogicalExpressions) { |
| (...skipping 17 matching lines...) Expand all Loading... |
| 411 1 * kPointerSize, | 389 1 * kPointerSize, |
| 412 1, | 390 1, |
| 413 10, | 391 10, |
| 414 {B(LdaZero), // | 392 {B(LdaZero), // |
| 415 B(Star), R(0), // | 393 B(Star), R(0), // |
| 416 B(Ldar), R(0), // | 394 B(Ldar), R(0), // |
| 417 B(JumpIfToBooleanFalse), U8(4), // | 395 B(JumpIfToBooleanFalse), U8(4), // |
| 418 B(LdaSmi8), U8(3), // | 396 B(LdaSmi8), U8(3), // |
| 419 B(Return)}, | 397 B(Return)}, |
| 420 0}, | 398 0}, |
| 399 {"var x = 0; return x || (1, 2, 3);", |
| 400 1 * kPointerSize, |
| 401 1, |
| 402 14, |
| 403 {B(LdaZero), // |
| 404 B(Star), R(0), // |
| 405 B(Ldar), R(0), // |
| 406 B(JumpIfToBooleanTrue), U8(8), // |
| 407 B(LdaSmi8), U8(1), // |
| 408 B(LdaSmi8), U8(2), // |
| 409 B(LdaSmi8), U8(3), // |
| 410 B(Return)}, |
| 411 0}, |
| 412 {"var a = 2, b = 3, c = 4; return a || (a, b, a, b, c = 5, 3);", |
| 413 3 * kPointerSize, |
| 414 1, |
| 415 23, |
| 416 {B(LdaSmi8), U8(2), // |
| 417 B(Star), R(0), // |
| 418 B(LdaSmi8), U8(3), // |
| 419 B(Star), R(1), // |
| 420 B(LdaSmi8), U8(4), // |
| 421 B(Star), R(2), // |
| 422 B(Ldar), R(0), // |
| 423 B(JumpIfToBooleanTrue), U8(8), // |
| 424 B(LdaSmi8), U8(5), // |
| 425 B(Star), R(2), // |
| 426 B(LdaSmi8), U8(3), // |
| 427 B(Return)}, |
| 428 0}, |
| 421 {"var x = 1; var a = 2, b = 3; return x || (" | 429 {"var x = 1; var a = 2, b = 3; return x || (" |
| 422 #define X "a, b, a, b, " | 430 #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 | 431 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 | 432 #undef X |
| 425 "3);", | 433 "3);", |
| 426 3 * kPointerSize, | 434 3 * kPointerSize, |
| 427 1, | 435 1, |
| 428 283, | 436 283, |
| 429 {B(LdaSmi8), U8(1), // | 437 {B(LdaSmi8), U8(1), // |
| 430 B(Star), R(0), // | 438 B(Star), R(0), // |
| 431 B(LdaSmi8), U8(2), // | 439 B(LdaSmi8), U8(2), // |
| 432 B(Star), R(1), // | 440 B(Star), R(1), // |
| 433 B(LdaSmi8), U8(3), // | 441 B(LdaSmi8), U8(3), // |
| 434 B(Star), R(2), // | 442 B(Star), R(2), // |
| 435 B(Ldar), R(0), // | 443 B(Ldar), R(0), // |
| 436 B(JumpIfToBooleanTrueConstant), U8(0), // | 444 B(JumpIfToBooleanTrueConstant), U8(0), // |
| 437 #define X B(Ldar), R(1), B(Ldar), R(2), B(Ldar), R(1), B(Ldar), R(2), | 445 #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 | 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 |
| 439 #undef X | 447 #undef X |
| 440 B(LdaSmi8), U8(3), // | 448 B(LdaSmi8), U8(3), // |
| 441 B(Return)}, | 449 B(Return)}, |
| 442 1, | 450 1, |
| 443 {268, 0, 0, 0}}, | 451 {268, 0, 0, 0}}, |
| 444 {"var x = 0; var a = 2, b = 3; return x && (" | 452 {"var x = 0; var a = 2, b = 3; return x && (" |
| 445 #define X "a, b, a, b, " | 453 #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 | 454 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 | 455 #undef X |
| 448 "3);", | 456 "3);", |
| 449 3 * kPointerSize, | 457 3 * kPointerSize, |
| 450 1, | 458 1, |
| 451 282, | 459 282, |
| 452 {B(LdaZero), // | 460 {B(LdaZero), // |
| 453 B(Star), R(0), // | 461 B(Star), R(0), // |
| 454 B(LdaSmi8), U8(2), // | 462 B(LdaSmi8), U8(2), // |
| 455 B(Star), R(1), // | 463 B(Star), R(1), // |
| 456 B(LdaSmi8), U8(3), // | 464 B(LdaSmi8), U8(3), // |
| 457 B(Star), R(2), // | 465 B(Star), R(2), // |
| 458 B(Ldar), R(0), // | 466 B(Ldar), R(0), // |
| 459 B(JumpIfToBooleanFalseConstant), U8(0), // | 467 B(JumpIfToBooleanFalseConstant), U8(0), // |
| 460 #define X B(Ldar), R(1), B(Ldar), R(2), B(Ldar), R(1), B(Ldar), R(2), | 468 #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 | 469 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 | 470 #undef X |
| 463 B(LdaSmi8), U8(3), // | 471 B(LdaSmi8), U8(3), // |
| 464 B(Return)}, | 472 B(Return)}, |
| 465 1, | 473 1, |
| 466 {268, 0, 0, 0}}, | 474 {268, 0, 0, 0}}, |
| 467 {"return 0 && 3;", | 475 {"return 0 && 3;", |
| 468 0 * kPointerSize, | 476 0 * kPointerSize, |
| 469 1, | 477 1, |
| 470 2, | 478 2, |
| 471 {B(LdaZero), // | 479 {B(LdaZero), // |
| 472 B(Return)}, | 480 B(Return)}, |
| 473 0}, | 481 0}, |
| 474 {"return 1 || 3;", | 482 {"return 1 || 3;", |
| 475 0 * kPointerSize, | 483 0 * kPointerSize, |
| 476 1, | 484 1, |
| 477 3, | 485 3, |
| 478 {B(LdaSmi8), U8(1), // | 486 {B(LdaSmi8), U8(1), // |
| 479 B(Return)}, | 487 B(Return)}, |
| 480 0}, | 488 0}, |
| 481 {"var x = 1; return x && 3 || 0, 1;", | 489 {"var x = 1; return x && 3 || 0, 1;", |
| 482 1 * kPointerSize, | 490 1 * kPointerSize, |
| 483 1, | 491 1, |
| 484 16, | 492 16, |
| 485 {B(LdaSmi8), U8(1), // | 493 {B(LdaSmi8), U8(1), // |
| 486 B(Star), R(0), // | 494 B(Star), R(0), // |
| 487 B(Ldar), R(0), // | 495 B(Ldar), R(0), // |
| 488 B(JumpIfToBooleanFalse), U8(4), // | 496 B(JumpIfToBooleanFalse), U8(4), // |
| (...skipping 11 matching lines...) Expand all Loading... |
| 500 } | 508 } |
| 501 } | 509 } |
| 502 | 510 |
| 503 | 511 |
| 504 TEST(Parameters) { | 512 TEST(Parameters) { |
| 505 InitializedHandleScope handle_scope; | 513 InitializedHandleScope handle_scope; |
| 506 BytecodeGeneratorHelper helper; | 514 BytecodeGeneratorHelper helper; |
| 507 | 515 |
| 508 ExpectedSnippet<int> snippets[] = { | 516 ExpectedSnippet<int> snippets[] = { |
| 509 {"function f() { return this; }", | 517 {"function f() { return this; }", |
| 510 0, 1, 3, {B(Ldar), R(helper.kLastParamIndex), B(Return)}, 0}, | 518 0, |
| 519 1, |
| 520 3, |
| 521 {B(Ldar), THIS(1), B(Return)}, |
| 522 0}, |
| 511 {"function f(arg1) { return arg1; }", | 523 {"function f(arg1) { return arg1; }", |
| 512 0, 2, 3, {B(Ldar), R(helper.kLastParamIndex), B(Return)}, 0}, | 524 0, |
| 525 2, |
| 526 3, |
| 527 {B(Ldar), A(1, 2), B(Return)}, |
| 528 0}, |
| 513 {"function f(arg1) { return this; }", | 529 {"function f(arg1) { return this; }", |
| 514 0, 2, 3, {B(Ldar), R(helper.kLastParamIndex - 1), B(Return)}, 0}, | 530 0, |
| 531 2, |
| 532 3, |
| 533 {B(Ldar), THIS(2), B(Return)}, |
| 534 0}, |
| 515 {"function f(arg1, arg2, arg3, arg4, arg5, arg6, arg7) { return arg4; }", | 535 {"function f(arg1, arg2, arg3, arg4, arg5, arg6, arg7) { return arg4; }", |
| 516 0, 8, 3, {B(Ldar), R(helper.kLastParamIndex - 3), B(Return)}, 0}, | 536 0, |
| 537 8, |
| 538 3, |
| 539 {B(Ldar), A(4, 8), B(Return)}, |
| 540 0}, |
| 517 {"function f(arg1, arg2, arg3, arg4, arg5, arg6, arg7) { return this; }", | 541 {"function f(arg1, arg2, arg3, arg4, arg5, arg6, arg7) { return this; }", |
| 518 0, 8, 3, {B(Ldar), R(helper.kLastParamIndex - 7), B(Return)}, 0}, | 542 0, |
| 543 8, |
| 544 3, |
| 545 {B(Ldar), THIS(8), B(Return)}, |
| 546 0}, |
| 519 {"function f(arg1) { arg1 = 1; }", | 547 {"function f(arg1) { arg1 = 1; }", |
| 520 0, 2, 6, | 548 0, |
| 521 {B(LdaSmi8), U8(1), // | 549 2, |
| 522 B(Star), R(helper.kLastParamIndex), // | 550 6, |
| 523 B(LdaUndefined), // | 551 {B(LdaSmi8), U8(1), // |
| 552 B(Star), A(1, 2), // |
| 553 B(LdaUndefined), // |
| 524 B(Return)}, | 554 B(Return)}, |
| 525 0}, | 555 0}, |
| 526 {"function f(arg1, arg2, arg3, arg4) { arg2 = 1; }", | 556 {"function f(arg1, arg2, arg3, arg4) { arg2 = 1; }", |
| 527 0, 5, 6, | 557 0, |
| 528 {B(LdaSmi8), U8(1), // | 558 5, |
| 529 B(Star), R(helper.kLastParamIndex - 2), // | 559 6, |
| 530 B(LdaUndefined), // | 560 {B(LdaSmi8), U8(1), // |
| 561 B(Star), A(2, 5), // |
| 562 B(LdaUndefined), // |
| 531 B(Return)}, | 563 B(Return)}, |
| 532 0}, | 564 0}, |
| 533 }; | 565 }; |
| 534 | 566 |
| 535 for (size_t i = 0; i < arraysize(snippets); i++) { | 567 for (size_t i = 0; i < arraysize(snippets); i++) { |
| 536 Handle<BytecodeArray> bytecode_array = | 568 Handle<BytecodeArray> bytecode_array = |
| 537 helper.MakeBytecodeForFunction(snippets[i].code_snippet); | 569 helper.MakeBytecodeForFunction(snippets[i].code_snippet); |
| 538 CheckBytecodeArrayEqual(snippets[i], bytecode_array); | 570 CheckBytecodeArrayEqual(snippets[i], bytecode_array); |
| 539 } | 571 } |
| 540 } | 572 } |
| (...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 690 | 722 |
| 691 FeedbackVectorSpec feedback_spec(&zone); | 723 FeedbackVectorSpec feedback_spec(&zone); |
| 692 FeedbackVectorSlot slot1 = feedback_spec.AddLoadICSlot(); | 724 FeedbackVectorSlot slot1 = feedback_spec.AddLoadICSlot(); |
| 693 FeedbackVectorSlot slot2 = feedback_spec.AddLoadICSlot(); | 725 FeedbackVectorSlot slot2 = feedback_spec.AddLoadICSlot(); |
| 694 | 726 |
| 695 Handle<i::TypeFeedbackVector> vector = | 727 Handle<i::TypeFeedbackVector> vector = |
| 696 i::NewTypeFeedbackVector(helper.isolate(), &feedback_spec); | 728 i::NewTypeFeedbackVector(helper.isolate(), &feedback_spec); |
| 697 | 729 |
| 698 ExpectedSnippet<const char*> snippets[] = { | 730 ExpectedSnippet<const char*> snippets[] = { |
| 699 {"function f(a) { return a.name; }\nf({name : \"test\"})", | 731 {"function f(a) { return a.name; }\nf({name : \"test\"})", |
| 700 1 * kPointerSize, | 732 0, |
| 701 2, | 733 2, |
| 702 10, | 734 6, |
| 703 { | 735 { |
| 704 B(Ldar), R(helper.kLastParamIndex), // | 736 B(LdaConstant), U8(0), // |
| 705 B(Star), R(0), // | 737 B(LoadICSloppy), A(1, 2), U8(vector->GetIndex(slot1)), // |
| 706 B(LdaConstant), U8(0), // | 738 B(Return), // |
| 707 B(LoadICSloppy), R(0), U8(vector->GetIndex(slot1)), // | |
| 708 B(Return) // | |
| 709 }, | 739 }, |
| 710 1, | 740 1, |
| 711 {"name"}}, | 741 {"name"}}, |
| 712 {"function f(a) { return a[\"key\"]; }\nf({key : \"test\"})", | 742 {"function f(a) { return a[\"key\"]; }\nf({key : \"test\"})", |
| 713 1 * kPointerSize, | 743 0, |
| 714 2, | 744 2, |
| 715 10, | 745 6, |
| 716 { | 746 { |
| 717 B(Ldar), R(helper.kLastParamIndex), // | 747 B(LdaConstant), U8(0), // |
| 718 B(Star), R(0), // | 748 B(LoadICSloppy), A(1, 2), U8(vector->GetIndex(slot1)), // |
| 719 B(LdaConstant), U8(0), // | 749 B(Return) // |
| 720 B(LoadICSloppy), R(0), U8(vector->GetIndex(slot1)), // | |
| 721 B(Return) // | |
| 722 }, | 750 }, |
| 723 1, | 751 1, |
| 724 {"key"}}, | 752 {"key"}}, |
| 725 {"function f(a) { return a[100]; }\nf({100 : \"test\"})", | 753 {"function f(a) { return a[100]; }\nf({100 : \"test\"})", |
| 726 1 * kPointerSize, | 754 0, |
| 727 2, | 755 2, |
| 728 10, | 756 6, |
| 729 { | 757 { |
| 730 B(Ldar), R(helper.kLastParamIndex), // | 758 B(LdaSmi8), U8(100), // |
| 731 B(Star), R(0), // | 759 B(KeyedLoadICSloppy), A(1, 2), U8(vector->GetIndex(slot1)), // |
| 732 B(LdaSmi8), U8(100), // | 760 B(Return) // |
| 733 B(KeyedLoadICSloppy), R(0), U8(vector->GetIndex(slot1)), // | |
| 734 B(Return) // | |
| 735 }, | 761 }, |
| 736 0}, | 762 0}, |
| 737 {"function f(a, b) { return a[b]; }\nf({arg : \"test\"}, \"arg\")", | 763 {"function f(a, b) { return a[b]; }\nf({arg : \"test\"}, \"arg\")", |
| 738 1 * kPointerSize, | 764 0, |
| 739 3, | 765 3, |
| 740 10, | 766 6, |
| 741 { | 767 { |
| 742 B(Ldar), R(helper.kLastParamIndex - 1), // | 768 B(Ldar), A(1, 2), // |
| 743 B(Star), R(0), // | 769 B(KeyedLoadICSloppy), A(1, 3), U8(vector->GetIndex(slot1)), // |
| 744 B(Ldar), R(helper.kLastParamIndex), // | 770 B(Return) // |
| 745 B(KeyedLoadICSloppy), R(0), U8(vector->GetIndex(slot1)), // | |
| 746 B(Return) // | |
| 747 }, | 771 }, |
| 748 0}, | 772 0}, |
| 749 {"function f(a) { var b = a.name; return a[-124]; }\n" | 773 {"function f(a) { var b = a.name; return a[-124]; }\n" |
| 750 "f({\"-124\" : \"test\", name : 123 })", | 774 "f({\"-124\" : \"test\", name : 123 })", |
| 751 2 * kPointerSize, | 775 kPointerSize, |
| 752 2, | 776 2, |
| 753 21, | 777 13, |
| 754 { | 778 { |
| 755 B(Ldar), R(helper.kLastParamIndex), // | 779 B(LdaConstant), U8(0), // |
| 756 B(Star), R(1), // | 780 B(LoadICSloppy), A(1, 2), U8(vector->GetIndex(slot1)), // |
| 757 B(LdaConstant), U8(0), // | 781 B(Star), R(0), // |
| 758 B(LoadICSloppy), R(1), U8(vector->GetIndex(slot1)), // | 782 B(LdaSmi8), U8(-124), // |
| 759 B(Star), R(0), // | 783 B(KeyedLoadICSloppy), A(1, 2), U8(vector->GetIndex(slot2)), // |
| 760 B(Ldar), R(helper.kLastParamIndex), // | 784 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 }, | 785 }, |
| 766 1, | 786 1, |
| 767 {"name"}}, | 787 {"name"}}, |
| 768 {"function f(a) { \"use strict\"; return a.name; }\nf({name : \"test\"})", | 788 {"function f(a) { \"use strict\"; return a.name; }\nf({name : \"test\"})", |
| 769 1 * kPointerSize, | 789 0, |
| 770 2, | 790 2, |
| 771 12, | 791 8, |
| 772 { | 792 { |
| 773 // TODO(rmcilroy) Avoid unnecessary LdaConstant for "use strict" | 793 // TODO(rmcilroy) Avoid unnecessary LdaConstant for "use strict" |
| 774 // expression, or any other unused literal expression. | 794 // expression, or any other unused literal expression. |
| 775 B(LdaConstant), U8(0), // | 795 B(LdaConstant), U8(0), // |
| 776 B(Ldar), R(helper.kLastParamIndex), // | 796 B(LdaConstant), U8(1), // |
| 777 B(Star), R(0), // | 797 B(LoadICStrict), A(1, 2), U8(vector->GetIndex(slot1)), // |
| 778 B(LdaConstant), U8(1), // | 798 B(Return), // |
| 779 B(LoadICStrict), R(0), U8(vector->GetIndex(slot1)), // | |
| 780 B(Return) // | |
| 781 }, | 799 }, |
| 782 2, | 800 2, |
| 783 {"use strict", "name"}}, | 801 {"use strict", "name"}}, |
| 784 {"function f(a, b) { \"use strict\"; return a[b]; }\n" | 802 {"function f(a, b) { \"use strict\"; return a[b]; }\n" |
| 785 "f({arg : \"test\"}, \"arg\")", | 803 "f({arg : \"test\"}, \"arg\")", |
| 786 1 * kPointerSize, | 804 0, |
| 787 3, | 805 3, |
| 788 12, | 806 8, |
| 789 { | 807 { |
| 790 // TODO(rmcilroy) Avoid unnecessary LdaConstant for "use strict" | 808 // TODO(rmcilroy) Avoid unnecessary LdaConstant for "use strict" |
| 791 // expression, or any other unused literal expression. | 809 // expression, or any other unused literal expression. |
| 792 B(LdaConstant), U8(0), // | 810 B(LdaConstant), U8(0), // |
| 793 B(Ldar), R(helper.kLastParamIndex - 1), // | 811 B(Ldar), A(2, 3), // |
| 794 B(Star), R(0), // | 812 B(KeyedLoadICStrict), A(1, 3), U8(vector->GetIndex(slot1)), // |
| 795 B(Ldar), R(helper.kLastParamIndex), // | 813 B(Return), // |
| 796 B(KeyedLoadICStrict), R(0), U8(vector->GetIndex(slot1)), // | |
| 797 B(Return) // | |
| 798 }, | 814 }, |
| 799 1, | 815 1, |
| 800 {"use strict"}}}; | 816 {"use strict"}}}; |
| 801 for (size_t i = 0; i < arraysize(snippets); i++) { | 817 for (size_t i = 0; i < arraysize(snippets); i++) { |
| 802 Handle<BytecodeArray> bytecode_array = | 818 Handle<BytecodeArray> bytecode_array = |
| 803 helper.MakeBytecode(snippets[i].code_snippet, helper.kFunctionName); | 819 helper.MakeBytecode(snippets[i].code_snippet, helper.kFunctionName); |
| 804 CheckBytecodeArrayEqual(snippets[i], bytecode_array); | 820 CheckBytecodeArrayEqual(snippets[i], bytecode_array); |
| 805 } | 821 } |
| 806 } | 822 } |
| 807 | 823 |
| 808 | 824 |
| 809 TEST(PropertyStores) { | 825 TEST(PropertyStores) { |
| 810 InitializedHandleScope handle_scope; | 826 InitializedHandleScope handle_scope; |
| 811 BytecodeGeneratorHelper helper; | 827 BytecodeGeneratorHelper helper; |
| 812 Zone zone; | 828 Zone zone; |
| 813 | 829 |
| 814 FeedbackVectorSpec feedback_spec(&zone); | 830 FeedbackVectorSpec feedback_spec(&zone); |
| 815 FeedbackVectorSlot slot1 = feedback_spec.AddStoreICSlot(); | 831 FeedbackVectorSlot slot1 = feedback_spec.AddStoreICSlot(); |
| 816 FeedbackVectorSlot slot2 = feedback_spec.AddStoreICSlot(); | 832 FeedbackVectorSlot slot2 = feedback_spec.AddStoreICSlot(); |
| 817 | 833 |
| 818 Handle<i::TypeFeedbackVector> vector = | 834 Handle<i::TypeFeedbackVector> vector = |
| 819 i::NewTypeFeedbackVector(helper.isolate(), &feedback_spec); | 835 i::NewTypeFeedbackVector(helper.isolate(), &feedback_spec); |
| 820 | 836 |
| 821 ExpectedSnippet<const char*> snippets[] = { | 837 ExpectedSnippet<const char*> snippets[] = { |
| 822 {"function f(a) { a.name = \"val\"; }\nf({name : \"test\"})", | 838 {"function f(a) { a.name = \"val\"; }\nf({name : \"test\"})", |
| 823 2 * kPointerSize, | 839 kPointerSize, |
| 824 2, | 840 2, |
| 825 16, | 841 12, |
| 826 { | 842 { |
| 827 B(Ldar), R(helper.kLastParamIndex), // | 843 B(LdaConstant), U8(0), // |
| 828 B(Star), R(0), // | 844 B(Star), R(0), // |
| 829 B(LdaConstant), U8(0), // | 845 B(LdaConstant), U8(1), // |
| 830 B(Star), R(1), // | 846 B(StoreICSloppy), A(1, 2), R(0), U8(vector->GetIndex(slot1)), // |
| 831 B(LdaConstant), U8(1), // | 847 B(LdaUndefined), // |
| 832 B(StoreICSloppy), R(0), R(1), U8(vector->GetIndex(slot1)), // | 848 B(Return), // |
| 833 B(LdaUndefined), // | |
| 834 B(Return) // | |
| 835 }, | 849 }, |
| 836 2, | 850 2, |
| 837 {"name", "val"}}, | 851 {"name", "val"}}, |
| 838 {"function f(a) { a[\"key\"] = \"val\"; }\nf({key : \"test\"})", | 852 {"function f(a) { a[\"key\"] = \"val\"; }\nf({key : \"test\"})", |
| 839 2 * kPointerSize, | 853 kPointerSize, |
| 840 2, | 854 2, |
| 841 16, | 855 12, |
| 842 { | 856 { |
| 843 B(Ldar), R(helper.kLastParamIndex), // | 857 B(LdaConstant), U8(0), // |
| 844 B(Star), R(0), // | 858 B(Star), R(0), // |
| 845 B(LdaConstant), U8(0), // | 859 B(LdaConstant), U8(1), // |
| 846 B(Star), R(1), // | 860 B(StoreICSloppy), A(1, 2), R(0), U8(vector->GetIndex(slot1)), // |
| 847 B(LdaConstant), U8(1), // | 861 B(LdaUndefined), // |
| 848 B(StoreICSloppy), R(0), R(1), U8(vector->GetIndex(slot1)), // | 862 B(Return), // |
| 849 B(LdaUndefined), // | |
| 850 B(Return) // | |
| 851 }, | 863 }, |
| 852 2, | 864 2, |
| 853 {"key", "val"}}, | 865 {"key", "val"}}, |
| 854 {"function f(a) { a[100] = \"val\"; }\nf({100 : \"test\"})", | 866 {"function f(a) { a[100] = \"val\"; }\nf({100 : \"test\"})", |
| 855 2 * kPointerSize, | 867 kPointerSize, |
| 856 2, | 868 2, |
| 857 16, | 869 12, |
| 858 { | 870 { |
| 859 B(Ldar), R(helper.kLastParamIndex), // | 871 B(LdaSmi8), U8(100), // |
| 860 B(Star), R(0), // | 872 B(Star), R(0), // |
| 861 B(LdaSmi8), U8(100), // | 873 B(LdaConstant), U8(0), // |
| 862 B(Star), R(1), // | 874 B(KeyedStoreICSloppy), // |
| 863 B(LdaConstant), U8(0), // | 875 A(1, 2), R(0), U8(vector->GetIndex(slot1)), // |
| 864 B(KeyedStoreICSloppy), R(0), R(1), U8(vector->GetIndex(slot1)), // | 876 B(LdaUndefined), // |
| 865 B(LdaUndefined), // | 877 B(Return), // |
| 866 B(Return) // | |
| 867 }, | 878 }, |
| 868 1, | 879 1, |
| 869 {"val"}}, | 880 {"val"}}, |
| 870 {"function f(a, b) { a[b] = \"val\"; }\nf({arg : \"test\"}, \"arg\")", | 881 {"function f(a, b) { a[b] = \"val\"; }\nf({arg : \"test\"}, \"arg\")", |
| 871 2 * kPointerSize, | 882 0, |
| 872 3, | 883 3, |
| 873 16, | 884 8, |
| 874 { | 885 { |
| 875 B(Ldar), R(helper.kLastParamIndex - 1), // | 886 B(LdaConstant), U8(0), // |
| 876 B(Star), R(0), // | 887 B(KeyedStoreICSloppy), // |
| 877 B(Ldar), R(helper.kLastParamIndex), // | 888 A(1, 3), A(2, 3), U8(vector->GetIndex(slot1)), // |
| 878 B(Star), R(1), // | 889 B(LdaUndefined), // |
| 879 B(LdaConstant), U8(0), // | 890 B(Return), // |
| 880 B(KeyedStoreICSloppy), R(0), R(1), U8(vector->GetIndex(slot1)), // | |
| 881 B(LdaUndefined), // | |
| 882 B(Return) // | |
| 883 }, | 891 }, |
| 884 1, | 892 1, |
| 885 {"val"}}, | 893 {"val"}}, |
| 886 {"function f(a) { a.name = a[-124]; }\n" | 894 {"function f(a) { a.name = a[-124]; }\n" |
| 887 "f({\"-124\" : \"test\", name : 123 })", | 895 "f({\"-124\" : \"test\", name : 123 })", |
| 888 3 * kPointerSize, | 896 kPointerSize, |
| 889 2, | 897 2, |
| 890 23, | 898 15, |
| 891 { | 899 { |
| 892 B(Ldar), R(helper.kLastParamIndex), // | 900 B(LdaConstant), U8(0), // |
| 893 B(Star), R(0), // | 901 B(Star), R(0), // |
| 894 B(LdaConstant), U8(0), // | 902 B(LdaSmi8), U8(-124), // |
| 895 B(Star), R(1), // | 903 B(KeyedLoadICSloppy), A(1, 2), U8(vector->GetIndex(slot1)), // |
| 896 B(Ldar), R(helper.kLastParamIndex), // | 904 B(StoreICSloppy), A(1, 2), R(0), U8(vector->GetIndex(slot2)), // |
| 897 B(Star), R(2), // | 905 B(LdaUndefined), // |
| 898 B(LdaSmi8), U8(-124), // | 906 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 }, | 907 }, |
| 904 1, | 908 1, |
| 905 {"name"}}, | 909 {"name"}}, |
| 906 {"function f(a) { \"use strict\"; a.name = \"val\"; }\n" | 910 {"function f(a) { \"use strict\"; a.name = \"val\"; }\n" |
| 907 "f({name : \"test\"})", | 911 "f({name : \"test\"})", |
| 908 2 * kPointerSize, | 912 kPointerSize, |
| 909 2, | 913 2, |
| 910 18, | 914 14, |
| 911 { | 915 { |
| 912 // TODO(rmcilroy) Avoid unnecessary LdaConstant for "use strict" | 916 // TODO(rmcilroy) Avoid unnecessary LdaConstant for "use strict" |
| 913 // expression, or any other unused literal expression. | 917 // expression, or any other unused literal expression. |
| 914 B(LdaConstant), U8(0), // | 918 B(LdaConstant), U8(0), // |
| 915 B(Ldar), R(helper.kLastParamIndex), // | 919 B(LdaConstant), U8(1), // |
| 916 B(Star), R(0), // | 920 B(Star), R(0), // |
| 917 B(LdaConstant), U8(1), // | 921 B(LdaConstant), U8(2), // |
| 918 B(Star), R(1), // | 922 B(StoreICStrict), A(1, 2), R(0), U8(vector->GetIndex(slot1)), // |
| 919 B(LdaConstant), U8(2), // | 923 B(LdaUndefined), // |
| 920 B(StoreICStrict), R(0), R(1), U8(vector->GetIndex(slot1)), // | 924 B(Return), // |
| 921 B(LdaUndefined), // | |
| 922 B(Return) // | |
| 923 }, | 925 }, |
| 924 3, | 926 3, |
| 925 {"use strict", "name", "val"}}, | 927 {"use strict", "name", "val"}}, |
| 926 {"function f(a, b) { \"use strict\"; a[b] = \"val\"; }\n" | 928 {"function f(a, b) { \"use strict\"; a[b] = \"val\"; }\n" |
| 927 "f({arg : \"test\"}, \"arg\")", | 929 "f({arg : \"test\"}, \"arg\")", |
| 928 2 * kPointerSize, | 930 0, |
| 929 3, | 931 3, |
| 930 18, | 932 10, |
| 931 { | 933 { |
| 932 // TODO(rmcilroy) Avoid unnecessary LdaConstant for "use strict" | 934 // TODO(rmcilroy) Avoid unnecessary LdaConstant for "use strict" |
| 933 // expression, or any other unused literal expression. | 935 // expression, or any other unused literal expression. |
| 934 B(LdaConstant), U8(0), // | 936 B(LdaConstant), U8(0), // |
| 935 B(Ldar), R(helper.kLastParamIndex - 1), // | 937 B(LdaConstant), U8(1), // |
| 936 B(Star), R(0), // | 938 B(KeyedStoreICStrict), A(1, 3), A(2, 3), // |
| 937 B(Ldar), R(helper.kLastParamIndex), // | 939 U8(vector->GetIndex(slot1)), // |
| 938 B(Star), R(1), // | 940 B(LdaUndefined), // |
| 939 B(LdaConstant), U8(1), // | 941 B(Return), // |
| 940 B(KeyedStoreICStrict), R(0), R(1), U8(vector->GetIndex(slot1)), // | |
| 941 B(LdaUndefined), // | |
| 942 B(Return) // | |
| 943 }, | 942 }, |
| 944 2, | 943 2, |
| 945 {"use strict", "val"}}}; | 944 {"use strict", "val"}}}; |
| 946 for (size_t i = 0; i < arraysize(snippets); i++) { | 945 for (size_t i = 0; i < arraysize(snippets); i++) { |
| 947 Handle<BytecodeArray> bytecode_array = | 946 Handle<BytecodeArray> bytecode_array = |
| 948 helper.MakeBytecode(snippets[i].code_snippet, helper.kFunctionName); | 947 helper.MakeBytecode(snippets[i].code_snippet, helper.kFunctionName); |
| 949 CheckBytecodeArrayEqual(snippets[i], bytecode_array); | 948 CheckBytecodeArrayEqual(snippets[i], bytecode_array); |
| 950 } | 949 } |
| 951 } | 950 } |
| 952 | 951 |
| (...skipping 13 matching lines...) Expand all Loading... |
| 966 | 965 |
| 967 Handle<i::TypeFeedbackVector> vector = | 966 Handle<i::TypeFeedbackVector> vector = |
| 968 i::NewTypeFeedbackVector(helper.isolate(), &feedback_spec); | 967 i::NewTypeFeedbackVector(helper.isolate(), &feedback_spec); |
| 969 | 968 |
| 970 ExpectedSnippet<const char*> snippets[] = { | 969 ExpectedSnippet<const char*> snippets[] = { |
| 971 {"function f(a) { return a.func(); }\nf(" FUNC_ARG ")", | 970 {"function f(a) { return a.func(); }\nf(" FUNC_ARG ")", |
| 972 2 * kPointerSize, | 971 2 * kPointerSize, |
| 973 2, | 972 2, |
| 974 16, | 973 16, |
| 975 { | 974 { |
| 976 B(Ldar), R(helper.kLastParamIndex), // | 975 B(Ldar), A(1, 2), // |
| 977 B(Star), R(1), // | 976 B(Star), R(1), // |
| 978 B(LdaConstant), U8(0), // | 977 B(LdaConstant), U8(0), // |
| 979 B(LoadICSloppy), R(1), U8(vector->GetIndex(slot2)), // | 978 B(LoadICSloppy), R(1), U8(vector->GetIndex(slot2)), // |
| 980 B(Star), R(0), // | 979 B(Star), R(0), // |
| 981 B(Call), R(0), R(1), U8(0), // | 980 B(Call), R(0), R(1), U8(0), // |
| 982 B(Return) // | 981 B(Return), // |
| 983 }, | 982 }, |
| 984 1, | 983 1, |
| 985 {"func"}}, | 984 {"func"}}, |
| 986 {"function f(a, b, c) { return a.func(b, c); }\nf(" FUNC_ARG ", 1, 2)", | 985 {"function f(a, b, c) { return a.func(b, c); }\nf(" FUNC_ARG ", 1, 2)", |
| 987 4 * kPointerSize, | 986 4 * kPointerSize, |
| 988 4, | 987 4, |
| 989 24, | 988 24, |
| 990 { | 989 { |
| 991 B(Ldar), R(helper.kLastParamIndex - 2), // | 990 B(Ldar), A(1, 4), // |
| 992 B(Star), R(1), // | 991 B(Star), R(1), // |
| 993 B(LdaConstant), U8(0), // | 992 B(LdaConstant), U8(0), // |
| 994 B(LoadICSloppy), R(1), U8(vector->GetIndex(slot2)), // | 993 B(LoadICSloppy), R(1), U8(vector->GetIndex(slot2)), // |
| 995 B(Star), R(0), // | 994 B(Star), R(0), // |
| 996 B(Ldar), R(helper.kLastParamIndex - 1), // | 995 B(Ldar), A(2, 4), // |
| 997 B(Star), R(2), // | 996 B(Star), R(2), // |
| 998 B(Ldar), R(helper.kLastParamIndex), // | 997 B(Ldar), A(3, 4), // |
| 999 B(Star), R(3), // | 998 B(Star), R(3), // |
| 1000 B(Call), R(0), R(1), U8(2), // | 999 B(Call), R(0), R(1), U8(2), // |
| 1001 B(Return) // | 1000 B(Return) // |
| 1002 }, | 1001 }, |
| 1003 1, | 1002 1, |
| 1004 {"func"}}, | 1003 {"func"}}, |
| 1005 {"function f(a, b) { return a.func(b + b, b); }\nf(" FUNC_ARG ", 1)", | 1004 {"function f(a, b) { return a.func(b + b, b); }\nf(" FUNC_ARG ", 1)", |
| 1006 4 * kPointerSize, | 1005 4 * kPointerSize, |
| 1007 3, | 1006 3, |
| 1008 30, | 1007 26, |
| 1009 { | 1008 { |
| 1010 B(Ldar), R(helper.kLastParamIndex - 1), // | 1009 B(Ldar), A(1, 3), // |
| 1011 B(Star), R(1), // | 1010 B(Star), R(1), // |
| 1012 B(LdaConstant), U8(0), // | 1011 B(LdaConstant), U8(0), // |
| 1013 B(LoadICSloppy), R(1), U8(vector->GetIndex(slot2)), // | 1012 B(LoadICSloppy), R(1), U8(vector->GetIndex(slot2)), // |
| 1014 B(Star), R(0), // | 1013 B(Star), R(0), // |
| 1015 B(Ldar), R(helper.kLastParamIndex), // | 1014 B(Ldar), A(2, 3), // |
| 1016 B(Star), R(3), // | 1015 B(Add), A(2, 3), // |
| 1017 B(Ldar), R(helper.kLastParamIndex), // | |
| 1018 B(Add), R(3), // | |
| 1019 B(Star), R(2), // | 1016 B(Star), R(2), // |
| 1020 B(Ldar), R(helper.kLastParamIndex), // | 1017 B(Ldar), A(2, 3), // |
| 1021 B(Star), R(3), // | 1018 B(Star), R(3), // |
| 1022 B(Call), R(0), R(1), U8(2), // | 1019 B(Call), R(0), R(1), U8(2), // |
| 1023 B(Return), // | 1020 B(Return), // |
| 1024 }, | 1021 }, |
| 1025 1, | 1022 1, |
| 1026 {"func"}}}; | 1023 {"func"}}}; |
| 1027 for (size_t i = 0; i < arraysize(snippets); i++) { | 1024 for (size_t i = 0; i < arraysize(snippets); i++) { |
| 1028 Handle<BytecodeArray> bytecode_array = | 1025 Handle<BytecodeArray> bytecode_array = |
| 1029 helper.MakeBytecode(snippets[i].code_snippet, helper.kFunctionName); | 1026 helper.MakeBytecode(snippets[i].code_snippet, helper.kFunctionName); |
| 1030 CheckBytecodeArrayEqual(snippets[i], bytecode_array); | 1027 CheckBytecodeArrayEqual(snippets[i], bytecode_array); |
| (...skipping 256 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1287 B(LdaUndefined), // | 1284 B(LdaUndefined), // |
| 1288 B(Return) // | 1285 B(Return) // |
| 1289 }, | 1286 }, |
| 1290 }, | 1287 }, |
| 1291 { | 1288 { |
| 1292 "function f(a) { return %IsArray(a) }\nf(undefined)", | 1289 "function f(a) { return %IsArray(a) }\nf(undefined)", |
| 1293 1 * kPointerSize, | 1290 1 * kPointerSize, |
| 1294 2, | 1291 2, |
| 1295 10, | 1292 10, |
| 1296 { | 1293 { |
| 1297 B(Ldar), R(helper.kLastParamIndex), // | 1294 B(Ldar), A(1, 2), // |
| 1298 B(Star), R(0), // | 1295 B(Star), R(0), // |
| 1299 B(CallRuntime), U16(Runtime::kIsArray), R(0), U8(1), // | 1296 B(CallRuntime), U16(Runtime::kIsArray), R(0), U8(1), // |
| 1300 B(Return) // | 1297 B(Return) // |
| 1301 }, | 1298 }, |
| 1302 }, | 1299 }, |
| 1303 { | 1300 { |
| 1304 "function f() { return %Add(1, 2) }\nf()", | 1301 "function f() { return %Add(1, 2) }\nf()", |
| 1305 2 * kPointerSize, | 1302 2 * kPointerSize, |
| 1306 1, | 1303 1, |
| 1307 14, | 1304 14, |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1374 B(Return), // | 1371 B(Return), // |
| 1375 B(Jump), U8(5), // | 1372 B(Jump), U8(5), // |
| 1376 B(LdaSmi8), U8(-1), // | 1373 B(LdaSmi8), U8(-1), // |
| 1377 B(Return), // | 1374 B(Return), // |
| 1378 B(LdaUndefined), // | 1375 B(LdaUndefined), // |
| 1379 B(Return)}, // | 1376 B(Return)}, // |
| 1380 0, | 1377 0, |
| 1381 {unused, unused, unused, unused, unused, unused}}, | 1378 {unused, unused, unused, unused, unused, unused}}, |
| 1382 {"function f(a) { if (a <= 0) { return 200; } else { return -200; } }" | 1379 {"function f(a) { if (a <= 0) { return 200; } else { return -200; } }" |
| 1383 "f(99);", | 1380 "f(99);", |
| 1384 kPointerSize, | 1381 0, |
| 1385 2, | 1382 2, |
| 1386 19, | 1383 15, |
| 1387 {B(Ldar), R(helper.kLastParamIndex), // | 1384 {B(LdaZero), // |
| 1388 B(Star), R(0), // | 1385 B(TestLessThanOrEqual), A(1, 2), // |
| 1389 B(LdaZero), // | 1386 B(JumpIfFalse), U8(7), // |
| 1390 B(TestLessThanOrEqual), R(0), // | 1387 B(LdaConstant), U8(0), // |
| 1391 B(JumpIfFalse), U8(7), // | 1388 B(Return), // |
| 1392 B(LdaConstant), U8(0), // | 1389 B(Jump), U8(5), // |
| 1393 B(Return), // | 1390 B(LdaConstant), U8(1), // |
| 1394 B(Jump), U8(5), // | 1391 B(Return), // |
| 1395 B(LdaConstant), U8(1), // | 1392 B(LdaUndefined), // |
| 1396 B(Return), // | 1393 B(Return)}, // |
| 1397 B(LdaUndefined), // | |
| 1398 B(Return)}, // | |
| 1399 2, | 1394 2, |
| 1400 {helper.factory()->NewNumberFromInt(200), | 1395 {helper.factory()->NewNumberFromInt(200), |
| 1401 helper.factory()->NewNumberFromInt(-200), unused, unused, unused, | 1396 helper.factory()->NewNumberFromInt(-200), unused, unused, unused, |
| 1402 unused}}, | 1397 unused}}, |
| 1403 {"function f(a, b) { if (a in b) { return 200; } }" | 1398 {"function f(a, b) { if (a in b) { return 200; } }" |
| 1404 "f('prop', { prop: 'yes'});", | 1399 "f('prop', { prop: 'yes'});", |
| 1405 kPointerSize, | 1400 0, |
| 1406 3, | 1401 3, |
| 1407 15, | 1402 11, |
| 1408 {B(Ldar), R(helper.kLastParamIndex - 1), // | 1403 {B(Ldar), A(2, 3), // |
| 1409 B(Star), R(0), // | 1404 B(TestIn), A(1, 3), // |
| 1410 B(Ldar), R(helper.kLastParamIndex), // | 1405 B(JumpIfFalse), U8(5), // |
| 1411 B(TestIn), R(0), // | 1406 B(LdaConstant), U8(0), // |
| 1412 B(JumpIfFalse), U8(5), // | 1407 B(Return), // |
| 1413 B(LdaConstant), U8(0), // | 1408 B(LdaUndefined), // |
| 1414 B(Return), // | 1409 B(Return)}, // |
| 1415 B(LdaUndefined), // | |
| 1416 B(Return)}, // | |
| 1417 1, | 1410 1, |
| 1418 {helper.factory()->NewNumberFromInt(200), unused, unused, unused, unused, | 1411 {helper.factory()->NewNumberFromInt(200), unused, unused, unused, unused, |
| 1419 unused}}, | 1412 unused}}, |
| 1420 {"function f(z) { var a = 0; var b = 0; if (a === 0.01) { " | 1413 {"function f(z) { var a = 0; var b = 0; if (a === 0.01) { " |
| 1421 #define X "b = a; a = b; " | 1414 #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 | 1415 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 | 1416 #undef X |
| 1424 " return 200; } else { return -200; } } f(0.001)", | 1417 " return 200; } else { return -200; } } f(0.001)", |
| 1425 3 * kPointerSize, | 1418 2 * kPointerSize, |
| 1426 2, | 1419 2, |
| 1427 218, | 1420 214, |
| 1428 {B(LdaZero), // | 1421 { |
| 1429 B(Star), R(0), // | 1422 #define X B(Ldar), R(0), B(Star), R(1), B(Ldar), R(1), B(Star), R(0) |
| 1430 B(LdaZero), // | 1423 B(LdaZero), // |
| 1431 B(Star), R(1), // | 1424 B(Star), R(0), // |
| 1432 B(Ldar), R(0), // | 1425 B(LdaZero), // |
| 1433 B(Star), R(2), // | 1426 B(Star), R(1), // |
| 1434 B(LdaConstant), U8(0), // | 1427 B(LdaConstant), U8(0), // |
| 1435 B(TestEqualStrict), R(2), // | 1428 B(TestEqualStrict), R(0), // |
| 1436 B(JumpIfFalseConstant), U8(2), // | 1429 B(JumpIfFalseConstant), U8(2), // |
| 1437 #define X B(Ldar), R(0), B(Star), R(1), B(Ldar), R(1), B(Star), R(0), | 1430 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 | 1431 X, X, X, X, X, X, X, X, X, X, // |
| 1432 X, X, X, X, // |
| 1433 B(LdaConstant), U8(1), // |
| 1434 B(Return), // |
| 1435 B(Jump), U8(5), // |
| 1436 B(LdaConstant), U8(3), // |
| 1437 B(Return), // |
| 1438 B(LdaUndefined), // |
| 1439 B(Return)}, // |
| 1439 #undef X | 1440 #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, | 1441 4, |
| 1448 {helper.factory()->NewHeapNumber(0.01), | 1442 {helper.factory()->NewHeapNumber(0.01), |
| 1449 helper.factory()->NewNumberFromInt(200), | 1443 helper.factory()->NewNumberFromInt(200), |
| 1450 helper.factory()->NewNumberFromInt(199), | 1444 helper.factory()->NewNumberFromInt(199), |
| 1451 helper.factory()->NewNumberFromInt(-200), | 1445 helper.factory()->NewNumberFromInt(-200), unused, unused}}, |
| 1452 unused, unused}}, | |
| 1453 {"function f(a, b) {\n" | 1446 {"function f(a, b) {\n" |
| 1454 " if (a == b) { return 1; }\n" | 1447 " if (a == b) { return 1; }\n" |
| 1455 " if (a === b) { return 1; }\n" | 1448 " if (a === b) { return 1; }\n" |
| 1456 " if (a < b) { return 1; }\n" | 1449 " if (a < b) { return 1; }\n" |
| 1457 " if (a > b) { return 1; }\n" | 1450 " if (a > b) { return 1; }\n" |
| 1458 " if (a <= b) { return 1; }\n" | 1451 " if (a <= b) { return 1; }\n" |
| 1459 " if (a >= b) { return 1; }\n" | 1452 " if (a >= b) { return 1; }\n" |
| 1460 " if (a in b) { return 1; }\n" | 1453 " if (a in b) { return 1; }\n" |
| 1461 " if (a instanceof b) { return 1; }\n" | 1454 " 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" | 1455 " return 0;\n" |
| 1465 "} f(1, 1);", | 1456 "} f(1, 1);", |
| 1466 kPointerSize, | 1457 0, |
| 1467 3, | 1458 3, |
| 1468 106, | 1459 74, |
| 1469 { | 1460 { |
| 1470 #define IF_CONDITION_RETURN(condition) \ | 1461 #define IF_CONDITION_RETURN(condition) \ |
| 1471 B(Ldar), R(helper.kLastParamIndex - 1), \ | 1462 B(Ldar), A(2, 3), \ |
| 1472 B(Star), R(0), \ | 1463 B(condition), A(1, 3), \ |
| 1473 B(Ldar), R(helper.kLastParamIndex), \ | 1464 B(JumpIfFalse), U8(5), \ |
| 1474 B(condition), R(0), \ | 1465 B(LdaSmi8), U8(1), \ |
| 1475 B(JumpIfFalse), U8(5), \ | 1466 B(Return), |
| 1476 B(LdaSmi8), U8(1), \ | |
| 1477 B(Return), | |
| 1478 IF_CONDITION_RETURN(TestEqual) // | 1467 IF_CONDITION_RETURN(TestEqual) // |
| 1479 IF_CONDITION_RETURN(TestEqualStrict) // | 1468 IF_CONDITION_RETURN(TestEqualStrict) // |
| 1480 IF_CONDITION_RETURN(TestLessThan) // | 1469 IF_CONDITION_RETURN(TestLessThan) // |
| 1481 IF_CONDITION_RETURN(TestGreaterThan) // | 1470 IF_CONDITION_RETURN(TestGreaterThan) // |
| 1482 IF_CONDITION_RETURN(TestLessThanOrEqual) // | 1471 IF_CONDITION_RETURN(TestLessThanOrEqual) // |
| 1483 IF_CONDITION_RETURN(TestGreaterThanOrEqual) // | 1472 IF_CONDITION_RETURN(TestGreaterThanOrEqual) // |
| 1484 IF_CONDITION_RETURN(TestIn) // | 1473 IF_CONDITION_RETURN(TestIn) // |
| 1485 IF_CONDITION_RETURN(TestInstanceOf) // | 1474 IF_CONDITION_RETURN(TestInstanceOf) // |
| 1475 B(LdaZero), // |
| 1476 B(Return)}, // |
| 1486 #undef IF_CONDITION_RETURN | 1477 #undef IF_CONDITION_RETURN |
| 1487 B(LdaZero), // | |
| 1488 B(Return)}, // | |
| 1489 0, | 1478 0, |
| 1490 {unused, unused, unused, unused, unused, unused}}, | 1479 {unused, unused, unused, unused, unused, unused}}, |
| 1491 }; | 1480 }; |
| 1492 | 1481 |
| 1493 for (size_t i = 0; i < arraysize(snippets); i++) { | 1482 for (size_t i = 0; i < arraysize(snippets); i++) { |
| 1494 Handle<BytecodeArray> bytecode_array = | 1483 Handle<BytecodeArray> bytecode_array = |
| 1495 helper.MakeBytecode(snippets[i].code_snippet, helper.kFunctionName); | 1484 helper.MakeBytecode(snippets[i].code_snippet, helper.kFunctionName); |
| 1496 CheckBytecodeArrayEqual(snippets[i], bytecode_array); | 1485 CheckBytecodeArrayEqual(snippets[i], bytecode_array); |
| 1497 } | 1486 } |
| 1498 } | 1487 } |
| 1499 | 1488 |
| 1500 | 1489 |
| 1501 TEST(DeclareGlobals) { | 1490 TEST(DeclareGlobals) { |
| 1502 InitializedHandleScope handle_scope; | 1491 InitializedHandleScope handle_scope; |
| 1503 BytecodeGeneratorHelper helper; | 1492 BytecodeGeneratorHelper helper; |
| 1504 | 1493 |
| 1505 ExpectedSnippet<InstanceType> snippets[] = { | 1494 ExpectedSnippet<InstanceType> snippets[] = { |
| 1506 {"var a = 1;", | 1495 {"var a = 1;", |
| 1507 5 * kPointerSize, | 1496 5 * kPointerSize, |
| 1508 1, | 1497 1, |
| 1509 45, | 1498 45, |
| 1510 { | 1499 { |
| 1511 B(Ldar), R(Register::function_closure().index()), // | 1500 B(Ldar), R(Register::function_closure().index()), // |
| 1512 B(Star), R(2), // | 1501 B(Star), R(2), // |
| 1513 B(LdaConstant), U8(0), // | 1502 B(LdaConstant), U8(0), // |
| 1514 B(Star), R(3), // | 1503 B(Star), R(3), // |
| 1515 B(CallRuntime), U16(Runtime::kNewScriptContext), R(2), U8(2), // | 1504 B(CallRuntime), U16(Runtime::kNewScriptContext), R(2), U8(2), // |
| 1516 B(PushContext), R(1), // | 1505 B(PushContext), R(1), // |
| 1517 B(LdaConstant), U8(1), // | 1506 B(LdaConstant), U8(1), // |
| 1518 B(Star), R(2), // | 1507 B(Star), R(2), // |
| 1519 B(LdaZero), // | 1508 B(LdaZero), // |
| 1520 B(Star), R(3), // | 1509 B(Star), R(3), // |
| 1521 B(CallRuntime), U16(Runtime::kDeclareGlobals), R(2), U8(2), // | 1510 B(CallRuntime), U16(Runtime::kDeclareGlobals), R(2), U8(2), // |
| 1522 B(LdaConstant), U8(2), // | 1511 B(LdaConstant), U8(2), // |
| 1523 B(Star), R(2), // | 1512 B(Star), R(2), // |
| 1524 B(LdaZero), // | 1513 B(LdaZero), // |
| 1525 B(Star), R(3), // | 1514 B(Star), R(3), // |
| 1526 B(LdaSmi8), U8(1), // | 1515 B(LdaSmi8), U8(1), // |
| 1527 B(Star), R(4), // | 1516 B(Star), R(4), // |
| 1528 B(CallRuntime), U16(Runtime::kInitializeVarGlobal), R(2), // | 1517 B(CallRuntime), U16(Runtime::kInitializeVarGlobal), R(2), U8(3), // |
| 1529 U8(3), // | 1518 B(LdaUndefined), // |
| 1530 B(LdaUndefined), // | 1519 B(Return), // |
| 1531 B(Return) // | |
| 1532 }, | 1520 }, |
| 1533 3, | 1521 3, |
| 1534 {InstanceType::FIXED_ARRAY_TYPE, | 1522 {InstanceType::FIXED_ARRAY_TYPE, InstanceType::FIXED_ARRAY_TYPE, |
| 1535 InstanceType::FIXED_ARRAY_TYPE, | |
| 1536 InstanceType::ONE_BYTE_INTERNALIZED_STRING_TYPE}}, | 1523 InstanceType::ONE_BYTE_INTERNALIZED_STRING_TYPE}}, |
| 1537 {"function f() {}", | 1524 {"function f() {}", |
| 1538 3 * kPointerSize, | 1525 3 * kPointerSize, |
| 1539 1, | 1526 1, |
| 1540 29, | 1527 29, |
| 1541 { | 1528 { |
| 1542 B(Ldar), R(Register::function_closure().index()), // | 1529 B(Ldar), R(Register::function_closure().index()), // |
| 1543 B(Star), R(1), // | 1530 B(Star), R(1), // |
| 1544 B(LdaConstant), U8(0), // | 1531 B(LdaConstant), U8(0), // |
| 1545 B(Star), R(2), // | 1532 B(Star), R(2), // |
| (...skipping 25 matching lines...) Expand all Loading... |
| 1571 B(LdaZero), // | 1558 B(LdaZero), // |
| 1572 B(Star), R(3), // | 1559 B(Star), R(3), // |
| 1573 B(CallRuntime), U16(Runtime::kDeclareGlobals), R(2), U8(2), // | 1560 B(CallRuntime), U16(Runtime::kDeclareGlobals), R(2), U8(2), // |
| 1574 B(LdaConstant), U8(2), // | 1561 B(LdaConstant), U8(2), // |
| 1575 B(Star), R(2), // | 1562 B(Star), R(2), // |
| 1576 B(LdaZero), // | 1563 B(LdaZero), // |
| 1577 B(Star), R(3), // | 1564 B(Star), R(3), // |
| 1578 B(LdaSmi8), U8(1), // | 1565 B(LdaSmi8), U8(1), // |
| 1579 B(Star), R(4), // | 1566 B(Star), R(4), // |
| 1580 B(CallRuntime), U16(Runtime::kInitializeVarGlobal), R(2), // | 1567 B(CallRuntime), U16(Runtime::kInitializeVarGlobal), R(2), // |
| 1581 U8(3), // | 1568 U8(3), // |
| 1582 B(LdaSmi8), U8(2), // | 1569 B(LdaSmi8), U8(2), // |
| 1583 B(StaGlobalSloppy), _, // | 1570 B(StaGlobalSloppy), _, // |
| 1584 B(Star), R(0), // | 1571 B(Star), R(0), // |
| 1585 B(Ldar), R(0), // | 1572 B(Ldar), R(0), // |
| 1586 B(Return) // | 1573 B(Return) // |
| 1587 }, | 1574 }, |
| 1588 3, | 1575 3, |
| 1589 {InstanceType::FIXED_ARRAY_TYPE, | 1576 {InstanceType::FIXED_ARRAY_TYPE, InstanceType::FIXED_ARRAY_TYPE, |
| 1590 InstanceType::FIXED_ARRAY_TYPE, | |
| 1591 InstanceType::ONE_BYTE_INTERNALIZED_STRING_TYPE}}, | 1577 InstanceType::ONE_BYTE_INTERNALIZED_STRING_TYPE}}, |
| 1592 {"function f() {}\nf();", | 1578 {"function f() {}\nf();", |
| 1593 4 * kPointerSize, | 1579 4 * kPointerSize, |
| 1594 1, | 1580 1, |
| 1595 43, | 1581 43, |
| 1596 { | 1582 { |
| 1597 B(Ldar), R(Register::function_closure().index()), // | 1583 B(Ldar), R(Register::function_closure().index()), // |
| 1598 B(Star), R(2), // | 1584 B(Star), R(2), // |
| 1599 B(LdaConstant), U8(0), // | 1585 B(LdaConstant), U8(0), // |
| 1600 B(Star), R(3), // | 1586 B(Star), R(3), // |
| (...skipping 26 matching lines...) Expand all Loading... |
| 1627 | 1613 |
| 1628 | 1614 |
| 1629 TEST(BasicLoops) { | 1615 TEST(BasicLoops) { |
| 1630 InitializedHandleScope handle_scope; | 1616 InitializedHandleScope handle_scope; |
| 1631 BytecodeGeneratorHelper helper; | 1617 BytecodeGeneratorHelper helper; |
| 1632 | 1618 |
| 1633 ExpectedSnippet<int> snippets[] = { | 1619 ExpectedSnippet<int> snippets[] = { |
| 1634 {"var x = 0;" | 1620 {"var x = 0;" |
| 1635 "var y = 1;" | 1621 "var y = 1;" |
| 1636 "while (x < 10) {" | 1622 "while (x < 10) {" |
| 1637 " y = y * 10;" | 1623 " y = y * 12;" |
| 1638 " x = x + 1;" | 1624 " x = x + 1;" |
| 1639 "}" | 1625 "}" |
| 1640 "return y;", | 1626 "return y;", |
| 1641 3 * kPointerSize, | 1627 2 * kPointerSize, |
| 1642 1, | 1628 1, |
| 1643 42, | 1629 30, |
| 1644 { | 1630 { |
| 1645 B(LdaZero), // | 1631 B(LdaZero), // |
| 1646 B(Star), R(0), // | 1632 B(Star), R(0), // |
| 1647 B(LdaSmi8), U8(1), // | 1633 B(LdaSmi8), U8(1), // |
| 1648 B(Star), R(1), // | 1634 B(Star), R(1), // |
| 1649 B(Jump), U8(22), // | 1635 B(Jump), U8(14), // |
| 1650 B(Ldar), R(1), // | 1636 B(LdaSmi8), U8(12), // |
| 1651 B(Star), R(2), // | 1637 B(Mul), R(1), // |
| 1638 B(Star), R(1), // |
| 1639 B(LdaSmi8), U8(1), // |
| 1640 B(Add), R(0), // |
| 1641 B(Star), R(0), // |
| 1652 B(LdaSmi8), U8(10), // | 1642 B(LdaSmi8), U8(10), // |
| 1653 B(Mul), R(2), // | 1643 B(TestLessThan), R(0), // |
| 1654 B(Star), R(1), // | 1644 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), // | 1645 B(Ldar), R(1), // |
| 1666 B(Return), // | 1646 B(Return), // |
| 1667 }, | 1647 }, |
| 1668 0}, | 1648 0}, |
| 1669 {"var i = 0;" | 1649 {"var i = 0;" |
| 1670 "while(true) {" | 1650 "while(true) {" |
| 1671 " if (i < 0) continue;" | 1651 " if (i < 0) continue;" |
| 1672 " if (i == 3) break;" | 1652 " if (i == 3) break;" |
| 1673 " if (i == 4) break;" | 1653 " if (i == 4) break;" |
| 1674 " if (i == 10) continue;" | 1654 " if (i == 10) continue;" |
| 1675 " if (i == 5) break;" | 1655 " if (i == 5) break;" |
| 1676 " i = i + 1;" | 1656 " i = i + 1;" |
| 1677 "}" | 1657 "}" |
| 1678 "return i;", | 1658 "return i;", |
| 1679 2 * kPointerSize, | 1659 1 * kPointerSize, |
| 1680 1, | 1660 1, |
| 1681 80, | 1661 56, |
| 1682 { | 1662 { |
| 1683 B(LdaZero), // | 1663 B(LdaZero), // |
| 1684 B(Star), R(0), // | 1664 B(Star), R(0), // |
| 1685 B(Jump), U8(71), // | 1665 B(Jump), U8(47), // |
| 1686 B(Ldar), R(0), // | |
| 1687 B(Star), R(1), // | |
| 1688 B(LdaZero), // | 1666 B(LdaZero), // |
| 1689 B(TestLessThan), R(1), // | 1667 B(TestLessThan), R(0), // |
| 1690 B(JumpIfFalse), U8(4), // | 1668 B(JumpIfFalse), U8(4), // |
| 1691 B(Jump), U8(60), // | 1669 B(Jump), U8(40), // |
| 1692 B(Ldar), R(0), // | |
| 1693 B(Star), R(1), // | |
| 1694 B(LdaSmi8), U8(3), // | 1670 B(LdaSmi8), U8(3), // |
| 1695 B(TestEqual), R(1), // | 1671 B(TestEqual), R(0), // |
| 1696 B(JumpIfFalse), U8(4), // | 1672 B(JumpIfFalse), U8(4), // |
| 1697 B(Jump), U8(51), // | 1673 B(Jump), U8(35), // |
| 1698 B(Ldar), R(0), // | |
| 1699 B(Star), R(1), // | |
| 1700 B(LdaSmi8), U8(4), // | 1674 B(LdaSmi8), U8(4), // |
| 1701 B(TestEqual), R(1), // | 1675 B(TestEqual), R(0), // |
| 1702 B(JumpIfFalse), U8(4), // | 1676 B(JumpIfFalse), U8(4), // |
| 1703 B(Jump), U8(39), // | 1677 B(Jump), U8(27), // |
| 1704 B(Ldar), R(0), // | |
| 1705 B(Star), R(1), // | |
| 1706 B(LdaSmi8), U8(10), // | 1678 B(LdaSmi8), U8(10), // |
| 1707 B(TestEqual), R(1), // | 1679 B(TestEqual), R(0), // |
| 1708 B(JumpIfFalse), U8(4), // | 1680 B(JumpIfFalse), U8(4), // |
| 1709 B(Jump), U8(24), // | 1681 B(Jump), U8(16), // |
| 1710 B(Ldar), R(0), // | |
| 1711 B(Star), R(1), // | |
| 1712 B(LdaSmi8), U8(5), // | 1682 B(LdaSmi8), U8(5), // |
| 1713 B(TestEqual), R(1), // | 1683 B(TestEqual), R(0), // |
| 1714 B(JumpIfFalse), U8(4), // | 1684 B(JumpIfFalse), U8(4), // |
| 1715 B(Jump), U8(15), // | 1685 B(Jump), U8(11), // |
| 1716 B(Ldar), R(0), // | |
| 1717 B(Star), R(1), // | |
| 1718 B(LdaSmi8), U8(1), // | 1686 B(LdaSmi8), U8(1), // |
| 1719 B(Add), R(1), // | 1687 B(Add), R(0), // |
| 1720 B(Star), R(0), // | 1688 B(Star), R(0), // |
| 1721 B(LdaTrue), // | 1689 B(LdaTrue), // |
| 1722 B(JumpIfTrue), U8(-70), // | 1690 B(JumpIfTrue), U8(-46), // |
| 1723 B(Ldar), R(0), // | 1691 B(Ldar), R(0), // |
| 1724 B(Return) // | 1692 B(Return), // |
| 1725 }, | 1693 }, |
| 1726 0}, | 1694 0}, |
| 1727 {"var x = 0; var y = 1;" | 1695 {"var x = 0; var y = 1;" |
| 1728 "do {" | 1696 "do {" |
| 1729 " y = y * 10;" | 1697 " y = y * 10;" |
| 1730 " if (x == 5) break;" | 1698 " if (x == 5) break;" |
| 1731 " if (x == 6) continue;" | 1699 " if (x == 6) continue;" |
| 1732 " x = x + 1;" | 1700 " x = x + 1;" |
| 1733 "} while (x < 10);" | 1701 "} while (x < 10);" |
| 1734 "return y;", | 1702 "return y;", |
| 1735 3 * kPointerSize, | 1703 2 * kPointerSize, |
| 1736 1, | 1704 1, |
| 1737 64, | 1705 44, |
| 1738 { | 1706 { |
| 1739 B(LdaZero), // | 1707 B(LdaZero), // |
| 1740 B(Star), R(0), // | 1708 B(Star), R(0), // |
| 1741 B(LdaSmi8), U8(1), // | 1709 B(LdaSmi8), U8(1), // |
| 1742 B(Star), R(1), // | 1710 B(Star), R(1), // |
| 1711 B(LdaSmi8), U8(10), // |
| 1712 B(Mul), R(1), // |
| 1713 B(Star), R(1), // |
| 1714 B(LdaSmi8), U8(5), // |
| 1715 B(TestEqual), R(0), // |
| 1716 B(JumpIfFalse), U8(4), // |
| 1717 B(Jump), U8(22), // |
| 1718 B(LdaSmi8), U8(6), // |
| 1719 B(TestEqual), R(0), // |
| 1720 B(JumpIfFalse), U8(4), // |
| 1721 B(Jump), U8(8), // |
| 1722 B(LdaSmi8), U8(1), // |
| 1723 B(Add), R(0), // |
| 1724 B(Star), R(0), // |
| 1725 B(LdaSmi8), U8(10), // |
| 1726 B(TestLessThan), R(0), // |
| 1727 B(JumpIfTrue), U8(-32), // |
| 1743 B(Ldar), R(1), // | 1728 B(Ldar), R(1), // |
| 1744 B(Star), R(2), // | 1729 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 }, | 1730 }, |
| 1773 0}, | 1731 0}, |
| 1774 {"var x = 0; " | 1732 {"var x = 0; " |
| 1775 "for(;;) {" | 1733 "for(;;) {" |
| 1776 " if (x == 1) break;" | 1734 " if (x == 1) break;" |
| 1777 " x = x + 1;" | 1735 " x = x + 1;" |
| 1778 "}", | 1736 "}", |
| 1779 2 * kPointerSize, | 1737 1 * kPointerSize, |
| 1780 1, | 1738 1, |
| 1781 29, | 1739 21, |
| 1782 { | 1740 { |
| 1783 B(LdaZero), // | 1741 B(LdaZero), // |
| 1784 B(Star), R(0), // | 1742 B(Star), R(0), // |
| 1785 B(Ldar), R(0), // | |
| 1786 B(Star), R(1), // | |
| 1787 B(LdaSmi8), U8(1), // | 1743 B(LdaSmi8), U8(1), // |
| 1788 B(TestEqual), R(1), // | 1744 B(TestEqual), R(0), // |
| 1789 B(JumpIfFalse), U8(4), // | 1745 B(JumpIfFalse), U8(4), // |
| 1790 B(Jump), U8(14), // | 1746 B(Jump), U8(10), // |
| 1791 B(Ldar), R(0), // | |
| 1792 B(Star), R(1), // | |
| 1793 B(LdaSmi8), U8(1), // | 1747 B(LdaSmi8), U8(1), // |
| 1794 B(Add), R(1), // | 1748 B(Add), R(0), // |
| 1795 B(Star), R(0), // | 1749 B(Star), R(0), // |
| 1796 B(Jump), U8(-22), // | 1750 B(Jump), U8(-14), // |
| 1797 B(LdaUndefined), // | 1751 B(LdaUndefined), // |
| 1798 B(Return), // | 1752 B(Return), // |
| 1799 }, | 1753 }, |
| 1800 0}, | 1754 0}, |
| 1801 {"var u = 0;" | 1755 {"var u = 0;" |
| 1802 "for(var i = 0; i < 100; i = i + 1) {" | 1756 "for(var i = 0; i < 100; i = i + 1) {" |
| 1803 " u = u + 1;" | 1757 " u = u + 1;" |
| 1804 " continue;" | 1758 " continue;" |
| 1805 "}", | 1759 "}", |
| 1806 3 * kPointerSize, | 1760 2 * kPointerSize, |
| 1807 1, | 1761 1, |
| 1808 42, | 1762 30, |
| 1809 { | 1763 { |
| 1810 B(LdaZero), // | 1764 B(LdaZero), // |
| 1811 B(Star), R(0), // | 1765 B(Star), R(0), // |
| 1812 B(LdaZero), // | 1766 B(LdaZero), // |
| 1813 B(Star), R(1), // | 1767 B(Star), R(1), // |
| 1814 B(Jump), U8(24), // | 1768 B(Jump), U8(16), // |
| 1815 B(Ldar), R(0), // | |
| 1816 B(Star), R(2), // | |
| 1817 B(LdaSmi8), U8(1), // | 1769 B(LdaSmi8), U8(1), // |
| 1818 B(Add), R(2), // | 1770 B(Add), R(0), // |
| 1819 B(Star), R(0), // | 1771 B(Star), R(0), // |
| 1820 B(Jump), U8(2), // | 1772 B(Jump), U8(2), // |
| 1821 B(Ldar), R(1), // | |
| 1822 B(Star), R(2), // | |
| 1823 B(LdaSmi8), U8(1), // | 1773 B(LdaSmi8), U8(1), // |
| 1824 B(Add), R(2), // | 1774 B(Add), R(1), // |
| 1825 B(Star), R(1), // | 1775 B(Star), R(1), // |
| 1826 B(Ldar), R(1), // | |
| 1827 B(Star), R(2), // | |
| 1828 B(LdaSmi8), U8(100), // | 1776 B(LdaSmi8), U8(100), // |
| 1829 B(TestLessThan), R(2), // | 1777 B(TestLessThan), R(1), // |
| 1830 B(JumpIfTrue), U8(-30), // | 1778 B(JumpIfTrue), U8(-18), // |
| 1831 B(LdaUndefined), // | 1779 B(LdaUndefined), // |
| 1832 B(Return), // | 1780 B(Return), // |
| 1833 }, | 1781 }, |
| 1834 0}, | 1782 0}, |
| 1835 {"var i = 0;" | 1783 {"var i = 0;" |
| 1836 "while(true) {" | 1784 "while(true) {" |
| 1837 " while (i < 3) {" | 1785 " while (i < 3) {" |
| 1838 " if (i == 2) break;" | 1786 " if (i == 2) break;" |
| 1839 " i = i + 1;" | 1787 " i = i + 1;" |
| 1840 " }" | 1788 " }" |
| 1841 " i = i + 1;" | 1789 " i = i + 1;" |
| 1842 " break;" | 1790 " break;" |
| 1843 "}" | 1791 "}" |
| 1844 "return i;", | 1792 "return i;", |
| 1845 2 * kPointerSize, | 1793 1 * kPointerSize, |
| 1846 1, | 1794 1, |
| 1847 57, | 1795 41, |
| 1848 { | 1796 { |
| 1849 B(LdaZero), // | 1797 B(LdaZero), // |
| 1850 B(Star), R(0), // | 1798 B(Star), R(0), // |
| 1851 B(Jump), U8(48), // | 1799 B(Jump), U8(32), // |
| 1852 B(Jump), U8(24), // | 1800 B(Jump), U8(16), // |
| 1853 B(Ldar), R(0), // | |
| 1854 B(Star), R(1), // | |
| 1855 B(LdaSmi8), U8(2), // | 1801 B(LdaSmi8), U8(2), // |
| 1856 B(TestEqual), R(1), // | 1802 B(TestEqual), R(0), // |
| 1857 B(JumpIfFalse), U8(4), // | 1803 B(JumpIfFalse), U8(4), // |
| 1858 B(Jump), U8(22), // | 1804 B(Jump), U8(14), // |
| 1859 B(Ldar), R(0), // | |
| 1860 B(Star), R(1), // | |
| 1861 B(LdaSmi8), U8(1), // | 1805 B(LdaSmi8), U8(1), // |
| 1862 B(Add), R(1), // | 1806 B(Add), R(0), // |
| 1863 B(Star), R(0), // | 1807 B(Star), R(0), // |
| 1864 B(Ldar), R(0), // | |
| 1865 B(Star), R(1), // | |
| 1866 B(LdaSmi8), U8(3), // | 1808 B(LdaSmi8), U8(3), // |
| 1867 B(TestLessThan), R(1), // | 1809 B(TestLessThan), R(0), // |
| 1868 B(JumpIfTrue), U8(-30), // | 1810 B(JumpIfTrue), U8(-18), // |
| 1869 B(Ldar), R(0), // | |
| 1870 B(Star), R(1), // | |
| 1871 B(LdaSmi8), U8(1), // | 1811 B(LdaSmi8), U8(1), // |
| 1872 B(Add), R(1), // | 1812 B(Add), R(0), // |
| 1873 B(Star), R(0), // | 1813 B(Star), R(0), // |
| 1874 B(Jump), U8(5), // | 1814 B(Jump), U8(5), // |
| 1875 B(LdaTrue), // | 1815 B(LdaTrue), // |
| 1876 B(JumpIfTrue), U8(-47), // | 1816 B(JumpIfTrue), U8(-31), // |
| 1877 B(Ldar), R(0), // | 1817 B(Ldar), R(0), // |
| 1878 B(Return), // | 1818 B(Return), // |
| 1879 }, | 1819 }, |
| 1880 0}, | 1820 0}, |
| 1881 }; | 1821 }; |
| 1882 | 1822 |
| 1883 for (size_t i = 0; i < arraysize(snippets); i++) { | 1823 for (size_t i = 0; i < arraysize(snippets); i++) { |
| 1884 Handle<BytecodeArray> bytecode_array = | 1824 Handle<BytecodeArray> bytecode_array = |
| 1885 helper.MakeBytecodeForFunctionBody(snippets[i].code_snippet); | 1825 helper.MakeBytecodeForFunctionBody(snippets[i].code_snippet); |
| 1886 CheckBytecodeArrayEqual(snippets[i], bytecode_array); | 1826 CheckBytecodeArrayEqual(snippets[i], bytecode_array); |
| 1887 } | 1827 } |
| 1888 } | 1828 } |
| 1889 | 1829 |
| 1890 | 1830 |
| 1891 TEST(UnaryOperators) { | 1831 TEST(UnaryOperators) { |
| 1892 InitializedHandleScope handle_scope; | 1832 InitializedHandleScope handle_scope; |
| 1893 BytecodeGeneratorHelper helper; | 1833 BytecodeGeneratorHelper helper; |
| 1894 | 1834 |
| 1895 ExpectedSnippet<int> snippets[] = { | 1835 ExpectedSnippet<int> snippets[] = { |
| 1896 {"var x = 0;" | 1836 {"var x = 0;" |
| 1897 "while (x != 10) {" | 1837 "while (x != 10) {" |
| 1898 " x = x + 10;" | 1838 " x = x + 10;" |
| 1899 "}" | 1839 "}" |
| 1900 "return x;", | 1840 "return x;", |
| 1901 2 * kPointerSize, | 1841 kPointerSize, |
| 1902 1, | 1842 1, |
| 1903 29, | 1843 21, |
| 1904 { | 1844 { |
| 1905 B(LdaZero), // | 1845 B(LdaZero), // |
| 1906 B(Star), R(0), // | 1846 B(Star), R(0), // |
| 1907 B(Jump), U8(12), // | 1847 B(Jump), U8(8), // |
| 1908 B(Ldar), R(0), // | |
| 1909 B(Star), R(1), // | |
| 1910 B(LdaSmi8), U8(10), // | 1848 B(LdaSmi8), U8(10), // |
| 1911 B(Add), R(1), // | 1849 B(Add), R(0), // |
| 1912 B(Star), R(0), // | 1850 B(Star), R(0), // |
| 1913 B(Ldar), R(0), // | |
| 1914 B(Star), R(1), // | |
| 1915 B(LdaSmi8), U8(10), // | 1851 B(LdaSmi8), U8(10), // |
| 1916 B(TestEqual), R(1), // | 1852 B(TestEqual), R(0), // |
| 1917 B(LogicalNot), // | 1853 B(LogicalNot), // |
| 1918 B(JumpIfTrue), U8(-19), // | 1854 B(JumpIfTrue), U8(-11), // |
| 1919 B(Ldar), R(0), // | 1855 B(Ldar), R(0), // |
| 1920 B(Return), // | 1856 B(Return), // |
| 1921 }, | 1857 }, |
| 1922 0}, | 1858 0}, |
| 1923 {"var x = false;" | 1859 {"var x = false;" |
| 1924 "do {" | 1860 "do {" |
| 1925 " x = !x;" | 1861 " x = !x;" |
| 1926 "} while(x == false);" | 1862 "} while(x == false);" |
| 1927 "return x;", | 1863 "return x;", |
| 1928 2 * kPointerSize, | 1864 kPointerSize, |
| 1929 1, | 1865 1, |
| 1930 20, | 1866 16, |
| 1931 { | 1867 { |
| 1932 B(LdaFalse), // | 1868 B(LdaFalse), // |
| 1933 B(Star), R(0), // | 1869 B(Star), R(0), // |
| 1934 B(Ldar), R(0), // | 1870 B(Ldar), R(0), // |
| 1935 B(LogicalNot), // | 1871 B(LogicalNot), // |
| 1936 B(Star), R(0), // | 1872 B(Star), R(0), // |
| 1937 B(Ldar), R(0), // | 1873 B(LdaFalse), // |
| 1938 B(Star), R(1), // | 1874 B(TestEqual), R(0), // |
| 1939 B(LdaFalse), // | 1875 B(JumpIfTrue), U8(-8), // |
| 1940 B(TestEqual), R(1), // | 1876 B(Ldar), R(0), // |
| 1941 B(JumpIfTrue), U8(-12), // | 1877 B(Return), // |
| 1942 B(Ldar), R(0), // | |
| 1943 B(Return), // | |
| 1944 }, | 1878 }, |
| 1945 0}, | 1879 0}, |
| 1946 {"var x = 101;" | 1880 {"var x = 101;" |
| 1947 "return void(x * 3);", | 1881 "return void(x * 3);", |
| 1948 2 * kPointerSize, | 1882 kPointerSize, |
| 1949 1, | 1883 1, |
| 1950 14, | 1884 10, |
| 1951 { | 1885 { |
| 1952 B(LdaSmi8), U8(101), // | 1886 B(LdaSmi8), U8(101), // |
| 1953 B(Star), R(0), // | 1887 B(Star), R(0), // |
| 1954 B(Ldar), R(0), // | |
| 1955 B(Star), R(1), // | |
| 1956 B(LdaSmi8), U8(3), // | 1888 B(LdaSmi8), U8(3), // |
| 1957 B(Mul), R(1), // | 1889 B(Mul), R(0), // |
| 1958 B(LdaUndefined), // | 1890 B(LdaUndefined), // |
| 1959 B(Return), // | 1891 B(Return), // |
| 1960 }, | 1892 }, |
| 1961 0}, | 1893 0}, |
| 1962 {"var x = 1234;" | 1894 {"var x = 1234;" |
| 1963 "var y = void (x * x - 1);" | 1895 "var y = void (x * x - 1);" |
| 1964 "return y;", | 1896 "return y;", |
| 1965 4 * kPointerSize, | 1897 3 * kPointerSize, |
| 1966 1, | 1898 1, |
| 1967 24, | 1899 20, |
| 1968 { | 1900 { |
| 1969 B(LdaConstant), U8(0), // | 1901 B(LdaConstant), U8(0), // |
| 1970 B(Star), R(0), // | 1902 B(Star), R(0), // |
| 1971 B(Ldar), R(0), // | 1903 B(Ldar), R(0), // |
| 1972 B(Star), R(3), // | 1904 B(Mul), R(0), // |
| 1973 B(Ldar), R(0), // | |
| 1974 B(Mul), R(3), // | |
| 1975 B(Star), R(2), // | 1905 B(Star), R(2), // |
| 1976 B(LdaSmi8), U8(1), // | 1906 B(LdaSmi8), U8(1), // |
| 1977 B(Sub), R(2), // | 1907 B(Sub), R(2), // |
| 1978 B(LdaUndefined), // | 1908 B(LdaUndefined), // |
| 1979 B(Star), R(1), // | 1909 B(Star), R(1), // |
| 1980 B(Ldar), R(1), // | 1910 B(Ldar), R(1), // |
| 1981 B(Return), // | 1911 B(Return), // |
| 1982 }, | 1912 }, |
| 1983 1, | 1913 1, |
| 1984 {1234}}, | 1914 {1234}}, |
| 1985 {"var x = 13;" | 1915 {"var x = 13;" |
| 1986 "return typeof(x);", | 1916 "return typeof(x);", |
| 1987 1 * kPointerSize, | 1917 kPointerSize, |
| 1988 1, | 1918 1, |
| 1989 8, | 1919 8, |
| 1990 { | 1920 { |
| 1991 B(LdaSmi8), U8(13), // | 1921 B(LdaSmi8), U8(13), // |
| 1992 B(Star), R(0), // | 1922 B(Star), R(0), // TODO(oth): Ldar R(X) following Star R(X) |
| 1993 B(Ldar), R(0), // | 1923 B(Ldar), R(0), // could be culled in bytecode array builder. |
| 1994 B(TypeOf), // | 1924 B(TypeOf), // |
| 1995 B(Return), // | 1925 B(Return), // |
| 1996 }, | 1926 }, |
| 1997 0}, | 1927 0}, |
| 1998 }; | 1928 }; |
| 1999 | 1929 |
| 2000 for (size_t i = 0; i < arraysize(snippets); i++) { | 1930 for (size_t i = 0; i < arraysize(snippets); i++) { |
| 2001 Handle<BytecodeArray> bytecode_array = | 1931 Handle<BytecodeArray> bytecode_array = |
| 2002 helper.MakeBytecodeForFunctionBody(snippets[i].code_snippet); | 1932 helper.MakeBytecodeForFunctionBody(snippets[i].code_snippet); |
| 2003 CheckBytecodeArrayEqual(snippets[i], bytecode_array); | 1933 CheckBytecodeArrayEqual(snippets[i], bytecode_array); |
| (...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2154 1, | 2084 1, |
| 2155 6, | 2085 6, |
| 2156 { | 2086 { |
| 2157 B(LdaConstant), U8(0), // | 2087 B(LdaConstant), U8(0), // |
| 2158 B(CreateArrayLiteral), U8(0), U8(simple_flags), // | 2088 B(CreateArrayLiteral), U8(0), U8(simple_flags), // |
| 2159 B(Return) // | 2089 B(Return) // |
| 2160 }, | 2090 }, |
| 2161 1, | 2091 1, |
| 2162 {InstanceType::FIXED_ARRAY_TYPE}}, | 2092 {InstanceType::FIXED_ARRAY_TYPE}}, |
| 2163 {"var a = 1; return [ a, a + 1 ];", | 2093 {"var a = 1; return [ a, a + 1 ];", |
| 2164 4 * kPointerSize, | 2094 3 * kPointerSize, |
| 2165 1, | 2095 1, |
| 2166 39, | 2096 35, |
| 2167 { | 2097 { |
| 2168 B(LdaSmi8), U8(1), // | 2098 B(LdaSmi8), U8(1), // |
| 2169 B(Star), R(0), // | 2099 B(Star), R(0), // |
| 2170 B(LdaConstant), U8(0), // | 2100 B(LdaConstant), U8(0), // |
| 2171 B(CreateArrayLiteral), U8(0), U8(3), // | 2101 B(CreateArrayLiteral), U8(0), U8(3), // |
| 2172 B(Star), R(2), // | 2102 B(Star), R(2), // |
| 2173 B(LdaZero), // | 2103 B(LdaZero), // |
| 2174 B(Star), R(1), // | 2104 B(Star), R(1), // |
| 2175 B(Ldar), R(0), // | 2105 B(Ldar), R(0), // |
| 2176 B(KeyedStoreICSloppy), R(2), R(1), U8(vector->GetIndex(slot1)), // | 2106 B(KeyedStoreICSloppy), R(2), R(1), U8(vector->GetIndex(slot1)), // |
| 2177 B(LdaSmi8), U8(1), // | 2107 B(LdaSmi8), U8(1), // |
| 2178 B(Star), R(1), // | 2108 B(Star), R(1), // |
| 2179 B(Ldar), R(0), // | |
| 2180 B(Star), R(3), // | |
| 2181 B(LdaSmi8), U8(1), // | 2109 B(LdaSmi8), U8(1), // |
| 2182 B(Add), R(3), // | 2110 B(Add), R(0), // |
| 2183 B(KeyedStoreICSloppy), R(2), R(1), U8(vector->GetIndex(slot1)), // | 2111 B(KeyedStoreICSloppy), R(2), R(1), U8(vector->GetIndex(slot1)), // |
| 2184 B(Ldar), R(2), // | 2112 B(Ldar), R(2), // |
| 2185 B(Return) // | 2113 B(Return), // |
| 2186 }, | 2114 }, |
| 2187 1, | 2115 1, |
| 2188 {InstanceType::FIXED_ARRAY_TYPE}}, | 2116 {InstanceType::FIXED_ARRAY_TYPE}}, |
| 2189 {"return [ [ 1, 2 ], [ 3 ] ];", | 2117 {"return [ [ 1, 2 ], [ 3 ] ];", |
| 2190 0, | 2118 0, |
| 2191 1, | 2119 1, |
| 2192 6, | 2120 6, |
| 2193 { | 2121 { |
| 2194 B(LdaConstant), U8(0), // | 2122 B(LdaConstant), U8(0), // |
| 2195 B(CreateArrayLiteral), U8(2), U8(deep_elements_flags), // | 2123 B(CreateArrayLiteral), U8(2), U8(deep_elements_flags), // |
| 2196 B(Return) // | 2124 B(Return) // |
| 2197 }, | 2125 }, |
| 2198 1, | 2126 1, |
| 2199 {InstanceType::FIXED_ARRAY_TYPE}}, | 2127 {InstanceType::FIXED_ARRAY_TYPE}}, |
| 2200 {"var a = 1; return [ [ a, 2 ], [ a + 2 ] ];", | 2128 {"var a = 1; return [ [ a, 2 ], [ a + 2 ] ];", |
| 2201 6 * kPointerSize, | 2129 5 * kPointerSize, |
| 2202 1, | 2130 1, |
| 2203 71, | 2131 67, |
| 2204 { | 2132 { |
| 2205 B(LdaSmi8), U8(1), // | 2133 B(LdaSmi8), U8(1), // |
| 2206 B(Star), R(0), // | 2134 B(Star), R(0), // |
| 2207 B(LdaConstant), U8(0), // | 2135 B(LdaConstant), U8(0), // |
| 2208 B(CreateArrayLiteral), U8(2), U8(deep_elements_flags), // | 2136 B(CreateArrayLiteral), U8(2), U8(deep_elements_flags), // |
| 2209 B(Star), R(2), // | 2137 B(Star), R(2), // |
| 2210 B(LdaZero), // | 2138 B(LdaZero), // |
| 2211 B(Star), R(1), // | 2139 B(Star), R(1), // |
| 2212 B(LdaConstant), U8(1), // | 2140 B(LdaConstant), U8(1), // |
| 2213 B(CreateArrayLiteral), U8(0), U8(simple_flags), // | 2141 B(CreateArrayLiteral), U8(0), U8(simple_flags), // |
| 2214 B(Star), R(4), // | 2142 B(Star), R(4), // |
| 2215 B(LdaZero), // | 2143 B(LdaZero), // |
| 2216 B(Star), R(3), // | 2144 B(Star), R(3), // |
| 2217 B(Ldar), R(0), // | 2145 B(Ldar), R(0), // |
| 2218 B(KeyedStoreICSloppy), R(4), R(3), U8(vector->GetIndex(slot1)), // | 2146 B(KeyedStoreICSloppy), R(4), R(3), U8(vector->GetIndex(slot1)), // |
| 2219 B(Ldar), R(4), // | 2147 B(Ldar), R(4), // |
| 2220 B(KeyedStoreICSloppy), R(2), R(1), U8(vector->GetIndex(slot3)), // | 2148 B(KeyedStoreICSloppy), R(2), R(1), U8(vector->GetIndex(slot3)), // |
| 2221 B(LdaSmi8), U8(1), // | 2149 B(LdaSmi8), U8(1), // |
| 2222 B(Star), R(1), // | 2150 B(Star), R(1), // |
| 2223 B(LdaConstant), U8(2), // | 2151 B(LdaConstant), U8(2), // |
| 2224 B(CreateArrayLiteral), U8(1), U8(simple_flags), // | 2152 B(CreateArrayLiteral), U8(1), U8(simple_flags), // |
| 2225 B(Star), R(4), // | 2153 B(Star), R(4), // |
| 2226 B(LdaZero), // | 2154 B(LdaZero), // |
| 2227 B(Star), R(3), // | 2155 B(Star), R(3), // |
| 2228 B(Ldar), R(0), // | |
| 2229 B(Star), R(5), // | |
| 2230 B(LdaSmi8), U8(2), // | 2156 B(LdaSmi8), U8(2), // |
| 2231 B(Add), R(5), // | 2157 B(Add), R(0), // |
| 2232 B(KeyedStoreICSloppy), R(4), R(3), U8(vector->GetIndex(slot2)), // | 2158 B(KeyedStoreICSloppy), R(4), R(3), U8(vector->GetIndex(slot2)), // |
| 2233 B(Ldar), R(4), // | 2159 B(Ldar), R(4), // |
| 2234 B(KeyedStoreICSloppy), R(2), R(1), U8(vector->GetIndex(slot3)), // | 2160 B(KeyedStoreICSloppy), R(2), R(1), U8(vector->GetIndex(slot3)), // |
| 2235 B(Ldar), R(2), // | 2161 B(Ldar), R(2), // |
| 2236 B(Return), // | 2162 B(Return), // |
| 2237 }, | 2163 }, |
| 2238 3, | 2164 3, |
| 2239 {InstanceType::FIXED_ARRAY_TYPE, InstanceType::FIXED_ARRAY_TYPE, | 2165 {InstanceType::FIXED_ARRAY_TYPE, InstanceType::FIXED_ARRAY_TYPE, |
| 2240 InstanceType::FIXED_ARRAY_TYPE}}, | 2166 InstanceType::FIXED_ARRAY_TYPE}}, |
| 2241 }; | 2167 }; |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2294 B(Star), R(2), // | 2220 B(Star), R(2), // |
| 2295 B(Ldar), R(0), // | 2221 B(Ldar), R(0), // |
| 2296 B(StoreICSloppy), R(1), R(2), U8(3), // | 2222 B(StoreICSloppy), R(1), R(2), U8(3), // |
| 2297 B(Ldar), R(1), // | 2223 B(Ldar), R(1), // |
| 2298 B(Return), // | 2224 B(Return), // |
| 2299 }, | 2225 }, |
| 2300 2, | 2226 2, |
| 2301 {InstanceType::FIXED_ARRAY_TYPE, | 2227 {InstanceType::FIXED_ARRAY_TYPE, |
| 2302 InstanceType::ONE_BYTE_INTERNALIZED_STRING_TYPE}}, | 2228 InstanceType::ONE_BYTE_INTERNALIZED_STRING_TYPE}}, |
| 2303 {"var a = 1; return { val: a, val: a + 1 };", | 2229 {"var a = 1; return { val: a, val: a + 1 };", |
| 2304 4 * kPointerSize, | 2230 3 * kPointerSize, |
| 2305 1, | 2231 1, |
| 2306 32, | 2232 26, |
| 2307 { | 2233 { |
| 2308 B(LdaSmi8), U8(1), // | 2234 B(LdaSmi8), U8(1), // |
| 2309 B(Star), R(0), // | 2235 B(Star), R(0), // |
| 2310 B(LdaConstant), U8(0), // | 2236 B(LdaConstant), U8(0), // |
| 2311 B(CreateObjectLiteral), U8(0), U8(deep_elements_flags), // | 2237 B(CreateObjectLiteral), U8(0), U8(deep_elements_flags), // |
| 2312 B(Star), R(1), // | 2238 B(Star), R(1), // |
| 2313 B(Ldar), R(0), // | |
| 2314 B(LdaConstant), U8(1), // | 2239 B(LdaConstant), U8(1), // |
| 2315 B(Star), R(2), // | 2240 B(Star), R(2), // |
| 2316 B(Ldar), R(0), // | |
| 2317 B(Star), R(3), // | |
| 2318 B(LdaSmi8), U8(1), // | 2241 B(LdaSmi8), U8(1), // |
| 2319 B(Add), R(3), // | 2242 B(Add), R(0), // |
| 2320 B(StoreICSloppy), R(1), R(2), U8(3), // | 2243 B(StoreICSloppy), R(1), R(2), U8(3), // |
| 2321 B(Ldar), R(1), // | 2244 B(Ldar), R(1), // |
| 2322 B(Return), // | 2245 B(Return), // |
| 2323 }, | 2246 }, |
| 2324 2, | 2247 2, |
| 2325 {InstanceType::FIXED_ARRAY_TYPE, | 2248 {InstanceType::FIXED_ARRAY_TYPE, |
| 2326 InstanceType::ONE_BYTE_INTERNALIZED_STRING_TYPE}}, | 2249 InstanceType::ONE_BYTE_INTERNALIZED_STRING_TYPE}}, |
| 2327 {"return { func: function() { } };", | 2250 {"return { func: function() { } };", |
| 2328 2 * kPointerSize, | 2251 2 * kPointerSize, |
| 2329 1, | 2252 1, |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2375 B(LdaConstant), U8(1), // | 2298 B(LdaConstant), U8(1), // |
| 2376 B(Star), R(1), // | 2299 B(Star), R(1), // |
| 2377 B(LdaConstant), U8(2), // | 2300 B(LdaConstant), U8(2), // |
| 2378 B(CreateClosure), U8(0), // | 2301 B(CreateClosure), U8(0), // |
| 2379 B(Star), R(2), // | 2302 B(Star), R(2), // |
| 2380 B(LdaNull), // | 2303 B(LdaNull), // |
| 2381 B(Star), R(3), // | 2304 B(Star), R(3), // |
| 2382 B(LdaZero), // | 2305 B(LdaZero), // |
| 2383 B(Star), R(4), // | 2306 B(Star), R(4), // |
| 2384 B(CallRuntime), U16(Runtime::kDefineAccessorPropertyUnchecked), // | 2307 B(CallRuntime), U16(Runtime::kDefineAccessorPropertyUnchecked), // |
| 2385 R(0), U8(5), // | 2308 R(0), U8(5), // |
| 2386 B(Ldar), R(0), // | 2309 B(Ldar), R(0), // |
| 2387 B(Return), // | 2310 B(Return), // |
| 2388 }, | 2311 }, |
| 2389 3, | 2312 3, |
| 2390 {InstanceType::FIXED_ARRAY_TYPE, | 2313 {InstanceType::FIXED_ARRAY_TYPE, |
| 2391 InstanceType::ONE_BYTE_INTERNALIZED_STRING_TYPE, | 2314 InstanceType::ONE_BYTE_INTERNALIZED_STRING_TYPE, |
| 2392 InstanceType::SHARED_FUNCTION_INFO_TYPE}}, | 2315 InstanceType::SHARED_FUNCTION_INFO_TYPE}}, |
| 2393 {"return { get a() { return this.x; }, set a(val) { this.x = val } };", | 2316 {"return { get a() { return this.x; }, set a(val) { this.x = val } };", |
| 2394 5 * kPointerSize, | 2317 5 * kPointerSize, |
| 2395 1, | 2318 1, |
| 2396 34, | 2319 34, |
| 2397 { | 2320 { |
| 2398 B(LdaConstant), U8(0), // | 2321 B(LdaConstant), U8(0), // |
| 2399 B(CreateObjectLiteral), U8(0), U8(deep_elements_flags), // | 2322 B(CreateObjectLiteral), U8(0), U8(deep_elements_flags), // |
| 2400 B(Star), R(0), // | 2323 B(Star), R(0), // |
| 2401 B(LdaConstant), U8(1), // | 2324 B(LdaConstant), U8(1), // |
| 2402 B(Star), R(1), // | 2325 B(Star), R(1), // |
| 2403 B(LdaConstant), U8(2), // | 2326 B(LdaConstant), U8(2), // |
| 2404 B(CreateClosure), U8(0), // | 2327 B(CreateClosure), U8(0), // |
| 2405 B(Star), R(2), // | 2328 B(Star), R(2), // |
| 2406 B(LdaConstant), U8(3), // | 2329 B(LdaConstant), U8(3), // |
| 2407 B(CreateClosure), U8(0), // | 2330 B(CreateClosure), U8(0), // |
| 2408 B(Star), R(3), // | 2331 B(Star), R(3), // |
| 2409 B(LdaZero), // | 2332 B(LdaZero), // |
| 2410 B(Star), R(4), // | 2333 B(Star), R(4), // |
| 2411 B(CallRuntime), U16(Runtime::kDefineAccessorPropertyUnchecked), // | 2334 B(CallRuntime), U16(Runtime::kDefineAccessorPropertyUnchecked), // |
| 2412 R(0), U8(5), // | 2335 R(0), U8(5), // |
| 2413 B(Ldar), R(0), // | 2336 B(Ldar), R(0), // |
| 2414 B(Return), // | 2337 B(Return), // |
| 2415 }, | 2338 }, |
| 2416 4, | 2339 4, |
| 2417 {InstanceType::FIXED_ARRAY_TYPE, | 2340 {InstanceType::FIXED_ARRAY_TYPE, |
| 2418 InstanceType::ONE_BYTE_INTERNALIZED_STRING_TYPE, | 2341 InstanceType::ONE_BYTE_INTERNALIZED_STRING_TYPE, |
| 2419 InstanceType::SHARED_FUNCTION_INFO_TYPE, | 2342 InstanceType::SHARED_FUNCTION_INFO_TYPE, |
| 2420 InstanceType::SHARED_FUNCTION_INFO_TYPE}}, | 2343 InstanceType::SHARED_FUNCTION_INFO_TYPE}}, |
| 2421 {"return { set b(val) { this.y = val } };", | 2344 {"return { set b(val) { this.y = val } };", |
| 2422 5 * kPointerSize, | 2345 5 * kPointerSize, |
| 2423 1, | 2346 1, |
| 2424 31, | 2347 31, |
| 2425 { | 2348 { |
| 2426 B(LdaConstant), U8(0), // | 2349 B(LdaConstant), U8(0), // |
| 2427 B(CreateObjectLiteral), U8(0), U8(deep_elements_flags), // | 2350 B(CreateObjectLiteral), U8(0), U8(deep_elements_flags), // |
| 2428 B(Star), R(0), // | 2351 B(Star), R(0), // |
| 2429 B(LdaConstant), U8(1), // | 2352 B(LdaConstant), U8(1), // |
| 2430 B(Star), R(1), // | 2353 B(Star), R(1), // |
| 2431 B(LdaNull), // | 2354 B(LdaNull), // |
| 2432 B(Star), R(2), // | 2355 B(Star), R(2), // |
| 2433 B(LdaConstant), U8(2), // | 2356 B(LdaConstant), U8(2), // |
| 2434 B(CreateClosure), U8(0), // | 2357 B(CreateClosure), U8(0), // |
| 2435 B(Star), R(3), // | 2358 B(Star), R(3), // |
| 2436 B(LdaZero), // | 2359 B(LdaZero), // |
| 2437 B(Star), R(4), // | 2360 B(Star), R(4), // |
| 2438 B(CallRuntime), U16(Runtime::kDefineAccessorPropertyUnchecked), // | 2361 B(CallRuntime), U16(Runtime::kDefineAccessorPropertyUnchecked), // |
| 2439 R(0), U8(5), // | 2362 R(0), U8(5), // |
| 2440 B(Ldar), R(0), // | 2363 B(Ldar), R(0), // |
| 2441 B(Return), // | 2364 B(Return), // |
| 2442 }, | 2365 }, |
| 2443 3, | 2366 3, |
| 2444 {InstanceType::FIXED_ARRAY_TYPE, | 2367 {InstanceType::FIXED_ARRAY_TYPE, |
| 2445 InstanceType::ONE_BYTE_INTERNALIZED_STRING_TYPE, | 2368 InstanceType::ONE_BYTE_INTERNALIZED_STRING_TYPE, |
| 2446 InstanceType::SHARED_FUNCTION_INFO_TYPE}}, | 2369 InstanceType::SHARED_FUNCTION_INFO_TYPE}}, |
| 2447 {"var a = 1; return { 1: a };", | 2370 {"var a = 1; return { 1: a };", |
| 2448 5 * kPointerSize, | 2371 5 * kPointerSize, |
| 2449 1, | 2372 1, |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2492 B(CreateObjectLiteral), U8(0), U8(simple_flags), // | 2415 B(CreateObjectLiteral), U8(0), U8(simple_flags), // |
| 2493 B(Star), R(1), // | 2416 B(Star), R(1), // |
| 2494 B(Ldar), R(0), // | 2417 B(Ldar), R(0), // |
| 2495 B(ToName), // | 2418 B(ToName), // |
| 2496 B(Star), R(2), // | 2419 B(Star), R(2), // |
| 2497 B(LdaSmi8), U8(1), // | 2420 B(LdaSmi8), U8(1), // |
| 2498 B(Star), R(3), // | 2421 B(Star), R(3), // |
| 2499 B(LdaZero), // | 2422 B(LdaZero), // |
| 2500 B(Star), R(4), // | 2423 B(Star), R(4), // |
| 2501 B(CallRuntime), U16(Runtime::kDefineDataPropertyUnchecked), R(1), // | 2424 B(CallRuntime), U16(Runtime::kDefineDataPropertyUnchecked), R(1), // |
| 2502 U8(4), // | 2425 U8(4), // |
| 2503 B(Ldar), R(1), // | 2426 B(Ldar), R(1), // |
| 2504 B(Return), // | 2427 B(Return), // |
| 2505 }, | 2428 }, |
| 2506 2, | 2429 2, |
| 2507 {InstanceType::ONE_BYTE_INTERNALIZED_STRING_TYPE, | 2430 {InstanceType::ONE_BYTE_INTERNALIZED_STRING_TYPE, |
| 2508 InstanceType::FIXED_ARRAY_TYPE}}, | 2431 InstanceType::FIXED_ARRAY_TYPE}}, |
| 2509 {"var a = 'test'; return { val: a, [a]: 1 }", | 2432 {"var a = 'test'; return { val: a, [a]: 1 }", |
| 2510 5 * kPointerSize, | 2433 5 * kPointerSize, |
| 2511 1, | 2434 1, |
| 2512 41, | 2435 41, |
| 2513 { | 2436 { |
| 2514 B(LdaConstant), U8(0), // | 2437 B(LdaConstant), U8(0), // |
| 2515 B(Star), R(0), // | 2438 B(Star), R(0), // |
| 2516 B(LdaConstant), U8(1), // | 2439 B(LdaConstant), U8(1), // |
| 2517 B(CreateObjectLiteral), U8(0), U8(deep_elements_flags), // | 2440 B(CreateObjectLiteral), U8(0), U8(deep_elements_flags), // |
| 2518 B(Star), R(1), // | 2441 B(Star), R(1), // |
| 2519 B(LdaConstant), U8(2), // | 2442 B(LdaConstant), U8(2), // |
| 2520 B(Star), R(2), // | 2443 B(Star), R(2), // |
| 2521 B(Ldar), R(0), // | 2444 B(Ldar), R(0), // |
| 2522 B(StoreICSloppy), R(1), R(2), U8(3), // | 2445 B(StoreICSloppy), R(1), R(2), U8(3), // |
| 2523 B(Ldar), R(0), // | 2446 B(Ldar), R(0), // |
| 2524 B(ToName), // | 2447 B(ToName), // |
| 2525 B(Star), R(2), // | 2448 B(Star), R(2), // |
| 2526 B(LdaSmi8), U8(1), // | 2449 B(LdaSmi8), U8(1), // |
| 2527 B(Star), R(3), // | 2450 B(Star), R(3), // |
| 2528 B(LdaZero), // | 2451 B(LdaZero), // |
| 2529 B(Star), R(4), // | 2452 B(Star), R(4), // |
| 2530 B(CallRuntime), U16(Runtime::kDefineDataPropertyUnchecked), R(1), // | 2453 B(CallRuntime), U16(Runtime::kDefineDataPropertyUnchecked), R(1), // |
| 2531 U8(4), // | 2454 U8(4), // |
| 2532 B(Ldar), R(1), // | 2455 B(Ldar), R(1), // |
| 2533 B(Return), // | 2456 B(Return), // |
| 2534 }, | 2457 }, |
| 2535 3, | 2458 3, |
| 2536 {InstanceType::ONE_BYTE_INTERNALIZED_STRING_TYPE, | 2459 {InstanceType::ONE_BYTE_INTERNALIZED_STRING_TYPE, |
| 2537 InstanceType::FIXED_ARRAY_TYPE, | 2460 InstanceType::FIXED_ARRAY_TYPE, |
| 2538 InstanceType::ONE_BYTE_INTERNALIZED_STRING_TYPE}}, | 2461 InstanceType::ONE_BYTE_INTERNALIZED_STRING_TYPE}}, |
| 2539 {"var a = 'test'; return { [a]: 1, __proto__: {} }", | 2462 {"var a = 'test'; return { [a]: 1, __proto__: {} }", |
| 2540 5 * kPointerSize, | 2463 5 * kPointerSize, |
| 2541 1, | 2464 1, |
| 2542 43, | 2465 43, |
| 2543 { | 2466 { |
| 2544 B(LdaConstant), U8(0), // | 2467 B(LdaConstant), U8(0), // |
| 2545 B(Star), R(0), // | 2468 B(Star), R(0), // |
| 2546 B(LdaConstant), U8(1), // | 2469 B(LdaConstant), U8(1), // |
| 2547 B(CreateObjectLiteral), U8(1), U8(simple_flags), // | 2470 B(CreateObjectLiteral), U8(1), U8(simple_flags), // |
| 2548 B(Star), R(1), // | 2471 B(Star), R(1), // |
| 2549 B(Ldar), R(0), // | 2472 B(Ldar), R(0), // |
| 2550 B(ToName), // | 2473 B(ToName), // |
| 2551 B(Star), R(2), // | 2474 B(Star), R(2), // |
| 2552 B(LdaSmi8), U8(1), // | 2475 B(LdaSmi8), U8(1), // |
| 2553 B(Star), R(3), // | 2476 B(Star), R(3), // |
| 2554 B(LdaZero), // | 2477 B(LdaZero), // |
| 2555 B(Star), R(4), // | 2478 B(Star), R(4), // |
| 2556 B(CallRuntime), U16(Runtime::kDefineDataPropertyUnchecked), R(1), // | 2479 B(CallRuntime), U16(Runtime::kDefineDataPropertyUnchecked), R(1), // |
| 2557 U8(4), // | 2480 U8(4), // |
| 2558 B(LdaConstant), U8(1), // | 2481 B(LdaConstant), U8(1), // |
| 2559 B(CreateObjectLiteral), U8(0), U8(13), // | 2482 B(CreateObjectLiteral), U8(0), U8(13), // |
| 2560 B(Star), R(2), // | 2483 B(Star), R(2), // |
| 2561 B(CallRuntime), U16(Runtime::kInternalSetPrototype), R(1), U8(2), // | 2484 B(CallRuntime), U16(Runtime::kInternalSetPrototype), R(1), U8(2), // |
| 2562 B(Ldar), R(1), // | 2485 B(Ldar), R(1), // |
| 2563 B(Return), // | 2486 B(Return), // |
| 2564 }, | 2487 }, |
| 2565 2, | 2488 2, |
| 2566 {InstanceType::ONE_BYTE_INTERNALIZED_STRING_TYPE, | 2489 {InstanceType::ONE_BYTE_INTERNALIZED_STRING_TYPE, |
| 2567 InstanceType::FIXED_ARRAY_TYPE}}, | 2490 InstanceType::FIXED_ARRAY_TYPE}}, |
| 2568 {"var n = 'name'; return { [n]: 'val', get a() { }, set a(b) {} };", | 2491 {"var n = 'name'; return { [n]: 'val', get a() { }, set a(b) {} };", |
| 2569 5 * kPointerSize, | 2492 5 * kPointerSize, |
| 2570 1, | 2493 1, |
| 2571 69, | 2494 69, |
| 2572 { | 2495 { |
| 2573 B(LdaConstant), U8(0), // | 2496 B(LdaConstant), U8(0), // |
| 2574 B(Star), R(0), // | 2497 B(Star), R(0), // |
| 2575 B(LdaConstant), U8(1), // | 2498 B(LdaConstant), U8(1), // |
| 2576 B(CreateObjectLiteral), U8(0), U8(simple_flags), // | 2499 B(CreateObjectLiteral), U8(0), U8(simple_flags), // |
| 2577 B(Star), R(1), // | 2500 B(Star), R(1), // |
| 2578 B(Ldar), R(0), // | 2501 B(Ldar), R(0), // |
| 2579 B(ToName), // | 2502 B(ToName), // |
| 2580 B(Star), R(2), // | 2503 B(Star), R(2), // |
| 2581 B(LdaConstant), U8(2), // | 2504 B(LdaConstant), U8(2), // |
| 2582 B(Star), R(3), // | 2505 B(Star), R(3), // |
| 2583 B(LdaZero), // | 2506 B(LdaZero), // |
| 2584 B(Star), R(4), // | 2507 B(Star), R(4), // |
| 2585 B(CallRuntime), U16(Runtime::kDefineDataPropertyUnchecked), R(1), // | 2508 B(CallRuntime), U16(Runtime::kDefineDataPropertyUnchecked), R(1), // |
| 2586 U8(4), // | 2509 U8(4), // |
| 2587 B(LdaConstant), U8(3), // | 2510 B(LdaConstant), U8(3), // |
| 2588 B(ToName), // | 2511 B(ToName), // |
| 2589 B(Star), R(2), // | 2512 B(Star), R(2), // |
| 2590 B(LdaConstant), U8(4), // | 2513 B(LdaConstant), U8(4), // |
| 2591 B(CreateClosure), U8(0), // | 2514 B(CreateClosure), U8(0), // |
| 2592 B(Star), R(3), // | 2515 B(Star), R(3), // |
| 2593 B(LdaZero), // | 2516 B(LdaZero), // |
| 2594 B(Star), R(4), // | 2517 B(Star), R(4), // |
| 2595 B(CallRuntime), U16(Runtime::kDefineGetterPropertyUnchecked), // | 2518 B(CallRuntime), U16(Runtime::kDefineGetterPropertyUnchecked), // |
| 2596 R(1), U8(4), // | 2519 R(1), U8(4), // |
| 2597 B(LdaConstant), U8(3), // | 2520 B(LdaConstant), U8(3), // |
| 2598 B(ToName), // | 2521 B(ToName), // |
| 2599 B(Star), R(2), // | 2522 B(Star), R(2), // |
| 2600 B(LdaConstant), U8(5), // | 2523 B(LdaConstant), U8(5), // |
| 2601 B(CreateClosure), U8(0), // | 2524 B(CreateClosure), U8(0), // |
| 2602 B(Star), R(3), // | 2525 B(Star), R(3), // |
| 2603 B(LdaZero), // | 2526 B(LdaZero), // |
| 2604 B(Star), R(4), // | 2527 B(Star), R(4), // |
| 2605 B(CallRuntime), U16(Runtime::kDefineSetterPropertyUnchecked), // | 2528 B(CallRuntime), U16(Runtime::kDefineSetterPropertyUnchecked), // |
| 2606 R(1), U8(4), // | 2529 R(1), U8(4), // |
| 2607 B(Ldar), R(1), // | 2530 B(Ldar), R(1), // |
| 2608 B(Return), // | 2531 B(Return), // |
| 2609 }, | 2532 }, |
| 2610 6, | 2533 6, |
| 2611 {InstanceType::ONE_BYTE_INTERNALIZED_STRING_TYPE, | 2534 {InstanceType::ONE_BYTE_INTERNALIZED_STRING_TYPE, |
| 2612 InstanceType::FIXED_ARRAY_TYPE, | 2535 InstanceType::FIXED_ARRAY_TYPE, |
| 2613 InstanceType::ONE_BYTE_INTERNALIZED_STRING_TYPE, | 2536 InstanceType::ONE_BYTE_INTERNALIZED_STRING_TYPE, |
| 2614 InstanceType::ONE_BYTE_INTERNALIZED_STRING_TYPE, | 2537 InstanceType::ONE_BYTE_INTERNALIZED_STRING_TYPE, |
| 2615 InstanceType::SHARED_FUNCTION_INFO_TYPE, | 2538 InstanceType::SHARED_FUNCTION_INFO_TYPE, |
| 2616 InstanceType::SHARED_FUNCTION_INFO_TYPE}}, | 2539 InstanceType::SHARED_FUNCTION_INFO_TYPE}}, |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2658 B(LdaConstant), U8(4), // | 2581 B(LdaConstant), U8(4), // |
| 2659 B(Star), R(6), // | 2582 B(Star), R(6), // |
| 2660 B(LdaConstant), U8(5), // | 2583 B(LdaConstant), U8(5), // |
| 2661 B(CreateClosure), U8(1), // | 2584 B(CreateClosure), U8(1), // |
| 2662 B(StoreICSloppy), R(5), R(6), U8(3), // | 2585 B(StoreICSloppy), R(5), R(6), U8(3), // |
| 2663 B(CallRuntime), U16(Runtime::kToFastProperties), R(5), U8(1), // | 2586 B(CallRuntime), U16(Runtime::kToFastProperties), R(5), U8(1), // |
| 2664 B(Ldar), R(5), // | 2587 B(Ldar), R(5), // |
| 2665 B(Star), R(4), // | 2588 B(Star), R(4), // |
| 2666 B(CallRuntime), U16(Runtime::kInitializeVarGlobal), R(2), U8(3), // | 2589 B(CallRuntime), U16(Runtime::kInitializeVarGlobal), R(2), U8(3), // |
| 2667 B(LdaUndefined), // | 2590 B(LdaUndefined), // |
| 2668 B(Return), // | 2591 B(Return), |
| 2669 }, | 2592 }, |
| 2670 6, | 2593 6, |
| 2671 {InstanceType::FIXED_ARRAY_TYPE, | 2594 {InstanceType::FIXED_ARRAY_TYPE, InstanceType::FIXED_ARRAY_TYPE, |
| 2672 InstanceType::FIXED_ARRAY_TYPE, | |
| 2673 InstanceType::ONE_BYTE_INTERNALIZED_STRING_TYPE, | 2595 InstanceType::ONE_BYTE_INTERNALIZED_STRING_TYPE, |
| 2674 InstanceType::FIXED_ARRAY_TYPE, | 2596 InstanceType::FIXED_ARRAY_TYPE, |
| 2675 InstanceType::ONE_BYTE_INTERNALIZED_STRING_TYPE, | 2597 InstanceType::ONE_BYTE_INTERNALIZED_STRING_TYPE, |
| 2676 InstanceType::SHARED_FUNCTION_INFO_TYPE}}, | 2598 InstanceType::SHARED_FUNCTION_INFO_TYPE}}, |
| 2677 }; | 2599 }; |
| 2678 | 2600 |
| 2679 for (size_t i = 0; i < arraysize(snippets); i++) { | 2601 for (size_t i = 0; i < arraysize(snippets); i++) { |
| 2680 Handle<BytecodeArray> bytecode_array = | 2602 Handle<BytecodeArray> bytecode_array = |
| 2681 helper.MakeTopLevelBytecode(snippets[i].code_snippet); | 2603 helper.MakeTopLevelBytecode(snippets[i].code_snippet); |
| 2682 CheckBytecodeArrayEqual(snippets[i], bytecode_array); | 2604 CheckBytecodeArrayEqual(snippets[i], bytecode_array); |
| 2683 } | 2605 } |
| 2684 } | 2606 } |
| 2685 | 2607 |
| 2686 | 2608 |
| 2687 TEST(TryCatch) { | 2609 TEST(TryCatch) { |
| 2688 InitializedHandleScope handle_scope; | 2610 InitializedHandleScope handle_scope; |
| 2689 BytecodeGeneratorHelper helper; | 2611 BytecodeGeneratorHelper helper; |
| 2690 | 2612 |
| 2691 // TODO(rmcilroy): modify tests when we have real try catch support. | 2613 // TODO(rmcilroy): modify tests when we have real try catch support. |
| 2692 ExpectedSnippet<int> snippets[] = { | 2614 ExpectedSnippet<int> snippets[] = { |
| 2693 {"try { return 1; } catch(e) { return 2; }", | 2615 {"try { return 1; } catch(e) { return 2; }", |
| 2694 1 * kPointerSize, | 2616 kPointerSize, |
| 2695 1, | 2617 1, |
| 2696 5, | 2618 5, |
| 2697 { | 2619 { |
| 2698 B(LdaSmi8), U8(1), // | 2620 B(LdaSmi8), U8(1), // |
| 2699 B(Return), // | 2621 B(Return), // |
| 2700 B(LdaUndefined), // | 2622 B(LdaUndefined), // |
| 2701 B(Return), // | 2623 B(Return), // |
| 2702 }, | 2624 }, |
| 2703 0}, | 2625 0}, |
| 2704 }; | 2626 }; |
| 2705 | 2627 |
| 2706 for (size_t i = 0; i < arraysize(snippets); i++) { | 2628 for (size_t i = 0; i < arraysize(snippets); i++) { |
| 2707 Handle<BytecodeArray> bytecode_array = | 2629 Handle<BytecodeArray> bytecode_array = |
| 2708 helper.MakeBytecodeForFunctionBody(snippets[i].code_snippet); | 2630 helper.MakeBytecodeForFunctionBody(snippets[i].code_snippet); |
| 2709 CheckBytecodeArrayEqual(snippets[i], bytecode_array); | 2631 CheckBytecodeArrayEqual(snippets[i], bytecode_array); |
| 2710 } | 2632 } |
| 2711 } | 2633 } |
| 2712 | 2634 |
| 2713 | 2635 |
| 2714 TEST(TryFinally) { | 2636 TEST(TryFinally) { |
| 2715 InitializedHandleScope handle_scope; | 2637 InitializedHandleScope handle_scope; |
| 2716 BytecodeGeneratorHelper helper; | 2638 BytecodeGeneratorHelper helper; |
| 2717 | 2639 |
| 2718 // TODO(rmcilroy): modify tests when we have real try finally support. | 2640 // TODO(rmcilroy): modify tests when we have real try finally support. |
| 2719 ExpectedSnippet<int> snippets[] = { | 2641 ExpectedSnippet<int> snippets[] = { |
| 2720 {"var a = 1; try { a = 2; } finally { a = 3; }", | 2642 {"var a = 1; try { a = 2; } finally { a = 3; }", |
| 2721 1 * kPointerSize, | 2643 kPointerSize, |
| 2722 1, | 2644 1, |
| 2723 14, | 2645 14, |
| 2724 { | 2646 { |
| 2725 B(LdaSmi8), U8(1), // | 2647 B(LdaSmi8), U8(1), // |
| 2726 B(Star), R(0), // | 2648 B(Star), R(0), // |
| 2727 B(LdaSmi8), U8(2), // | 2649 B(LdaSmi8), U8(2), // |
| 2728 B(Star), R(0), // | 2650 B(Star), R(0), // |
| 2729 B(LdaSmi8), U8(3), // | 2651 B(LdaSmi8), U8(3), // |
| 2730 B(Star), R(0), // | 2652 B(Star), R(0), // |
| 2731 B(LdaUndefined), // | 2653 B(LdaUndefined), // |
| (...skipping 291 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3023 for (size_t i = 0; i < arraysize(snippets); i++) { | 2945 for (size_t i = 0; i < arraysize(snippets); i++) { |
| 3024 Handle<BytecodeArray> bytecode_array = | 2946 Handle<BytecodeArray> bytecode_array = |
| 3025 helper.MakeBytecodeForFunction(snippets[i].code_snippet); | 2947 helper.MakeBytecodeForFunction(snippets[i].code_snippet); |
| 3026 CheckBytecodeArrayEqual(snippets[i], bytecode_array); | 2948 CheckBytecodeArrayEqual(snippets[i], bytecode_array); |
| 3027 } | 2949 } |
| 3028 } | 2950 } |
| 3029 | 2951 |
| 3030 } // namespace interpreter | 2952 } // namespace interpreter |
| 3031 } // namespace internal | 2953 } // namespace internal |
| 3032 } // namespace v8 | 2954 } // namespace v8 |
| OLD | NEW |