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

Side by Side Diff: src/x64/code-stubs-x64.cc

Issue 140613004: stub fast api calls (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: comments Created 6 years, 11 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 | Annotate | Revision Log
« no previous file with comments | « src/ia32/stub-cache-ia32.cc ('k') | src/x64/macro-assembler-x64.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 the V8 project authors. All rights reserved. 1 // Copyright 2013 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 5204 matching lines...) Expand 10 before | Expand all | Expand 10 after
5215 Label fast_elements_case; 5215 Label fast_elements_case;
5216 __ cmpl(rcx, Immediate(FAST_ELEMENTS)); 5216 __ cmpl(rcx, Immediate(FAST_ELEMENTS));
5217 __ j(equal, &fast_elements_case); 5217 __ j(equal, &fast_elements_case);
5218 GenerateCase(masm, FAST_HOLEY_ELEMENTS); 5218 GenerateCase(masm, FAST_HOLEY_ELEMENTS);
5219 5219
5220 __ bind(&fast_elements_case); 5220 __ bind(&fast_elements_case);
5221 GenerateCase(masm, FAST_ELEMENTS); 5221 GenerateCase(masm, FAST_ELEMENTS);
5222 } 5222 }
5223 5223
5224 5224
5225 void CallApiFunctionStub::Generate(MacroAssembler* masm) {
5226 // ----------- S t a t e -------------
5227 // -- rax : callee
5228 // -- rbx : call_data
5229 // -- rcx : holder
5230 // -- rdx : api_function_address
5231 // -- rsi : context
5232 // --
5233 // -- rsp[0] : return address
5234 // -- rsp[8] : last argument
5235 // -- ...
5236 // -- rsp[argc * 8] : first argument
5237 // -- rsp[(argc + 1) * 8] : receiver
5238 // -----------------------------------
5239
5240 Register callee = rax;
5241 Register call_data = rbx;
5242 Register holder = rcx;
5243 Register api_function_address = rdx;
5244 Register return_address = rdi;
5245 Register context = rsi;
5246
5247 int argc = ArgumentBits::decode(bit_field_);
5248 bool restore_context = RestoreContextBits::decode(bit_field_);
5249 bool call_data_undefined = CallDataUndefinedBits::decode(bit_field_);
5250
5251 typedef FunctionCallbackArguments FCA;
5252
5253 STATIC_ASSERT(FCA::kContextSaveIndex == 6);
5254 STATIC_ASSERT(FCA::kCalleeIndex == 5);
5255 STATIC_ASSERT(FCA::kDataIndex == 4);
5256 STATIC_ASSERT(FCA::kReturnValueOffset == 3);
5257 STATIC_ASSERT(FCA::kReturnValueDefaultValueIndex == 2);
5258 STATIC_ASSERT(FCA::kIsolateIndex == 1);
5259 STATIC_ASSERT(FCA::kHolderIndex == 0);
5260 STATIC_ASSERT(FCA::kArgsLength == 7);
5261
5262 __ PopReturnAddressTo(return_address);
5263
5264 // context save
5265 __ push(context);
5266 // load context from callee
5267 __ movp(context, FieldOperand(callee, JSFunction::kContextOffset));
5268
5269 // callee
5270 __ push(callee);
5271
5272 // call data
5273 __ push(call_data);
5274 Register scratch = call_data;
5275 if (!call_data_undefined) {
5276 __ LoadRoot(scratch, Heap::kUndefinedValueRootIndex);
5277 }
5278 // return value
5279 __ push(scratch);
5280 // return value default
5281 __ push(scratch);
5282 // isolate
5283 __ Move(scratch,
5284 ExternalReference::isolate_address(masm->isolate()));
5285 __ push(scratch);
5286 // holder
5287 __ push(holder);
5288
5289 __ movp(scratch, rsp);
5290 // Push return address back on stack.
5291 __ PushReturnAddressFrom(return_address);
5292
5293 // Allocate the v8::Arguments structure in the arguments' space since
5294 // it's not controlled by GC.
5295 const int kApiStackSpace = 4;
5296
5297 __ PrepareCallApiFunction(kApiStackSpace);
5298
5299 // FunctionCallbackInfo::implicit_args_.
5300 __ movp(StackSpaceOperand(0), scratch);
5301 __ addq(scratch, Immediate((argc + FCA::kArgsLength - 1) * kPointerSize));
5302 __ movp(StackSpaceOperand(1), scratch); // FunctionCallbackInfo::values_.
5303 __ Set(StackSpaceOperand(2), argc); // FunctionCallbackInfo::length_.
5304 // FunctionCallbackInfo::is_construct_call_.
5305 __ Set(StackSpaceOperand(3), 0);
5306
5307 #if defined(__MINGW64__) || defined(_WIN64)
5308 Register arguments_arg = rcx;
5309 Register callback_arg = rdx;
5310 #else
5311 Register arguments_arg = rdi;
5312 Register callback_arg = rsi;
5313 #endif
5314
5315 // It's okay if callback_arg == api_function_address
5316 // but not arguments_arg
5317 ASSERT(!api_function_address.is(arguments_arg));
5318
5319 // v8::InvocationCallback's argument.
5320 __ lea(arguments_arg, StackSpaceOperand(0));
5321
5322 Address thunk_address = FUNCTION_ADDR(&InvokeFunctionCallback);
5323
5324 StackArgumentsAccessor args_from_rbp(rbp, FCA::kArgsLength,
5325 ARGUMENTS_DONT_CONTAIN_RECEIVER);
5326 Operand context_restore_operand = args_from_rbp.GetArgumentOperand(
5327 FCA::kArgsLength - 1 - FCA::kContextSaveIndex);
5328 Operand return_value_operand = args_from_rbp.GetArgumentOperand(
5329 FCA::kArgsLength - 1 - FCA::kReturnValueOffset);
5330 __ CallApiFunctionAndReturn(
5331 api_function_address,
5332 thunk_address,
5333 callback_arg,
5334 argc + FCA::kArgsLength + 1,
5335 return_value_operand,
5336 restore_context ? &context_restore_operand : NULL);
5337 }
5338
5339
5225 #undef __ 5340 #undef __
5226 5341
5227 } } // namespace v8::internal 5342 } } // namespace v8::internal
5228 5343
5229 #endif // V8_TARGET_ARCH_X64 5344 #endif // V8_TARGET_ARCH_X64
OLDNEW
« no previous file with comments | « src/ia32/stub-cache-ia32.cc ('k') | src/x64/macro-assembler-x64.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698