Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(677)

Side by Side Diff: src/ia32/lithium-codegen-ia32.cc

Issue 10908194: Fix arguments object materialization during deopt. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Improved test coverage and fixed bug. Created 8 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/ia32/lithium-codegen-ia32.h ('k') | src/ia32/lithium-ia32.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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* arguments_index,
409 int* arguments_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. The
418 // arguments index points to the first element of a sequence of tagged
419 // values on the stack that represent the arguments. This needs to be
420 // kept in sync with the LArgumentsElements implementation.
421 *arguments_index = -environment->parameter_count();
422 *arguments_count = environment->parameter_count();
423
424 WriteTranslation(environment->outer(),
425 translation,
426 arguments_index,
427 arguments_count);
416 int closure_id = *info()->closure() != *environment->closure() 428 int closure_id = *info()->closure() != *environment->closure()
417 ? DefineDeoptimizationLiteral(environment->closure()) 429 ? DefineDeoptimizationLiteral(environment->closure())
418 : Translation::kSelfLiteralId; 430 : Translation::kSelfLiteralId;
419 switch (environment->frame_type()) { 431 switch (environment->frame_type()) {
420 case JS_FUNCTION: 432 case JS_FUNCTION:
421 translation->BeginJSFrame(environment->ast_id(), closure_id, height); 433 translation->BeginJSFrame(environment->ast_id(), closure_id, height);
422 break; 434 break;
423 case JS_CONSTRUCT: 435 case JS_CONSTRUCT:
424 translation->BeginConstructStubFrame(closure_id, translation_size); 436 translation->BeginConstructStubFrame(closure_id, translation_size);
425 break; 437 break;
426 case JS_GETTER: 438 case JS_GETTER:
427 ASSERT(translation_size == 1); 439 ASSERT(translation_size == 1);
428 ASSERT(height == 0); 440 ASSERT(height == 0);
429 translation->BeginGetterStubFrame(closure_id); 441 translation->BeginGetterStubFrame(closure_id);
430 break; 442 break;
431 case JS_SETTER: 443 case JS_SETTER:
432 ASSERT(translation_size == 2); 444 ASSERT(translation_size == 2);
433 ASSERT(height == 0); 445 ASSERT(height == 0);
434 translation->BeginSetterStubFrame(closure_id); 446 translation->BeginSetterStubFrame(closure_id);
435 break; 447 break;
436 case ARGUMENTS_ADAPTOR: 448 case ARGUMENTS_ADAPTOR:
437 translation->BeginArgumentsAdaptorFrame(closure_id, translation_size); 449 translation->BeginArgumentsAdaptorFrame(closure_id, translation_size);
438 break; 450 break;
439 } 451 }
452
453 // Inlined frames which push their arguments cause the index to be
454 // bumped and another stack area to be used for materialization.
455 if (environment->entry() != NULL &&
456 environment->entry()->arguments_pushed()) {
457 *arguments_index = *arguments_index < 0
458 ? GetStackSlotCount()
459 : *arguments_index + *arguments_count;
460 *arguments_count = environment->entry()->arguments_count() + 1;
461 }
462
440 for (int i = 0; i < translation_size; ++i) { 463 for (int i = 0; i < translation_size; ++i) {
441 LOperand* value = environment->values()->at(i); 464 LOperand* value = environment->values()->at(i);
442 // spilled_registers_ and spilled_double_registers_ are either 465 // spilled_registers_ and spilled_double_registers_ are either
443 // both NULL or both set. 466 // both NULL or both set.
444 if (environment->spilled_registers() != NULL && value != NULL) { 467 if (environment->spilled_registers() != NULL && value != NULL) {
445 if (value->IsRegister() && 468 if (value->IsRegister() &&
446 environment->spilled_registers()[value->index()] != NULL) { 469 environment->spilled_registers()[value->index()] != NULL) {
447 translation->MarkDuplicate(); 470 translation->MarkDuplicate();
448 AddToTranslation(translation, 471 AddToTranslation(translation,
449 environment->spilled_registers()[value->index()], 472 environment->spilled_registers()[value->index()],
450 environment->HasTaggedValueAt(i), 473 environment->HasTaggedValueAt(i),
451 environment->HasUint32ValueAt(i)); 474 environment->HasUint32ValueAt(i),
475 *arguments_index,
476 *arguments_count);
452 } else if ( 477 } else if (
453 value->IsDoubleRegister() && 478 value->IsDoubleRegister() &&
454 environment->spilled_double_registers()[value->index()] != NULL) { 479 environment->spilled_double_registers()[value->index()] != NULL) {
455 translation->MarkDuplicate(); 480 translation->MarkDuplicate();
456 AddToTranslation( 481 AddToTranslation(
457 translation, 482 translation,
458 environment->spilled_double_registers()[value->index()], 483 environment->spilled_double_registers()[value->index()],
459 false, 484 false,
460 false); 485 false,
486 *arguments_index,
487 *arguments_count);
461 } 488 }
462 } 489 }
463 490
464 AddToTranslation(translation, 491 AddToTranslation(translation,
465 value, 492 value,
466 environment->HasTaggedValueAt(i), 493 environment->HasTaggedValueAt(i),
467 environment->HasUint32ValueAt(i)); 494 environment->HasUint32ValueAt(i),
495 *arguments_index,
496 *arguments_count);
468 } 497 }
469 } 498 }
470 499
471 500
472 void LCodeGen::AddToTranslation(Translation* translation, 501 void LCodeGen::AddToTranslation(Translation* translation,
473 LOperand* op, 502 LOperand* op,
474 bool is_tagged, 503 bool is_tagged,
475 bool is_uint32) { 504 bool is_uint32,
505 int arguments_index,
506 int arguments_count) {
476 if (op == NULL) { 507 if (op == NULL) {
477 // TODO(twuerthinger): Introduce marker operands to indicate that this value 508 // TODO(twuerthinger): Introduce marker operands to indicate that this value
478 // is not present and must be reconstructed from the deoptimizer. Currently 509 // is not present and must be reconstructed from the deoptimizer. Currently
479 // this is only used for the arguments object. 510 // this is only used for the arguments object.
480 translation->StoreArgumentsObject(); 511 translation->StoreArgumentsObject(arguments_index, arguments_count);
481 } else if (op->IsStackSlot()) { 512 } else if (op->IsStackSlot()) {
482 if (is_tagged) { 513 if (is_tagged) {
483 translation->StoreStackSlot(op->index()); 514 translation->StoreStackSlot(op->index());
484 } else if (is_uint32) { 515 } else if (is_uint32) {
485 translation->StoreUint32StackSlot(op->index()); 516 translation->StoreUint32StackSlot(op->index());
486 } else { 517 } else {
487 translation->StoreInt32StackSlot(op->index()); 518 translation->StoreInt32StackSlot(op->index());
488 } 519 }
489 } else if (op->IsDoubleStackSlot()) { 520 } else if (op->IsDoubleStackSlot()) {
490 translation->StoreDoubleStackSlot(op->index()); 521 translation->StoreDoubleStackSlot(op->index());
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
589 // 0 ..................................................... size-1 620 // 0 ..................................................... size-1
590 // [parameters] [locals] [expression stack including arguments] 621 // [parameters] [locals] [expression stack including arguments]
591 622
592 // Layout of the translation: 623 // Layout of the translation:
593 // 0 ........................................................ size - 1 + 4 624 // 0 ........................................................ size - 1 + 4
594 // [expression stack including arguments] [locals] [4 words] [parameters] 625 // [expression stack including arguments] [locals] [4 words] [parameters]
595 // |>------------ translation_size ------------<| 626 // |>------------ translation_size ------------<|
596 627
597 int frame_count = 0; 628 int frame_count = 0;
598 int jsframe_count = 0; 629 int jsframe_count = 0;
630 int args_index = 0;
631 int args_count = 0;
599 for (LEnvironment* e = environment; e != NULL; e = e->outer()) { 632 for (LEnvironment* e = environment; e != NULL; e = e->outer()) {
600 ++frame_count; 633 ++frame_count;
601 if (e->frame_type() == JS_FUNCTION) { 634 if (e->frame_type() == JS_FUNCTION) {
602 ++jsframe_count; 635 ++jsframe_count;
603 } 636 }
604 } 637 }
605 Translation translation(&translations_, frame_count, jsframe_count, 638 Translation translation(&translations_, frame_count, jsframe_count, zone());
606 zone()); 639 WriteTranslation(environment, &translation, &args_index, &args_count);
607 WriteTranslation(environment, &translation);
608 int deoptimization_index = deoptimizations_.length(); 640 int deoptimization_index = deoptimizations_.length();
609 int pc_offset = masm()->pc_offset(); 641 int pc_offset = masm()->pc_offset();
610 environment->Register(deoptimization_index, 642 environment->Register(deoptimization_index,
611 translation.index(), 643 translation.index(),
612 (mode == Safepoint::kLazyDeopt) ? pc_offset : -1); 644 (mode == Safepoint::kLazyDeopt) ? pc_offset : -1);
613 deoptimizations_.Add(environment, zone()); 645 deoptimizations_.Add(environment, zone());
614 } 646 }
615 } 647 }
616 648
617 649
(...skipping 4895 matching lines...) Expand 10 before | Expand all | Expand 10 after
5513 FixedArray::kHeaderSize - kPointerSize)); 5545 FixedArray::kHeaderSize - kPointerSize));
5514 __ bind(&done); 5546 __ bind(&done);
5515 } 5547 }
5516 5548
5517 5549
5518 #undef __ 5550 #undef __
5519 5551
5520 } } // namespace v8::internal 5552 } } // namespace v8::internal
5521 5553
5522 #endif // V8_TARGET_ARCH_IA32 5554 #endif // V8_TARGET_ARCH_IA32
OLDNEW
« no previous file with comments | « src/ia32/lithium-codegen-ia32.h ('k') | src/ia32/lithium-ia32.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698