| OLD | NEW |
| 1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
| 2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
| 3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
| 4 // met: | 4 // met: |
| 5 // | 5 // |
| 6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
| 7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
| 8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
| 9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
| 10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
| (...skipping 386 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 397 | 397 |
| 398 Operand LCodeGen::HighOperand(LOperand* op) { | 398 Operand LCodeGen::HighOperand(LOperand* op) { |
| 399 ASSERT(op->IsDoubleStackSlot()); | 399 ASSERT(op->IsDoubleStackSlot()); |
| 400 int index = op->index(); | 400 int index = op->index(); |
| 401 int offset = (index >= 0) ? index + 3 : index - 1; | 401 int offset = (index >= 0) ? index + 3 : index - 1; |
| 402 return Operand(ebp, -offset * kPointerSize); | 402 return Operand(ebp, -offset * kPointerSize); |
| 403 } | 403 } |
| 404 | 404 |
| 405 | 405 |
| 406 void LCodeGen::WriteTranslation(LEnvironment* environment, | 406 void LCodeGen::WriteTranslation(LEnvironment* environment, |
| 407 Translation* translation) { | 407 Translation* translation, |
| 408 int* args_index, |
| 409 int* args_count) { |
| 408 if (environment == NULL) return; | 410 if (environment == NULL) return; |
| 409 | 411 |
| 410 // The translation includes one command per value in the environment. | 412 // The translation includes one command per value in the environment. |
| 411 int translation_size = environment->values()->length(); | 413 int translation_size = environment->values()->length(); |
| 412 // The output frame height does not include the parameters. | 414 // The output frame height does not include the parameters. |
| 413 int height = translation_size - environment->parameter_count(); | 415 int height = translation_size - environment->parameter_count(); |
| 414 | 416 |
| 415 WriteTranslation(environment->outer(), translation); | 417 // Function parameters are arguments to the outermost environment. |
| 418 *args_index = -environment->parameter_count(); |
| 419 *args_count = environment->parameter_count(); |
| 420 |
| 421 WriteTranslation(environment->outer(), translation, args_index, args_count); |
| 416 int closure_id = *info()->closure() != *environment->closure() | 422 int closure_id = *info()->closure() != *environment->closure() |
| 417 ? DefineDeoptimizationLiteral(environment->closure()) | 423 ? DefineDeoptimizationLiteral(environment->closure()) |
| 418 : Translation::kSelfLiteralId; | 424 : Translation::kSelfLiteralId; |
| 419 switch (environment->frame_type()) { | 425 switch (environment->frame_type()) { |
| 420 case JS_FUNCTION: | 426 case JS_FUNCTION: |
| 421 translation->BeginJSFrame(environment->ast_id(), closure_id, height); | 427 translation->BeginJSFrame(environment->ast_id(), closure_id, height); |
| 422 break; | 428 break; |
| 423 case JS_CONSTRUCT: | 429 case JS_CONSTRUCT: |
| 424 translation->BeginConstructStubFrame(closure_id, translation_size); | 430 translation->BeginConstructStubFrame(closure_id, translation_size); |
| 425 break; | 431 break; |
| 426 case JS_GETTER: | 432 case JS_GETTER: |
| 427 ASSERT(translation_size == 1); | 433 ASSERT(translation_size == 1); |
| 428 ASSERT(height == 0); | 434 ASSERT(height == 0); |
| 429 translation->BeginGetterStubFrame(closure_id); | 435 translation->BeginGetterStubFrame(closure_id); |
| 430 break; | 436 break; |
| 431 case JS_SETTER: | 437 case JS_SETTER: |
| 432 ASSERT(translation_size == 2); | 438 ASSERT(translation_size == 2); |
| 433 ASSERT(height == 0); | 439 ASSERT(height == 0); |
| 434 translation->BeginSetterStubFrame(closure_id); | 440 translation->BeginSetterStubFrame(closure_id); |
| 435 break; | 441 break; |
| 436 case ARGUMENTS_ADAPTOR: | 442 case ARGUMENTS_ADAPTOR: |
| 437 translation->BeginArgumentsAdaptorFrame(closure_id, translation_size); | 443 translation->BeginArgumentsAdaptorFrame(closure_id, translation_size); |
| 438 break; | 444 break; |
| 439 } | 445 } |
| 446 |
| 447 // Inlined frames which push their arguments cause the index to be |
| 448 // bumped and a new stack area to be used for materialization. |
| 449 if (environment->entry() != NULL && |
| 450 environment->entry()->arguments_pushed()) { |
| 451 bool outermost = *args_index < 0; |
| 452 *args_index = outermost ? GetStackSlotCount() : *args_index + *args_count; |
| 453 *args_count = environment->entry()->arguments_count() + 1; |
| 454 } |
| 455 |
| 440 for (int i = 0; i < translation_size; ++i) { | 456 for (int i = 0; i < translation_size; ++i) { |
| 441 LOperand* value = environment->values()->at(i); | 457 LOperand* value = environment->values()->at(i); |
| 442 // spilled_registers_ and spilled_double_registers_ are either | 458 // spilled_registers_ and spilled_double_registers_ are either |
| 443 // both NULL or both set. | 459 // both NULL or both set. |
| 444 if (environment->spilled_registers() != NULL && value != NULL) { | 460 if (environment->spilled_registers() != NULL && value != NULL) { |
| 445 if (value->IsRegister() && | 461 if (value->IsRegister() && |
| 446 environment->spilled_registers()[value->index()] != NULL) { | 462 environment->spilled_registers()[value->index()] != NULL) { |
| 447 translation->MarkDuplicate(); | 463 translation->MarkDuplicate(); |
| 448 AddToTranslation(translation, | 464 AddToTranslation(translation, |
| 449 environment->spilled_registers()[value->index()], | 465 environment->spilled_registers()[value->index()], |
| 450 environment->HasTaggedValueAt(i), | 466 environment->HasTaggedValueAt(i), |
| 451 environment->HasUint32ValueAt(i)); | 467 environment->HasUint32ValueAt(i), |
| 468 *args_index, |
| 469 *args_count); |
| 452 } else if ( | 470 } else if ( |
| 453 value->IsDoubleRegister() && | 471 value->IsDoubleRegister() && |
| 454 environment->spilled_double_registers()[value->index()] != NULL) { | 472 environment->spilled_double_registers()[value->index()] != NULL) { |
| 455 translation->MarkDuplicate(); | 473 translation->MarkDuplicate(); |
| 456 AddToTranslation( | 474 AddToTranslation( |
| 457 translation, | 475 translation, |
| 458 environment->spilled_double_registers()[value->index()], | 476 environment->spilled_double_registers()[value->index()], |
| 459 false, | 477 false, |
| 460 false); | 478 false, |
| 479 *args_index, |
| 480 *args_count); |
| 461 } | 481 } |
| 462 } | 482 } |
| 463 | 483 |
| 464 AddToTranslation(translation, | 484 AddToTranslation(translation, |
| 465 value, | 485 value, |
| 466 environment->HasTaggedValueAt(i), | 486 environment->HasTaggedValueAt(i), |
| 467 environment->HasUint32ValueAt(i)); | 487 environment->HasUint32ValueAt(i), |
| 488 *args_index, |
| 489 *args_count); |
| 468 } | 490 } |
| 469 } | 491 } |
| 470 | 492 |
| 471 | 493 |
| 472 void LCodeGen::AddToTranslation(Translation* translation, | 494 void LCodeGen::AddToTranslation(Translation* translation, |
| 473 LOperand* op, | 495 LOperand* op, |
| 474 bool is_tagged, | 496 bool is_tagged, |
| 475 bool is_uint32) { | 497 bool is_uint32, |
| 498 int arguments_index, |
| 499 int arguments_count) { |
| 476 if (op == NULL) { | 500 if (op == NULL) { |
| 477 // TODO(twuerthinger): Introduce marker operands to indicate that this value | 501 // TODO(twuerthinger): Introduce marker operands to indicate that this value |
| 478 // is not present and must be reconstructed from the deoptimizer. Currently | 502 // is not present and must be reconstructed from the deoptimizer. Currently |
| 479 // this is only used for the arguments object. | 503 // this is only used for the arguments object. |
| 480 translation->StoreArgumentsObject(); | 504 translation->StoreArgumentsObject(arguments_index, arguments_count); |
| 481 } else if (op->IsStackSlot()) { | 505 } else if (op->IsStackSlot()) { |
| 482 if (is_tagged) { | 506 if (is_tagged) { |
| 483 translation->StoreStackSlot(op->index()); | 507 translation->StoreStackSlot(op->index()); |
| 484 } else if (is_uint32) { | 508 } else if (is_uint32) { |
| 485 translation->StoreUint32StackSlot(op->index()); | 509 translation->StoreUint32StackSlot(op->index()); |
| 486 } else { | 510 } else { |
| 487 translation->StoreInt32StackSlot(op->index()); | 511 translation->StoreInt32StackSlot(op->index()); |
| 488 } | 512 } |
| 489 } else if (op->IsDoubleStackSlot()) { | 513 } else if (op->IsDoubleStackSlot()) { |
| 490 translation->StoreDoubleStackSlot(op->index()); | 514 translation->StoreDoubleStackSlot(op->index()); |
| (...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 589 // 0 ..................................................... size-1 | 613 // 0 ..................................................... size-1 |
| 590 // [parameters] [locals] [expression stack including arguments] | 614 // [parameters] [locals] [expression stack including arguments] |
| 591 | 615 |
| 592 // Layout of the translation: | 616 // Layout of the translation: |
| 593 // 0 ........................................................ size - 1 + 4 | 617 // 0 ........................................................ size - 1 + 4 |
| 594 // [expression stack including arguments] [locals] [4 words] [parameters] | 618 // [expression stack including arguments] [locals] [4 words] [parameters] |
| 595 // |>------------ translation_size ------------<| | 619 // |>------------ translation_size ------------<| |
| 596 | 620 |
| 597 int frame_count = 0; | 621 int frame_count = 0; |
| 598 int jsframe_count = 0; | 622 int jsframe_count = 0; |
| 623 int args_index = 0; |
| 624 int args_count = 0; |
| 599 for (LEnvironment* e = environment; e != NULL; e = e->outer()) { | 625 for (LEnvironment* e = environment; e != NULL; e = e->outer()) { |
| 600 ++frame_count; | 626 ++frame_count; |
| 601 if (e->frame_type() == JS_FUNCTION) { | 627 if (e->frame_type() == JS_FUNCTION) { |
| 602 ++jsframe_count; | 628 ++jsframe_count; |
| 603 } | 629 } |
| 604 } | 630 } |
| 605 Translation translation(&translations_, frame_count, jsframe_count, | 631 Translation translation(&translations_, frame_count, jsframe_count, zone()); |
| 606 zone()); | 632 WriteTranslation(environment, &translation, &args_index, &args_count); |
| 607 WriteTranslation(environment, &translation); | |
| 608 int deoptimization_index = deoptimizations_.length(); | 633 int deoptimization_index = deoptimizations_.length(); |
| 609 int pc_offset = masm()->pc_offset(); | 634 int pc_offset = masm()->pc_offset(); |
| 610 environment->Register(deoptimization_index, | 635 environment->Register(deoptimization_index, |
| 611 translation.index(), | 636 translation.index(), |
| 612 (mode == Safepoint::kLazyDeopt) ? pc_offset : -1); | 637 (mode == Safepoint::kLazyDeopt) ? pc_offset : -1); |
| 613 deoptimizations_.Add(environment, zone()); | 638 deoptimizations_.Add(environment, zone()); |
| 614 } | 639 } |
| 615 } | 640 } |
| 616 | 641 |
| 617 | 642 |
| (...skipping 4895 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5513 FixedArray::kHeaderSize - kPointerSize)); | 5538 FixedArray::kHeaderSize - kPointerSize)); |
| 5514 __ bind(&done); | 5539 __ bind(&done); |
| 5515 } | 5540 } |
| 5516 | 5541 |
| 5517 | 5542 |
| 5518 #undef __ | 5543 #undef __ |
| 5519 | 5544 |
| 5520 } } // namespace v8::internal | 5545 } } // namespace v8::internal |
| 5521 | 5546 |
| 5522 #endif // V8_TARGET_ARCH_IA32 | 5547 #endif // V8_TARGET_ARCH_IA32 |
| OLD | NEW |