| 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 333 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 344 // context in the fixed part of the frame. | 344 // context in the fixed part of the frame. |
| 345 return Operand(rbp, -(index + 3) * kPointerSize); | 345 return Operand(rbp, -(index + 3) * kPointerSize); |
| 346 } else { | 346 } else { |
| 347 // Incoming parameter. Skip the return address. | 347 // Incoming parameter. Skip the return address. |
| 348 return Operand(rbp, -(index - 1) * kPointerSize); | 348 return Operand(rbp, -(index - 1) * kPointerSize); |
| 349 } | 349 } |
| 350 } | 350 } |
| 351 | 351 |
| 352 | 352 |
| 353 void LCodeGen::WriteTranslation(LEnvironment* environment, | 353 void LCodeGen::WriteTranslation(LEnvironment* environment, |
| 354 Translation* translation) { | 354 Translation* translation, |
| 355 int* args_index, |
| 356 int* args_count) { |
| 355 if (environment == NULL) return; | 357 if (environment == NULL) return; |
| 356 | 358 |
| 357 // The translation includes one command per value in the environment. | 359 // The translation includes one command per value in the environment. |
| 358 int translation_size = environment->values()->length(); | 360 int translation_size = environment->values()->length(); |
| 359 // The output frame height does not include the parameters. | 361 // The output frame height does not include the parameters. |
| 360 int height = translation_size - environment->parameter_count(); | 362 int height = translation_size - environment->parameter_count(); |
| 361 | 363 |
| 362 WriteTranslation(environment->outer(), translation); | 364 // Function parameters are arguments to the outermost environment. |
| 365 *args_index = -environment->parameter_count(); |
| 366 *args_count = environment->parameter_count(); |
| 367 |
| 368 WriteTranslation(environment->outer(), translation, args_index, args_count); |
| 363 int closure_id = *info()->closure() != *environment->closure() | 369 int closure_id = *info()->closure() != *environment->closure() |
| 364 ? DefineDeoptimizationLiteral(environment->closure()) | 370 ? DefineDeoptimizationLiteral(environment->closure()) |
| 365 : Translation::kSelfLiteralId; | 371 : Translation::kSelfLiteralId; |
| 366 | 372 |
| 367 switch (environment->frame_type()) { | 373 switch (environment->frame_type()) { |
| 368 case JS_FUNCTION: | 374 case JS_FUNCTION: |
| 369 translation->BeginJSFrame(environment->ast_id(), closure_id, height); | 375 translation->BeginJSFrame(environment->ast_id(), closure_id, height); |
| 370 break; | 376 break; |
| 371 case JS_CONSTRUCT: | 377 case JS_CONSTRUCT: |
| 372 translation->BeginConstructStubFrame(closure_id, translation_size); | 378 translation->BeginConstructStubFrame(closure_id, translation_size); |
| 373 break; | 379 break; |
| 374 case JS_GETTER: | 380 case JS_GETTER: |
| 375 ASSERT(translation_size == 1); | 381 ASSERT(translation_size == 1); |
| 376 ASSERT(height == 0); | 382 ASSERT(height == 0); |
| 377 translation->BeginGetterStubFrame(closure_id); | 383 translation->BeginGetterStubFrame(closure_id); |
| 378 break; | 384 break; |
| 379 case JS_SETTER: | 385 case JS_SETTER: |
| 380 ASSERT(translation_size == 2); | 386 ASSERT(translation_size == 2); |
| 381 ASSERT(height == 0); | 387 ASSERT(height == 0); |
| 382 translation->BeginSetterStubFrame(closure_id); | 388 translation->BeginSetterStubFrame(closure_id); |
| 383 break; | 389 break; |
| 384 case ARGUMENTS_ADAPTOR: | 390 case ARGUMENTS_ADAPTOR: |
| 385 translation->BeginArgumentsAdaptorFrame(closure_id, translation_size); | 391 translation->BeginArgumentsAdaptorFrame(closure_id, translation_size); |
| 386 break; | 392 break; |
| 387 } | 393 } |
| 394 |
| 395 // Inlined frames which push their arguments cause the index to be |
| 396 // bumped and a new stack area to be used for materialization. |
| 397 if (environment->entry() != NULL && |
| 398 environment->entry()->arguments_pushed()) { |
| 399 bool outermost = *args_index < 0; |
| 400 *args_index = outermost ? GetStackSlotCount() : *args_index + *args_count; |
| 401 *args_count = environment->entry()->arguments_count() + 1; |
| 402 } |
| 403 |
| 388 for (int i = 0; i < translation_size; ++i) { | 404 for (int i = 0; i < translation_size; ++i) { |
| 389 LOperand* value = environment->values()->at(i); | 405 LOperand* value = environment->values()->at(i); |
| 390 // spilled_registers_ and spilled_double_registers_ are either | 406 // spilled_registers_ and spilled_double_registers_ are either |
| 391 // both NULL or both set. | 407 // both NULL or both set. |
| 392 if (environment->spilled_registers() != NULL && value != NULL) { | 408 if (environment->spilled_registers() != NULL && value != NULL) { |
| 393 if (value->IsRegister() && | 409 if (value->IsRegister() && |
| 394 environment->spilled_registers()[value->index()] != NULL) { | 410 environment->spilled_registers()[value->index()] != NULL) { |
| 395 translation->MarkDuplicate(); | 411 translation->MarkDuplicate(); |
| 396 AddToTranslation(translation, | 412 AddToTranslation(translation, |
| 397 environment->spilled_registers()[value->index()], | 413 environment->spilled_registers()[value->index()], |
| 398 environment->HasTaggedValueAt(i), | 414 environment->HasTaggedValueAt(i), |
| 399 environment->HasUint32ValueAt(i)); | 415 environment->HasUint32ValueAt(i), |
| 416 *args_index, |
| 417 *args_count); |
| 400 } else if ( | 418 } else if ( |
| 401 value->IsDoubleRegister() && | 419 value->IsDoubleRegister() && |
| 402 environment->spilled_double_registers()[value->index()] != NULL) { | 420 environment->spilled_double_registers()[value->index()] != NULL) { |
| 403 translation->MarkDuplicate(); | 421 translation->MarkDuplicate(); |
| 404 AddToTranslation( | 422 AddToTranslation( |
| 405 translation, | 423 translation, |
| 406 environment->spilled_double_registers()[value->index()], | 424 environment->spilled_double_registers()[value->index()], |
| 407 false, | 425 false, |
| 408 false); | 426 false, |
| 427 *args_index, |
| 428 *args_count); |
| 409 } | 429 } |
| 410 } | 430 } |
| 411 | 431 |
| 412 AddToTranslation(translation, | 432 AddToTranslation(translation, |
| 413 value, | 433 value, |
| 414 environment->HasTaggedValueAt(i), | 434 environment->HasTaggedValueAt(i), |
| 415 environment->HasUint32ValueAt(i)); | 435 environment->HasUint32ValueAt(i), |
| 436 *args_index, |
| 437 *args_count); |
| 416 } | 438 } |
| 417 } | 439 } |
| 418 | 440 |
| 419 | 441 |
| 420 void LCodeGen::AddToTranslation(Translation* translation, | 442 void LCodeGen::AddToTranslation(Translation* translation, |
| 421 LOperand* op, | 443 LOperand* op, |
| 422 bool is_tagged, | 444 bool is_tagged, |
| 423 bool is_uint32) { | 445 bool is_uint32, |
| 446 int arguments_index, |
| 447 int arguments_count) { |
| 424 if (op == NULL) { | 448 if (op == NULL) { |
| 425 // TODO(twuerthinger): Introduce marker operands to indicate that this value | 449 // TODO(twuerthinger): Introduce marker operands to indicate that this value |
| 426 // is not present and must be reconstructed from the deoptimizer. Currently | 450 // is not present and must be reconstructed from the deoptimizer. Currently |
| 427 // this is only used for the arguments object. | 451 // this is only used for the arguments object. |
| 428 translation->StoreArgumentsObject(); | 452 translation->StoreArgumentsObject(arguments_index, arguments_count); |
| 429 } else if (op->IsStackSlot()) { | 453 } else if (op->IsStackSlot()) { |
| 430 if (is_tagged) { | 454 if (is_tagged) { |
| 431 translation->StoreStackSlot(op->index()); | 455 translation->StoreStackSlot(op->index()); |
| 432 } else if (is_uint32) { | 456 } else if (is_uint32) { |
| 433 translation->StoreUint32StackSlot(op->index()); | 457 translation->StoreUint32StackSlot(op->index()); |
| 434 } else { | 458 } else { |
| 435 translation->StoreInt32StackSlot(op->index()); | 459 translation->StoreInt32StackSlot(op->index()); |
| 436 } | 460 } |
| 437 } else if (op->IsDoubleStackSlot()) { | 461 } else if (op->IsDoubleStackSlot()) { |
| 438 translation->StoreDoubleStackSlot(op->index()); | 462 translation->StoreDoubleStackSlot(op->index()); |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 524 // 0 ..................................................... size-1 | 548 // 0 ..................................................... size-1 |
| 525 // [parameters] [locals] [expression stack including arguments] | 549 // [parameters] [locals] [expression stack including arguments] |
| 526 | 550 |
| 527 // Layout of the translation: | 551 // Layout of the translation: |
| 528 // 0 ........................................................ size - 1 + 4 | 552 // 0 ........................................................ size - 1 + 4 |
| 529 // [expression stack including arguments] [locals] [4 words] [parameters] | 553 // [expression stack including arguments] [locals] [4 words] [parameters] |
| 530 // |>------------ translation_size ------------<| | 554 // |>------------ translation_size ------------<| |
| 531 | 555 |
| 532 int frame_count = 0; | 556 int frame_count = 0; |
| 533 int jsframe_count = 0; | 557 int jsframe_count = 0; |
| 558 int args_index = 0; |
| 559 int args_count = 0; |
| 534 for (LEnvironment* e = environment; e != NULL; e = e->outer()) { | 560 for (LEnvironment* e = environment; e != NULL; e = e->outer()) { |
| 535 ++frame_count; | 561 ++frame_count; |
| 536 if (e->frame_type() == JS_FUNCTION) { | 562 if (e->frame_type() == JS_FUNCTION) { |
| 537 ++jsframe_count; | 563 ++jsframe_count; |
| 538 } | 564 } |
| 539 } | 565 } |
| 540 Translation translation(&translations_, frame_count, jsframe_count, | 566 Translation translation(&translations_, frame_count, jsframe_count, zone()); |
| 541 environment->zone()); | 567 WriteTranslation(environment, &translation, &args_index, &args_count); |
| 542 WriteTranslation(environment, &translation); | |
| 543 int deoptimization_index = deoptimizations_.length(); | 568 int deoptimization_index = deoptimizations_.length(); |
| 544 int pc_offset = masm()->pc_offset(); | 569 int pc_offset = masm()->pc_offset(); |
| 545 environment->Register(deoptimization_index, | 570 environment->Register(deoptimization_index, |
| 546 translation.index(), | 571 translation.index(), |
| 547 (mode == Safepoint::kLazyDeopt) ? pc_offset : -1); | 572 (mode == Safepoint::kLazyDeopt) ? pc_offset : -1); |
| 548 deoptimizations_.Add(environment, environment->zone()); | 573 deoptimizations_.Add(environment, environment->zone()); |
| 549 } | 574 } |
| 550 } | 575 } |
| 551 | 576 |
| 552 | 577 |
| (...skipping 4728 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5281 FixedArray::kHeaderSize - kPointerSize)); | 5306 FixedArray::kHeaderSize - kPointerSize)); |
| 5282 __ bind(&done); | 5307 __ bind(&done); |
| 5283 } | 5308 } |
| 5284 | 5309 |
| 5285 | 5310 |
| 5286 #undef __ | 5311 #undef __ |
| 5287 | 5312 |
| 5288 } } // namespace v8::internal | 5313 } } // namespace v8::internal |
| 5289 | 5314 |
| 5290 #endif // V8_TARGET_ARCH_X64 | 5315 #endif // V8_TARGET_ARCH_X64 |
| OLD | NEW |