Chromium Code Reviews| 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 204 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 215 __ push(rdi); | 215 __ push(rdi); |
| 216 } else { | 216 } else { |
| 217 __ push(Operand(rbp, JavaScriptFrameConstants::kFunctionOffset)); | 217 __ push(Operand(rbp, JavaScriptFrameConstants::kFunctionOffset)); |
| 218 } | 218 } |
| 219 // The receiver is just before the parameters on the caller's stack. | 219 // The receiver is just before the parameters on the caller's stack. |
| 220 int num_parameters = info->scope()->num_parameters(); | 220 int num_parameters = info->scope()->num_parameters(); |
| 221 int offset = num_parameters * kPointerSize; | 221 int offset = num_parameters * kPointerSize; |
| 222 __ lea(rdx, | 222 __ lea(rdx, |
| 223 Operand(rbp, StandardFrameConstants::kCallerSPOffset + offset)); | 223 Operand(rbp, StandardFrameConstants::kCallerSPOffset + offset)); |
| 224 __ push(rdx); | 224 __ push(rdx); |
| 225 __ Push(Smi::FromInt(num_parameters)); | 225 __ SafePush(Smi::FromInt(num_parameters)); |
| 226 // Arguments to ArgumentsAccessStub: | 226 // Arguments to ArgumentsAccessStub: |
| 227 // function, receiver address, parameter count. | 227 // function, receiver address, parameter count. |
| 228 // The stub will rewrite receiver and parameter count if the previous | 228 // The stub will rewrite receiver and parameter count if the previous |
| 229 // stack frame was an arguments adapter frame. | 229 // stack frame was an arguments adapter frame. |
| 230 ArgumentsAccessStub::Type type; | 230 ArgumentsAccessStub::Type type; |
| 231 if (!is_classic_mode()) { | 231 if (!is_classic_mode()) { |
| 232 type = ArgumentsAccessStub::NEW_STRICT; | 232 type = ArgumentsAccessStub::NEW_STRICT; |
| 233 } else if (function()->has_duplicate_parameters()) { | 233 } else if (function()->has_duplicate_parameters()) { |
| 234 type = ArgumentsAccessStub::NEW_NON_STRICT_SLOW; | 234 type = ArgumentsAccessStub::NEW_NON_STRICT_SLOW; |
| 235 } else { | 235 } else { |
| (...skipping 261 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 497 } | 497 } |
| 498 } | 498 } |
| 499 | 499 |
| 500 | 500 |
| 501 void FullCodeGenerator::EffectContext::Plug(Handle<Object> lit) const { | 501 void FullCodeGenerator::EffectContext::Plug(Handle<Object> lit) const { |
| 502 } | 502 } |
| 503 | 503 |
| 504 | 504 |
| 505 void FullCodeGenerator::AccumulatorValueContext::Plug( | 505 void FullCodeGenerator::AccumulatorValueContext::Plug( |
| 506 Handle<Object> lit) const { | 506 Handle<Object> lit) const { |
| 507 __ Move(result_register(), lit); | 507 if (lit->IsSmi()) { |
| 508 __ SafeMove(result_register(), Smi::cast(*lit)); | |
| 509 } else { | |
| 510 __ Move(result_register(), lit); | |
| 511 } | |
| 508 } | 512 } |
| 509 | 513 |
| 510 | 514 |
| 511 void FullCodeGenerator::StackValueContext::Plug(Handle<Object> lit) const { | 515 void FullCodeGenerator::StackValueContext::Plug(Handle<Object> lit) const { |
| 512 __ Push(lit); | 516 if (lit->IsSmi()) { |
| 517 __ SafePush(Smi::cast(*lit)); | |
| 518 } else { | |
| 519 __ Push(lit); | |
| 520 } | |
| 513 } | 521 } |
| 514 | 522 |
| 515 | 523 |
| 516 void FullCodeGenerator::TestContext::Plug(Handle<Object> lit) const { | 524 void FullCodeGenerator::TestContext::Plug(Handle<Object> lit) const { |
| 517 codegen()->PrepareForBailoutBeforeSplit(condition(), | 525 codegen()->PrepareForBailoutBeforeSplit(condition(), |
| 518 true, | 526 true, |
| 519 true_label_, | 527 true_label_, |
| 520 false_label_); | 528 false_label_); |
| 521 ASSERT(!lit->IsUndetectableObject()); // There are no undetectable literals. | 529 ASSERT(!lit->IsUndetectableObject()); // There are no undetectable literals. |
| 522 if (lit->IsUndefined() || lit->IsNull() || lit->IsFalse()) { | 530 if (lit->IsUndefined() || lit->IsNull() || lit->IsFalse()) { |
| (...skipping 1925 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2448 int arg_count = args->length(); | 2456 int arg_count = args->length(); |
| 2449 for (int i = 0; i < arg_count; i++) { | 2457 for (int i = 0; i < arg_count; i++) { |
| 2450 VisitForStackValue(args->at(i)); | 2458 VisitForStackValue(args->at(i)); |
| 2451 } | 2459 } |
| 2452 | 2460 |
| 2453 // Call the construct call builtin that handles allocation and | 2461 // Call the construct call builtin that handles allocation and |
| 2454 // constructor invocation. | 2462 // constructor invocation. |
| 2455 SetSourcePosition(expr->position()); | 2463 SetSourcePosition(expr->position()); |
| 2456 | 2464 |
| 2457 // Load function and argument count into rdi and rax. | 2465 // Load function and argument count into rdi and rax. |
| 2458 __ Set(rax, arg_count); | 2466 __ SafeSet(rax, arg_count); |
| 2459 __ movq(rdi, Operand(rsp, arg_count * kPointerSize)); | 2467 __ movq(rdi, Operand(rsp, arg_count * kPointerSize)); |
| 2460 | 2468 |
| 2461 // Record call targets in unoptimized code, but not in the snapshot. | 2469 // Record call targets in unoptimized code, but not in the snapshot. |
| 2462 CallFunctionFlags flags; | 2470 CallFunctionFlags flags; |
| 2463 if (!Serializer::enabled()) { | 2471 if (!Serializer::enabled()) { |
| 2464 flags = RECORD_CALL_TARGET; | 2472 flags = RECORD_CALL_TARGET; |
| 2465 Handle<Object> uninitialized = | 2473 Handle<Object> uninitialized = |
| 2466 TypeFeedbackCells::UninitializedSentinel(isolate()); | 2474 TypeFeedbackCells::UninitializedSentinel(isolate()); |
| 2467 Handle<JSGlobalPropertyCell> cell = | 2475 Handle<JSGlobalPropertyCell> cell = |
| 2468 isolate()->factory()->NewJSGlobalPropertyCell(uninitialized); | 2476 isolate()->factory()->NewJSGlobalPropertyCell(uninitialized); |
| (...skipping 336 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2805 | 2813 |
| 2806 | 2814 |
| 2807 void FullCodeGenerator::EmitArguments(CallRuntime* expr) { | 2815 void FullCodeGenerator::EmitArguments(CallRuntime* expr) { |
| 2808 ZoneList<Expression*>* args = expr->arguments(); | 2816 ZoneList<Expression*>* args = expr->arguments(); |
| 2809 ASSERT(args->length() == 1); | 2817 ASSERT(args->length() == 1); |
| 2810 | 2818 |
| 2811 // ArgumentsAccessStub expects the key in rdx and the formal | 2819 // ArgumentsAccessStub expects the key in rdx and the formal |
| 2812 // parameter count in rax. | 2820 // parameter count in rax. |
| 2813 VisitForAccumulatorValue(args->at(0)); | 2821 VisitForAccumulatorValue(args->at(0)); |
| 2814 __ movq(rdx, rax); | 2822 __ movq(rdx, rax); |
| 2815 __ Move(rax, Smi::FromInt(info_->scope()->num_parameters())); | 2823 __ SafeMove(rax, Smi::FromInt(info_->scope()->num_parameters())); |
|
Erik Corry
2012/06/26 12:26:40
Can this ever make a difference when kMaxNumFuncti
| |
| 2816 ArgumentsAccessStub stub(ArgumentsAccessStub::READ_ELEMENT); | 2824 ArgumentsAccessStub stub(ArgumentsAccessStub::READ_ELEMENT); |
| 2817 __ CallStub(&stub); | 2825 __ CallStub(&stub); |
| 2818 context()->Plug(rax); | 2826 context()->Plug(rax); |
| 2819 } | 2827 } |
| 2820 | 2828 |
| 2821 | 2829 |
| 2822 void FullCodeGenerator::EmitArgumentsLength(CallRuntime* expr) { | 2830 void FullCodeGenerator::EmitArgumentsLength(CallRuntime* expr) { |
| 2823 ASSERT(expr->arguments()->length() == 0); | 2831 ASSERT(expr->arguments()->length() == 0); |
| 2824 | 2832 |
| 2825 Label exit; | 2833 Label exit; |
| 2826 // Get the number of formal parameters. | 2834 // Get the number of formal parameters. |
| 2827 __ Move(rax, Smi::FromInt(info_->scope()->num_parameters())); | 2835 __ SafeMove(rax, Smi::FromInt(info_->scope()->num_parameters())); |
| 2828 | 2836 |
| 2829 // Check if the calling frame is an arguments adaptor frame. | 2837 // Check if the calling frame is an arguments adaptor frame. |
| 2830 __ movq(rbx, Operand(rbp, StandardFrameConstants::kCallerFPOffset)); | 2838 __ movq(rbx, Operand(rbp, StandardFrameConstants::kCallerFPOffset)); |
| 2831 __ Cmp(Operand(rbx, StandardFrameConstants::kContextOffset), | 2839 __ Cmp(Operand(rbx, StandardFrameConstants::kContextOffset), |
| 2832 Smi::FromInt(StackFrame::ARGUMENTS_ADAPTOR)); | 2840 Smi::FromInt(StackFrame::ARGUMENTS_ADAPTOR)); |
| 2833 __ j(not_equal, &exit, Label::kNear); | 2841 __ j(not_equal, &exit, Label::kNear); |
| 2834 | 2842 |
| 2835 // Arguments adaptor case: Read the arguments length from the | 2843 // Arguments adaptor case: Read the arguments length from the |
| 2836 // adaptor frame. | 2844 // adaptor frame. |
| 2837 __ movq(rax, Operand(rbx, ArgumentsAdaptorFrameConstants::kLengthOffset)); | 2845 __ movq(rax, Operand(rbx, ArgumentsAdaptorFrameConstants::kLengthOffset)); |
| (...skipping 1697 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 4535 *context_length = 0; | 4543 *context_length = 0; |
| 4536 return previous_; | 4544 return previous_; |
| 4537 } | 4545 } |
| 4538 | 4546 |
| 4539 | 4547 |
| 4540 #undef __ | 4548 #undef __ |
| 4541 | 4549 |
| 4542 } } // namespace v8::internal | 4550 } } // namespace v8::internal |
| 4543 | 4551 |
| 4544 #endif // V8_TARGET_ARCH_X64 | 4552 #endif // V8_TARGET_ARCH_X64 |
| OLD | NEW |