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 2143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2154 ArgumentsAdaptorFrameConstants::kLengthOffset)); | 2154 ArgumentsAdaptorFrameConstants::kLengthOffset)); |
2155 __ SmiUntag(result); | 2155 __ SmiUntag(result); |
2156 | 2156 |
2157 // Argument length is in result register. | 2157 // Argument length is in result register. |
2158 __ bind(&done); | 2158 __ bind(&done); |
2159 } | 2159 } |
2160 | 2160 |
2161 | 2161 |
2162 void LCodeGen::DoApplyArguments(LApplyArguments* instr) { | 2162 void LCodeGen::DoApplyArguments(LApplyArguments* instr) { |
2163 Register receiver = ToRegister(instr->receiver()); | 2163 Register receiver = ToRegister(instr->receiver()); |
2164 Register function = ToRegister(instr->function()); | |
2164 Register length = ToRegister(instr->length()); | 2165 Register length = ToRegister(instr->length()); |
2165 Register elements = ToRegister(instr->elements()); | 2166 Register elements = ToRegister(instr->elements()); |
2166 Register temp = ToRegister(instr->TempAt(0)); | 2167 Register scratch = ToRegister(instr->TempAt(0)); |
2167 ASSERT(ToRegister(instr->function()).is(edi)); | 2168 ASSERT(receiver.is(eax)); // Used for parameter count. |
2169 ASSERT(function.is(edi)); // Required by InvokeFunction. | |
2168 ASSERT(ToRegister(instr->result()).is(eax)); | 2170 ASSERT(ToRegister(instr->result()).is(eax)); |
2169 | 2171 |
2170 // If the receiver is null or undefined, we have to pass the | 2172 // If the receiver is null or undefined, we have to pass the global object |
2171 // global object as a receiver. | 2173 // as a receiver. |
2172 NearLabel global_receiver, receiver_ok; | 2174 NearLabel global_object, receiver_ok; |
2173 __ cmp(receiver, Factory::null_value()); | 2175 __ cmp(receiver, Factory::null_value()); |
2174 __ j(equal, &global_receiver); | 2176 __ j(equal, &global_object); |
2175 __ cmp(receiver, Factory::undefined_value()); | 2177 __ cmp(receiver, Factory::undefined_value()); |
2176 __ j(equal, &global_receiver); | 2178 __ j(equal, &global_object); |
2177 | 2179 |
2178 // The receiver should be a JS object. | 2180 // The receiver should be a JS object. |
2179 __ test(receiver, Immediate(kSmiTagMask)); | 2181 __ test(receiver, Immediate(kSmiTagMask)); |
2180 DeoptimizeIf(equal, instr->environment()); | 2182 DeoptimizeIf(equal, instr->environment()); |
2181 __ CmpObjectType(receiver, FIRST_JS_OBJECT_TYPE, temp); | 2183 __ CmpObjectType(receiver, FIRST_JS_OBJECT_TYPE, scratch); |
2182 DeoptimizeIf(below, instr->environment()); | 2184 DeoptimizeIf(below, instr->environment()); |
2183 __ jmp(&receiver_ok); | 2185 __ jmp(&receiver_ok); |
2184 | 2186 |
2185 __ bind(&global_receiver); | 2187 __ bind(&global_object); |
2186 // TODO(kmillikin): We have a hydrogen value for the global object. See | 2188 // TODO(kmillikin): We have a hydrogen value for the global object. See |
2187 // if it's better to use it than to explicitly fetch it from the context | 2189 // if it's better to use it than to explicitly fetch it from the context |
2188 // here. | 2190 // here. |
2189 __ mov(receiver, Operand(ebp, StandardFrameConstants::kContextOffset)); | 2191 __ mov(receiver, Operand(ebp, StandardFrameConstants::kContextOffset)); |
2190 __ mov(receiver, ContextOperand(receiver, Context::GLOBAL_INDEX)); | 2192 __ mov(receiver, ContextOperand(receiver, Context::GLOBAL_INDEX)); |
2191 __ bind(&receiver_ok); | 2193 __ bind(&receiver_ok); |
2192 | 2194 |
2193 Label invoke; | |
2194 | |
2195 // Copy the arguments to this function possibly from the | 2195 // Copy the arguments to this function possibly from the |
2196 // adaptor frame below it. | 2196 // adaptor frame below it. |
2197 const uint32_t kArgumentsLimit = 1 * KB; | 2197 const uint32_t kArgumentsLimit = 1 * KB; |
2198 __ cmp(length, kArgumentsLimit); | 2198 __ cmp(length, kArgumentsLimit); |
2199 DeoptimizeIf(above, instr->environment()); | 2199 DeoptimizeIf(above, instr->environment()); |
2200 | 2200 |
2201 __ push(receiver); | 2201 __ push(receiver); |
2202 __ mov(receiver, length); | 2202 __ mov(receiver, length); |
2203 | 2203 |
2204 // Loop through the arguments pushing them onto the execution | 2204 // Loop through the arguments pushing them onto the execution |
2205 // stack. | 2205 // stack. |
2206 Label loop; | 2206 Label invoke, loop; |
fschneider
2011/02/11 10:04:03
NearLabels?
Kevin Millikin (Chromium)
2011/02/11 11:22:16
Yes, good catch.
| |
2207 // length is a small non-negative integer, due to the test above. | 2207 // length is a small non-negative integer, due to the test above. |
2208 __ test(length, Operand(length)); | 2208 __ test(length, Operand(length)); |
2209 __ j(zero, &invoke); | 2209 __ j(zero, &invoke); |
2210 __ bind(&loop); | 2210 __ bind(&loop); |
2211 __ push(Operand(elements, length, times_pointer_size, 1 * kPointerSize)); | 2211 __ push(Operand(elements, length, times_pointer_size, 1 * kPointerSize)); |
2212 __ dec(length); | 2212 __ dec(length); |
2213 __ j(not_zero, &loop); | 2213 __ j(not_zero, &loop); |
2214 | 2214 |
2215 // Invoke the function. | 2215 // Invoke the function. |
2216 __ bind(&invoke); | 2216 __ bind(&invoke); |
2217 ASSERT(instr->HasPointerMap() && instr->HasDeoptimizationEnvironment()); | 2217 ASSERT(instr->HasPointerMap() && instr->HasDeoptimizationEnvironment()); |
2218 LPointerMap* pointers = instr->pointer_map(); | 2218 LPointerMap* pointers = instr->pointer_map(); |
2219 LEnvironment* env = instr->deoptimization_environment(); | 2219 LEnvironment* env = instr->deoptimization_environment(); |
2220 RecordPosition(pointers->position()); | 2220 RecordPosition(pointers->position()); |
2221 RegisterEnvironmentForDeoptimization(env); | 2221 RegisterEnvironmentForDeoptimization(env); |
2222 SafepointGenerator safepoint_generator(this, | 2222 SafepointGenerator safepoint_generator(this, |
2223 pointers, | 2223 pointers, |
2224 env->deoptimization_index()); | 2224 env->deoptimization_index()); |
2225 ASSERT(receiver.is(eax)); | |
2226 v8::internal::ParameterCount actual(eax); | 2225 v8::internal::ParameterCount actual(eax); |
2227 __ InvokeFunction(edi, actual, CALL_FUNCTION, &safepoint_generator); | 2226 __ InvokeFunction(function, actual, CALL_FUNCTION, &safepoint_generator); |
2228 } | 2227 } |
2229 | 2228 |
2230 | 2229 |
2231 void LCodeGen::DoPushArgument(LPushArgument* instr) { | 2230 void LCodeGen::DoPushArgument(LPushArgument* instr) { |
2232 LOperand* argument = instr->InputAt(0); | 2231 LOperand* argument = instr->InputAt(0); |
2233 if (argument->IsConstantOperand()) { | 2232 if (argument->IsConstantOperand()) { |
2234 __ push(ToImmediate(argument)); | 2233 __ push(ToImmediate(argument)); |
2235 } else { | 2234 } else { |
2236 __ push(ToOperand(argument)); | 2235 __ push(ToOperand(argument)); |
2237 } | 2236 } |
(...skipping 1530 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3768 ASSERT(osr_pc_offset_ == -1); | 3767 ASSERT(osr_pc_offset_ == -1); |
3769 osr_pc_offset_ = masm()->pc_offset(); | 3768 osr_pc_offset_ = masm()->pc_offset(); |
3770 } | 3769 } |
3771 | 3770 |
3772 | 3771 |
3773 #undef __ | 3772 #undef __ |
3774 | 3773 |
3775 } } // namespace v8::internal | 3774 } } // namespace v8::internal |
3776 | 3775 |
3777 #endif // V8_TARGET_ARCH_IA32 | 3776 #endif // V8_TARGET_ARCH_IA32 |
OLD | NEW |