| OLD | NEW |
| 1 // Copyright 2010 the V8 project authors. All rights reserved. | 1 // Copyright 2010 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 2976 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2987 | 2987 |
| 2988 // Add a label for checking the size of the code used for returning. | 2988 // Add a label for checking the size of the code used for returning. |
| 2989 #ifdef DEBUG | 2989 #ifdef DEBUG |
| 2990 Label check_exit_codesize; | 2990 Label check_exit_codesize; |
| 2991 masm_->bind(&check_exit_codesize); | 2991 masm_->bind(&check_exit_codesize); |
| 2992 #endif | 2992 #endif |
| 2993 | 2993 |
| 2994 // Leave the frame and return popping the arguments and the | 2994 // Leave the frame and return popping the arguments and the |
| 2995 // receiver. | 2995 // receiver. |
| 2996 frame_->Exit(); | 2996 frame_->Exit(); |
| 2997 masm_->ret((scope()->num_parameters() + 1) * kPointerSize); | 2997 int arguments_bytes = (scope()->num_parameters() + 1) * kPointerSize; |
| 2998 __ Ret(arguments_bytes, rcx); |
| 2998 DeleteFrame(); | 2999 DeleteFrame(); |
| 2999 | 3000 |
| 3000 #ifdef ENABLE_DEBUGGER_SUPPORT | 3001 #ifdef ENABLE_DEBUGGER_SUPPORT |
| 3001 // Add padding that will be overwritten by a debugger breakpoint. | 3002 // Add padding that will be overwritten by a debugger breakpoint. |
| 3002 // frame_->Exit() generates "movq rsp, rbp; pop rbp; ret k" | 3003 // The shortest return sequence generated is "movq rsp, rbp; pop rbp; ret k" |
| 3003 // with length 7 (3 + 1 + 3). | 3004 // with length 7 (3 + 1 + 3). |
| 3004 const int kPadding = Assembler::kJSReturnSequenceLength - 7; | 3005 const int kPadding = Assembler::kJSReturnSequenceLength - 7; |
| 3005 for (int i = 0; i < kPadding; ++i) { | 3006 for (int i = 0; i < kPadding; ++i) { |
| 3006 masm_->int3(); | 3007 masm_->int3(); |
| 3007 } | 3008 } |
| 3008 // Check that the size of the code used for returning matches what is | 3009 // Check that the size of the code used for returning is large enough |
| 3009 // expected by the debugger. | 3010 // for the debugger's requirements. |
| 3010 ASSERT_EQ(Assembler::kJSReturnSequenceLength, | 3011 ASSERT(Assembler::kJSReturnSequenceLength <= |
| 3011 masm_->SizeOfCodeGeneratedSince(&check_exit_codesize)); | 3012 masm_->SizeOfCodeGeneratedSince(&check_exit_codesize)); |
| 3012 #endif | 3013 #endif |
| 3013 } | 3014 } |
| 3014 | 3015 |
| 3015 | 3016 |
| 3016 void CodeGenerator::VisitWithEnterStatement(WithEnterStatement* node) { | 3017 void CodeGenerator::VisitWithEnterStatement(WithEnterStatement* node) { |
| 3017 ASSERT(!in_spilled_code()); | 3018 ASSERT(!in_spilled_code()); |
| 3018 Comment cmnt(masm_, "[ WithEnterStatement"); | 3019 Comment cmnt(masm_, "[ WithEnterStatement"); |
| 3019 CodeForStatementPosition(node); | 3020 CodeForStatementPosition(node); |
| 3020 Load(node->expression()); | 3021 Load(node->expression()); |
| 3021 Result context; | 3022 Result context; |
| (...skipping 2374 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5396 NOT_INSIDE_TYPEOF, | 5397 NOT_INSIDE_TYPEOF, |
| 5397 &slow); | 5398 &slow); |
| 5398 frame_->Push(&fun); | 5399 frame_->Push(&fun); |
| 5399 if (arg_count > 0) { | 5400 if (arg_count > 0) { |
| 5400 frame_->PushElementAt(arg_count); | 5401 frame_->PushElementAt(arg_count); |
| 5401 } else { | 5402 } else { |
| 5402 frame_->Push(FACTORY->undefined_value()); | 5403 frame_->Push(FACTORY->undefined_value()); |
| 5403 } | 5404 } |
| 5404 frame_->PushParameterAt(-1); | 5405 frame_->PushParameterAt(-1); |
| 5405 | 5406 |
| 5407 // Push the strict mode flag. |
| 5408 frame_->Push(Smi::FromInt(strict_mode_flag())); |
| 5409 |
| 5406 // Resolve the call. | 5410 // Resolve the call. |
| 5407 result = | 5411 result = |
| 5408 frame_->CallRuntime(Runtime::kResolvePossiblyDirectEvalNoLookup, 3); | 5412 frame_->CallRuntime(Runtime::kResolvePossiblyDirectEvalNoLookup, 4); |
| 5409 | 5413 |
| 5410 done.Jump(&result); | 5414 done.Jump(&result); |
| 5411 slow.Bind(); | 5415 slow.Bind(); |
| 5412 } | 5416 } |
| 5413 | 5417 |
| 5414 // Prepare the stack for the call to ResolvePossiblyDirectEval by | 5418 // Prepare the stack for the call to ResolvePossiblyDirectEval by |
| 5415 // pushing the loaded function, the first argument to the eval | 5419 // pushing the loaded function, the first argument to the eval |
| 5416 // call and the receiver. | 5420 // call and the receiver. |
| 5417 frame_->PushElementAt(arg_count + 1); | 5421 frame_->PushElementAt(arg_count + 1); |
| 5418 if (arg_count > 0) { | 5422 if (arg_count > 0) { |
| 5419 frame_->PushElementAt(arg_count); | 5423 frame_->PushElementAt(arg_count); |
| 5420 } else { | 5424 } else { |
| 5421 frame_->Push(FACTORY->undefined_value()); | 5425 frame_->Push(FACTORY->undefined_value()); |
| 5422 } | 5426 } |
| 5423 frame_->PushParameterAt(-1); | 5427 frame_->PushParameterAt(-1); |
| 5424 | 5428 |
| 5429 // Push the strict mode flag. |
| 5430 frame_->Push(Smi::FromInt(strict_mode_flag())); |
| 5431 |
| 5425 // Resolve the call. | 5432 // Resolve the call. |
| 5426 result = frame_->CallRuntime(Runtime::kResolvePossiblyDirectEval, 3); | 5433 result = frame_->CallRuntime(Runtime::kResolvePossiblyDirectEval, 4); |
| 5427 | 5434 |
| 5428 // If we generated fast-case code bind the jump-target where fast | 5435 // If we generated fast-case code bind the jump-target where fast |
| 5429 // and slow case merge. | 5436 // and slow case merge. |
| 5430 if (done.is_linked()) done.Bind(&result); | 5437 if (done.is_linked()) done.Bind(&result); |
| 5431 | 5438 |
| 5432 // The runtime call returns a pair of values in rax (function) and | 5439 // The runtime call returns a pair of values in rax (function) and |
| 5433 // rdx (receiver). Touch up the stack with the right values. | 5440 // rdx (receiver). Touch up the stack with the right values. |
| 5434 Result receiver = allocator_->Allocate(rdx); | 5441 Result receiver = allocator_->Allocate(rdx); |
| 5435 frame_->SetElementAt(arg_count + 1, &result); | 5442 frame_->SetElementAt(arg_count + 1, &result); |
| 5436 frame_->SetElementAt(arg_count, &receiver); | 5443 frame_->SetElementAt(arg_count, &receiver); |
| (...skipping 1526 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6963 // Test for -0.5. | 6970 // Test for -0.5. |
| 6964 // Load xmm2 with -0.5. | 6971 // Load xmm2 with -0.5. |
| 6965 __ movl(answer.reg(), Immediate(0xBF000000)); | 6972 __ movl(answer.reg(), Immediate(0xBF000000)); |
| 6966 __ movd(xmm2, answer.reg()); | 6973 __ movd(xmm2, answer.reg()); |
| 6967 __ cvtss2sd(xmm2, xmm2); | 6974 __ cvtss2sd(xmm2, xmm2); |
| 6968 // xmm2 now has -0.5. | 6975 // xmm2 now has -0.5. |
| 6969 __ ucomisd(xmm2, xmm1); | 6976 __ ucomisd(xmm2, xmm1); |
| 6970 __ j(not_equal, ¬_minus_half); | 6977 __ j(not_equal, ¬_minus_half); |
| 6971 | 6978 |
| 6972 // Calculates reciprocal of square root. | 6979 // Calculates reciprocal of square root. |
| 6973 // Note that 1/sqrt(x) = sqrt(1/x)) | 6980 // sqrtsd returns -0 when input is -0. ECMA spec requires +0. |
| 6974 __ divsd(xmm3, xmm0); | 6981 __ xorpd(xmm1, xmm1); |
| 6982 __ addsd(xmm1, xmm0); |
| 6983 __ sqrtsd(xmm1, xmm1); |
| 6984 __ divsd(xmm3, xmm1); |
| 6975 __ movsd(xmm1, xmm3); | 6985 __ movsd(xmm1, xmm3); |
| 6976 __ sqrtsd(xmm1, xmm1); | |
| 6977 __ jmp(&allocate_return); | 6986 __ jmp(&allocate_return); |
| 6978 | 6987 |
| 6979 // Test for 0.5. | 6988 // Test for 0.5. |
| 6980 __ bind(¬_minus_half); | 6989 __ bind(¬_minus_half); |
| 6981 // Load xmm2 with 0.5. | 6990 // Load xmm2 with 0.5. |
| 6982 // Since xmm3 is 1 and xmm2 is -0.5 this is simply xmm2 + xmm3. | 6991 // Since xmm3 is 1 and xmm2 is -0.5 this is simply xmm2 + xmm3. |
| 6983 __ addsd(xmm2, xmm3); | 6992 __ addsd(xmm2, xmm3); |
| 6984 // xmm2 now has 0.5. | 6993 // xmm2 now has 0.5. |
| 6985 __ ucomisd(xmm2, xmm1); | 6994 __ ucomisd(xmm2, xmm1); |
| 6986 call_runtime.Branch(not_equal); | 6995 call_runtime.Branch(not_equal); |
| 6987 | 6996 |
| 6988 // Calculates square root. | 6997 // Calculates square root. |
| 6989 __ movsd(xmm1, xmm0); | 6998 // sqrtsd returns -0 when input is -0. ECMA spec requires +0. |
| 6999 __ xorpd(xmm1, xmm1); |
| 7000 __ addsd(xmm1, xmm0); |
| 6990 __ sqrtsd(xmm1, xmm1); | 7001 __ sqrtsd(xmm1, xmm1); |
| 6991 | 7002 |
| 6992 JumpTarget done; | 7003 JumpTarget done; |
| 6993 Label failure, success; | 7004 Label failure, success; |
| 6994 __ bind(&allocate_return); | 7005 __ bind(&allocate_return); |
| 6995 // Make a copy of the frame to enable us to handle allocation | 7006 // Make a copy of the frame to enable us to handle allocation |
| 6996 // failure after the JumpTarget jump. | 7007 // failure after the JumpTarget jump. |
| 6997 VirtualFrame* clone = new VirtualFrame(frame()); | 7008 VirtualFrame* clone = new VirtualFrame(frame()); |
| 6998 __ AllocateHeapNumber(answer.reg(), exponent.reg(), &failure); | 7009 __ AllocateHeapNumber(answer.reg(), exponent.reg(), &failure); |
| 6999 __ movsd(FieldOperand(answer.reg(), HeapNumber::kValueOffset), xmm1); | 7010 __ movsd(FieldOperand(answer.reg(), HeapNumber::kValueOffset), xmm1); |
| (...skipping 1802 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 8802 } | 8813 } |
| 8803 | 8814 |
| 8804 #endif | 8815 #endif |
| 8805 | 8816 |
| 8806 | 8817 |
| 8807 #undef __ | 8818 #undef __ |
| 8808 | 8819 |
| 8809 } } // namespace v8::internal | 8820 } } // namespace v8::internal |
| 8810 | 8821 |
| 8811 #endif // V8_TARGET_ARCH_X64 | 8822 #endif // V8_TARGET_ARCH_X64 |
| OLD | NEW |