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

Side by Side Diff: src/arm/code-stubs-arm.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 | « no previous file | src/arm/macro-assembler-arm.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 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 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 5497 matching lines...) Expand 10 before | Expand all | Expand 10 after
5508 Label fast_elements_case; 5508 Label fast_elements_case;
5509 __ cmp(r3, Operand(FAST_ELEMENTS)); 5509 __ cmp(r3, Operand(FAST_ELEMENTS));
5510 __ b(eq, &fast_elements_case); 5510 __ b(eq, &fast_elements_case);
5511 GenerateCase(masm, FAST_HOLEY_ELEMENTS); 5511 GenerateCase(masm, FAST_HOLEY_ELEMENTS);
5512 5512
5513 __ bind(&fast_elements_case); 5513 __ bind(&fast_elements_case);
5514 GenerateCase(masm, FAST_ELEMENTS); 5514 GenerateCase(masm, FAST_ELEMENTS);
5515 } 5515 }
5516 5516
5517 5517
5518 void CallApiFunctionStub::Generate(MacroAssembler* masm) {
5519 // ----------- S t a t e -------------
5520 // -- r0 : callee
5521 // -- r4 : call_data
5522 // -- r2 : holder
5523 // -- r3 : api_function_address
5524 // -- r1 : thunk_arg
5525 // -- cp : context
5526 // --
5527 // -- esp[0] : last argument
5528 // -- ...
5529 // -- esp[(argc - 1)* 4] : first argument
5530 // -- esp[argc * 4] : receiver
5531 // -----------------------------------
5532
5533 Register callee = r0;
5534 Register call_data = r4;
5535 Register holder = r2;
5536 Register api_function_address = r3;
5537 Register thunk_arg = r1;
5538 Register context = cp;
5539
5540 int argc = ArgumentBits::decode(bit_field_);
5541 bool restore_context = RestoreContextBits::decode(bit_field_);
5542 bool call_data_undefined = CallDataUndefinedBits::decode(bit_field_);
5543
5544 typedef FunctionCallbackArguments FCA;
5545
5546 STATIC_ASSERT(FCA::kContextSaveIndex == 6);
5547 STATIC_ASSERT(FCA::kCalleeIndex == 5);
5548 STATIC_ASSERT(FCA::kDataIndex == 4);
5549 STATIC_ASSERT(FCA::kReturnValueOffset == 3);
5550 STATIC_ASSERT(FCA::kReturnValueDefaultValueIndex == 2);
5551 STATIC_ASSERT(FCA::kIsolateIndex == 1);
5552 STATIC_ASSERT(FCA::kHolderIndex == 0);
5553 STATIC_ASSERT(FCA::kArgsLength == 7);
5554
5555 Isolate* isolate = masm->isolate();
5556
5557 // context save
5558 __ push(context);
5559 // load context from callee
5560 __ ldr(context, FieldMemOperand(callee, JSFunction::kContextOffset));
5561
5562 // callee
5563 __ push(callee);
5564
5565 // call data
5566 __ push(call_data);
5567
5568 Register scratch = call_data;
5569 if (!call_data_undefined) {
5570 __ LoadRoot(scratch, Heap::kUndefinedValueRootIndex);
5571 }
5572 // return value
5573 __ push(scratch);
5574 // return value default
5575 __ push(scratch);
5576 // isolate
5577 __ mov(scratch,
5578 Operand(ExternalReference::isolate_address(isolate)));
5579 __ push(scratch);
5580 // holder
5581 __ push(holder);
5582
5583 // Prepare arguments.
5584 __ mov(scratch, sp);
5585
5586 // Allocate the v8::Arguments structure in the arguments' space since
5587 // it's not controlled by GC.
5588 const int kApiStackSpace = 4;
5589
5590 FrameScope frame_scope(masm, StackFrame::MANUAL);
5591 __ EnterExitFrame(false, kApiStackSpace);
5592
5593 ASSERT(!thunk_arg.is(r0) && !api_function_address.is(r0) && !scratch.is(r0));
5594 // r0 = FunctionCallbackInfo&
5595 // Arguments is after the return address.
5596 __ add(r0, sp, Operand(1 * kPointerSize));
5597 // FunctionCallbackInfo::implicit_args_
5598 __ str(scratch, MemOperand(r0, 0 * kPointerSize));
5599 // FunctionCallbackInfo::values_
5600 __ add(ip, scratch, Operand((FCA::kArgsLength - 1 + argc) * kPointerSize));
5601 __ str(ip, MemOperand(r0, 1 * kPointerSize));
5602 // FunctionCallbackInfo::length_ = argc
5603 __ mov(ip, Operand(argc));
5604 __ str(ip, MemOperand(r0, 2 * kPointerSize));
5605 // FunctionCallbackInfo::is_construct_call = 0
5606 __ mov(ip, Operand::Zero());
5607 __ str(ip, MemOperand(r0, 3 * kPointerSize));
5608
5609 const int kStackUnwindSpace = argc + FCA::kArgsLength + 1;
5610 Address thunk_address = FUNCTION_ADDR(&InvokeFunctionCallback);
5611 ExternalReference::Type thunk_type = ExternalReference::PROFILING_API_CALL;
5612 ApiFunction thunk_fun(thunk_address);
5613 ExternalReference thunk_ref = ExternalReference(&thunk_fun, thunk_type,
5614 masm->isolate());
5615
5616 AllowExternalCallThatCantCauseGC scope(masm);
5617 MemOperand context_restore_operand(
5618 fp, (2 + FCA::kContextSaveIndex) * kPointerSize);
5619 MemOperand return_value_operand(fp,
5620 (2 + FCA::kReturnValueOffset) * kPointerSize);
5621
5622 __ CallApiFunctionAndReturn(api_function_address,
5623 thunk_ref,
5624 thunk_arg,
5625 kStackUnwindSpace,
5626 return_value_operand,
5627 restore_context ?
5628 &context_restore_operand : NULL);
5629 }
5630
5631
5518 #undef __ 5632 #undef __
5519 5633
5520 } } // namespace v8::internal 5634 } } // namespace v8::internal
5521 5635
5522 #endif // V8_TARGET_ARCH_ARM 5636 #endif // V8_TARGET_ARCH_ARM
OLDNEW
« no previous file with comments | « no previous file | src/arm/macro-assembler-arm.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698