| OLD | NEW |
| 1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 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 19 matching lines...) Expand all Loading... |
| 30 #if defined(V8_TARGET_ARCH_IA32) | 30 #if defined(V8_TARGET_ARCH_IA32) |
| 31 | 31 |
| 32 #include "ia32/lithium-codegen-ia32.h" | 32 #include "ia32/lithium-codegen-ia32.h" |
| 33 #include "code-stubs.h" | 33 #include "code-stubs.h" |
| 34 #include "stub-cache.h" | 34 #include "stub-cache.h" |
| 35 | 35 |
| 36 namespace v8 { | 36 namespace v8 { |
| 37 namespace internal { | 37 namespace internal { |
| 38 | 38 |
| 39 | 39 |
| 40 // When invoking builtins, we need to record the safepoint in the middle of |
| 41 // the invoke instruction sequence generated by the macro assembler. |
| 40 class SafepointGenerator : public PostCallGenerator { | 42 class SafepointGenerator : public PostCallGenerator { |
| 41 public: | 43 public: |
| 42 SafepointGenerator(LCodeGen* codegen, | 44 SafepointGenerator(LCodeGen* codegen, |
| 43 LPointerMap* pointers, | 45 LPointerMap* pointers, |
| 44 int deoptimization_index) | 46 int deoptimization_index) |
| 45 : codegen_(codegen), | 47 : codegen_(codegen), |
| 46 pointers_(pointers), | 48 pointers_(pointers), |
| 47 deoptimization_index_(deoptimization_index) { } | 49 deoptimization_index_(deoptimization_index) { } |
| 48 virtual ~SafepointGenerator() { } | 50 virtual ~SafepointGenerator() { } |
| 49 | 51 |
| (...skipping 309 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 359 translation->StoreLiteral(src_index); | 361 translation->StoreLiteral(src_index); |
| 360 } else { | 362 } else { |
| 361 UNREACHABLE(); | 363 UNREACHABLE(); |
| 362 } | 364 } |
| 363 } | 365 } |
| 364 | 366 |
| 365 | 367 |
| 366 void LCodeGen::CallCode(Handle<Code> code, | 368 void LCodeGen::CallCode(Handle<Code> code, |
| 367 RelocInfo::Mode mode, | 369 RelocInfo::Mode mode, |
| 368 LInstruction* instr) { | 370 LInstruction* instr) { |
| 369 if (instr != NULL) { | 371 ASSERT(instr != NULL); |
| 370 LPointerMap* pointers = instr->pointer_map(); | 372 LPointerMap* pointers = instr->pointer_map(); |
| 371 RecordPosition(pointers->position()); | 373 RecordPosition(pointers->position()); |
| 372 __ call(code, mode); | 374 __ call(code, mode); |
| 373 RegisterLazyDeoptimization(instr); | 375 RegisterLazyDeoptimization(instr); |
| 374 } else { | |
| 375 LPointerMap no_pointers(0); | |
| 376 RecordPosition(no_pointers.position()); | |
| 377 __ call(code, mode); | |
| 378 RecordSafepoint(&no_pointers, Safepoint::kNoDeoptimizationIndex); | |
| 379 } | |
| 380 | 376 |
| 381 // Signal that we don't inline smi code before these stubs in the | 377 // Signal that we don't inline smi code before these stubs in the |
| 382 // optimizing code generator. | 378 // optimizing code generator. |
| 383 if (code->kind() == Code::TYPE_RECORDING_BINARY_OP_IC || | 379 if (code->kind() == Code::TYPE_RECORDING_BINARY_OP_IC || |
| 384 code->kind() == Code::COMPARE_IC) { | 380 code->kind() == Code::COMPARE_IC) { |
| 385 __ nop(); | 381 __ nop(); |
| 386 } | 382 } |
| 387 } | 383 } |
| 388 | 384 |
| 389 | 385 |
| 390 void LCodeGen::CallRuntime(Runtime::Function* function, | 386 void LCodeGen::CallRuntime(Runtime::Function* function, |
| 391 int num_arguments, | 387 int num_arguments, |
| 392 LInstruction* instr) { | 388 LInstruction* instr) { |
| 393 ASSERT(instr != NULL); | 389 ASSERT(instr != NULL); |
| 390 ASSERT(instr->HasPointerMap()); |
| 394 LPointerMap* pointers = instr->pointer_map(); | 391 LPointerMap* pointers = instr->pointer_map(); |
| 395 ASSERT(pointers != NULL); | |
| 396 RecordPosition(pointers->position()); | 392 RecordPosition(pointers->position()); |
| 397 | 393 |
| 398 __ CallRuntime(function, num_arguments); | 394 __ CallRuntime(function, num_arguments); |
| 399 // Runtime calls to Throw are not supposed to ever return at the | 395 RegisterLazyDeoptimization(instr); |
| 400 // call site, so don't register lazy deoptimization for these. We do | |
| 401 // however have to record a safepoint since throwing exceptions can | |
| 402 // cause garbage collections. | |
| 403 // BUG(3243555): register a lazy deoptimization point at throw. We need | |
| 404 // it to be able to inline functions containing a throw statement. | |
| 405 if (!instr->IsThrow()) { | |
| 406 RegisterLazyDeoptimization(instr); | |
| 407 } else { | |
| 408 RecordSafepoint(instr->pointer_map(), Safepoint::kNoDeoptimizationIndex); | |
| 409 } | |
| 410 } | 396 } |
| 411 | 397 |
| 412 | 398 |
| 413 void LCodeGen::RegisterLazyDeoptimization(LInstruction* instr) { | 399 void LCodeGen::RegisterLazyDeoptimization(LInstruction* instr) { |
| 414 // Create the environment to bailout to. If the call has side effects | 400 // Create the environment to bailout to. If the call has side effects |
| 415 // execution has to continue after the call otherwise execution can continue | 401 // execution has to continue after the call otherwise execution can continue |
| 416 // from a previous bailout point repeating the call. | 402 // from a previous bailout point repeating the call. |
| 417 LEnvironment* deoptimization_environment; | 403 LEnvironment* deoptimization_environment; |
| 418 if (instr->HasDeoptimizationEnvironment()) { | 404 if (instr->HasDeoptimizationEnvironment()) { |
| 419 deoptimization_environment = instr->deoptimization_environment(); | 405 deoptimization_environment = instr->deoptimization_environment(); |
| (...skipping 1718 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2138 // length is a small non-negative integer, due to the test above. | 2124 // length is a small non-negative integer, due to the test above. |
| 2139 __ test(length, Operand(length)); | 2125 __ test(length, Operand(length)); |
| 2140 __ j(zero, &invoke); | 2126 __ j(zero, &invoke); |
| 2141 __ bind(&loop); | 2127 __ bind(&loop); |
| 2142 __ push(Operand(elements, length, times_pointer_size, 1 * kPointerSize)); | 2128 __ push(Operand(elements, length, times_pointer_size, 1 * kPointerSize)); |
| 2143 __ dec(length); | 2129 __ dec(length); |
| 2144 __ j(not_zero, &loop); | 2130 __ j(not_zero, &loop); |
| 2145 | 2131 |
| 2146 // Invoke the function. | 2132 // Invoke the function. |
| 2147 __ bind(&invoke); | 2133 __ bind(&invoke); |
| 2134 ASSERT(instr->HasPointerMap() && instr->HasDeoptimizationEnvironment()); |
| 2135 LPointerMap* pointers = instr->pointer_map(); |
| 2136 LEnvironment* env = instr->deoptimization_environment(); |
| 2137 RecordPosition(pointers->position()); |
| 2138 RegisterEnvironmentForDeoptimization(env); |
| 2139 SafepointGenerator safepoint_generator(this, |
| 2140 pointers, |
| 2141 env->deoptimization_index()); |
| 2148 ASSERT(receiver.is(eax)); | 2142 ASSERT(receiver.is(eax)); |
| 2149 v8::internal::ParameterCount actual(eax); | 2143 v8::internal::ParameterCount actual(eax); |
| 2150 SafepointGenerator safepoint_generator(this, | |
| 2151 instr->pointer_map(), | |
| 2152 Safepoint::kNoDeoptimizationIndex); | |
| 2153 __ InvokeFunction(edi, actual, CALL_FUNCTION, &safepoint_generator); | 2144 __ InvokeFunction(edi, actual, CALL_FUNCTION, &safepoint_generator); |
| 2154 } | 2145 } |
| 2155 | 2146 |
| 2156 | 2147 |
| 2157 void LCodeGen::DoPushArgument(LPushArgument* instr) { | 2148 void LCodeGen::DoPushArgument(LPushArgument* instr) { |
| 2158 LOperand* argument = instr->InputAt(0); | 2149 LOperand* argument = instr->InputAt(0); |
| 2159 if (argument->IsConstantOperand()) { | 2150 if (argument->IsConstantOperand()) { |
| 2160 __ push(ToImmediate(argument)); | 2151 __ push(ToImmediate(argument)); |
| 2161 } else { | 2152 } else { |
| 2162 __ push(ToOperand(argument)); | 2153 __ push(ToOperand(argument)); |
| (...skipping 1405 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3568 | 3559 |
| 3569 void LCodeGen::DoDeleteProperty(LDeleteProperty* instr) { | 3560 void LCodeGen::DoDeleteProperty(LDeleteProperty* instr) { |
| 3570 LOperand* obj = instr->object(); | 3561 LOperand* obj = instr->object(); |
| 3571 LOperand* key = instr->key(); | 3562 LOperand* key = instr->key(); |
| 3572 __ push(ToOperand(obj)); | 3563 __ push(ToOperand(obj)); |
| 3573 if (key->IsConstantOperand()) { | 3564 if (key->IsConstantOperand()) { |
| 3574 __ push(ToImmediate(key)); | 3565 __ push(ToImmediate(key)); |
| 3575 } else { | 3566 } else { |
| 3576 __ push(ToOperand(key)); | 3567 __ push(ToOperand(key)); |
| 3577 } | 3568 } |
| 3578 RecordPosition(instr->pointer_map()->position()); | 3569 ASSERT(instr->HasPointerMap() && instr->HasDeoptimizationEnvironment()); |
| 3570 LPointerMap* pointers = instr->pointer_map(); |
| 3571 LEnvironment* env = instr->deoptimization_environment(); |
| 3572 RecordPosition(pointers->position()); |
| 3573 RegisterEnvironmentForDeoptimization(env); |
| 3579 SafepointGenerator safepoint_generator(this, | 3574 SafepointGenerator safepoint_generator(this, |
| 3580 instr->pointer_map(), | 3575 pointers, |
| 3581 Safepoint::kNoDeoptimizationIndex); | 3576 env->deoptimization_index()); |
| 3582 __ InvokeBuiltin(Builtins::DELETE, CALL_FUNCTION, &safepoint_generator); | 3577 __ InvokeBuiltin(Builtins::DELETE, CALL_FUNCTION, &safepoint_generator); |
| 3583 } | 3578 } |
| 3584 | 3579 |
| 3585 | 3580 |
| 3586 void LCodeGen::DoStackCheck(LStackCheck* instr) { | 3581 void LCodeGen::DoStackCheck(LStackCheck* instr) { |
| 3587 // Perform stack overflow check. | 3582 // Perform stack overflow check. |
| 3588 NearLabel done; | 3583 NearLabel done; |
| 3589 ExternalReference stack_limit = ExternalReference::address_of_stack_limit(); | 3584 ExternalReference stack_limit = ExternalReference::address_of_stack_limit(); |
| 3590 __ cmp(esp, Operand::StaticVariable(stack_limit)); | 3585 __ cmp(esp, Operand::StaticVariable(stack_limit)); |
| 3591 __ j(above_equal, &done); | 3586 __ j(above_equal, &done); |
| (...skipping 19 matching lines...) Expand all Loading... |
| 3611 ASSERT(osr_pc_offset_ == -1); | 3606 ASSERT(osr_pc_offset_ == -1); |
| 3612 osr_pc_offset_ = masm()->pc_offset(); | 3607 osr_pc_offset_ = masm()->pc_offset(); |
| 3613 } | 3608 } |
| 3614 | 3609 |
| 3615 | 3610 |
| 3616 #undef __ | 3611 #undef __ |
| 3617 | 3612 |
| 3618 } } // namespace v8::internal | 3613 } } // namespace v8::internal |
| 3619 | 3614 |
| 3620 #endif // V8_TARGET_ARCH_IA32 | 3615 #endif // V8_TARGET_ARCH_IA32 |
| OLD | NEW |