Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(562)

Side by Side Diff: src/x64/stub-cache-x64.cc

Issue 2801008: Port faster callbacks invocation to x64. (Closed)
Patch Set: Minor cosmetic changes Created 10 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/x64/macro-assembler-x64.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 2193 matching lines...) Expand 10 before | Expand all | Expand 10 after
2204 Register scratch3, 2204 Register scratch3,
2205 AccessorInfo* callback, 2205 AccessorInfo* callback,
2206 String* name, 2206 String* name,
2207 Label* miss, 2207 Label* miss,
2208 Failure** failure) { 2208 Failure** failure) {
2209 // Check that the receiver isn't a smi. 2209 // Check that the receiver isn't a smi.
2210 __ JumpIfSmi(receiver, miss); 2210 __ JumpIfSmi(receiver, miss);
2211 2211
2212 // Check that the maps haven't changed. 2212 // Check that the maps haven't changed.
2213 Register reg = 2213 Register reg =
2214 CheckPrototypes(object, receiver, holder, 2214 CheckPrototypes(object, receiver, holder, scratch1,
2215 scratch1, scratch2, scratch3, name, miss); 2215 scratch2, scratch3, name, miss);
2216 2216
2217 // Push the arguments on the JS stack of the caller. 2217 Handle<AccessorInfo> callback_handle(callback);
2218 __ pop(scratch2); // remove return address 2218
2219 __ EnterInternalFrame();
2220 __ PushHandleScope(scratch2);
2221 // Push the stack address where the list of arguments ends.
2222 __ movq(scratch2, rsp);
2223 __ subq(scratch2, Immediate(2 * kPointerSize));
2224 __ push(scratch2);
2219 __ push(receiver); // receiver 2225 __ push(receiver); // receiver
2220 __ push(reg); // holder 2226 __ push(reg); // holder
2221 __ Move(reg, Handle<AccessorInfo>(callback)); // callback data 2227 if (Heap::InNewSpace(callback_handle->data())) {
2222 __ push(reg); 2228 __ Move(scratch2, callback_handle);
2223 __ push(FieldOperand(reg, AccessorInfo::kDataOffset)); 2229 __ push(FieldOperand(scratch2, AccessorInfo::kDataOffset)); // data
2230 } else {
2231 __ Push(Handle<Object>(callback_handle->data()));
2232 }
2224 __ push(name_reg); // name 2233 __ push(name_reg); // name
2225 __ push(scratch2); // restore return address 2234 // Save a pointer to where we pushed the arguments pointer.
2235 // This will be passed as the const AccessorInfo& to the C++ callback.
2226 2236
2227 // Do tail-call to the runtime system. 2237 #ifdef _WIN64
2228 ExternalReference load_callback_property = 2238 // Win64 uses first register--rcx--for returned value.
2229 ExternalReference(IC_Utility(IC::kLoadCallbackProperty)); 2239 Register accessor_info_arg = r8;
2230 __ TailCallExternalReference(load_callback_property, 5, 1); 2240 Register name_arg = rdx;
2241 #else
2242 Register accessor_info_arg = rdx; // temporary, copied to rsi by the stub.
2243 Register name_arg = rdi;
2244 #endif
2245
2246 __ movq(accessor_info_arg, rsp);
2247 __ addq(accessor_info_arg, Immediate(4 * kPointerSize));
2248 __ movq(name_arg, rsp);
2249
2250 // Do call through the api.
2251 ASSERT_EQ(5, ApiGetterEntryStub::kStackSpace);
2252 Address getter_address = v8::ToCData<Address>(callback->getter());
2253 ApiFunction fun(getter_address);
2254 ApiGetterEntryStub stub(callback_handle, &fun);
2255 #ifdef _WIN64
2256 // We need to prepare a slot for result handle on stack and put
2257 // a pointer to it into 1st arg register.
2258 __ push(Immediate(0));
2259 __ movq(rcx, rsp);
2260 #endif
2261 // Emitting a stub call may try to allocate (if the code is not
2262 // already generated). Do not allow the assembler to perform a
2263 // garbage collection but instead return the allocation failure
2264 // object.
2265 Object* result = masm()->TryCallStub(&stub);
2266 if (result->IsFailure()) {
2267 *failure = Failure::cast(result);
2268 return false;
2269 }
2270 #ifdef _WIN64
2271 // Discard allocated slot.
2272 __ addq(rsp, Immediate(kPointerSize));
2273 #endif
2274
2275 // We need to avoid using rax since that now holds the result.
2276 Register tmp = scratch2.is(rax) ? reg : scratch2;
2277 // Emitting PopHandleScope may try to allocate. Do not allow the
2278 // assembler to perform a garbage collection but instead return a
2279 // failure object.
2280 result = masm()->TryPopHandleScope(rax, tmp);
2281 if (result->IsFailure()) {
2282 *failure = Failure::cast(result);
2283 return false;
2284 }
2285 __ LeaveInternalFrame();
2286
2287 __ ret(0);
2231 2288
2232 return true; 2289 return true;
2233 } 2290 }
2234 2291
2235 2292
2236 Register StubCompiler::CheckPrototypes(JSObject* object, 2293 Register StubCompiler::CheckPrototypes(JSObject* object,
2237 Register object_reg, 2294 Register object_reg,
2238 JSObject* holder, 2295 JSObject* holder,
2239 Register holder_reg, 2296 Register holder_reg,
2240 Register scratch1, 2297 Register scratch1,
(...skipping 310 matching lines...) Expand 10 before | Expand all | Expand 10 after
2551 // Return the generated code. 2608 // Return the generated code.
2552 return GetCode(); 2609 return GetCode();
2553 } 2610 }
2554 2611
2555 2612
2556 #undef __ 2613 #undef __
2557 2614
2558 } } // namespace v8::internal 2615 } } // namespace v8::internal
2559 2616
2560 #endif // V8_TARGET_ARCH_X64 2617 #endif // V8_TARGET_ARCH_X64
OLDNEW
« no previous file with comments | « src/x64/macro-assembler-x64.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698