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