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

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

Issue 140613004: stub fast api calls (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: comments Created 6 years, 10 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/code-stubs.h ('k') | src/ia32/macro-assembler-ia32.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 5364 matching lines...) Expand 10 before | Expand all | Expand 10 after
5375 Label fast_elements_case; 5375 Label fast_elements_case;
5376 __ cmp(ecx, Immediate(FAST_ELEMENTS)); 5376 __ cmp(ecx, Immediate(FAST_ELEMENTS));
5377 __ j(equal, &fast_elements_case); 5377 __ j(equal, &fast_elements_case);
5378 GenerateCase(masm, FAST_HOLEY_ELEMENTS); 5378 GenerateCase(masm, FAST_HOLEY_ELEMENTS);
5379 5379
5380 __ bind(&fast_elements_case); 5380 __ bind(&fast_elements_case);
5381 GenerateCase(masm, FAST_ELEMENTS); 5381 GenerateCase(masm, FAST_ELEMENTS);
5382 } 5382 }
5383 5383
5384 5384
5385 void CallApiFunctionStub::Generate(MacroAssembler* masm) {
5386 // ----------- S t a t e -------------
5387 // -- eax : callee
5388 // -- ebx : call_data
5389 // -- ecx : holder
5390 // -- edx : api_function_address
5391 // -- esi : context
5392 // --
5393 // -- esp[0] : return address
5394 // -- esp[4] : last argument
5395 // -- ...
5396 // -- esp[argc * 4] : first argument
5397 // -- esp[(argc + 1) * 4] : receiver
5398 // -----------------------------------
5399
5400 Register callee = eax;
5401 Register call_data = ebx;
5402 Register holder = ecx;
5403 Register api_function_address = edx;
5404 Register return_address = edi;
5405 Register context = esi;
5406
5407 int argc = ArgumentBits::decode(bit_field_);
5408 bool restore_context = RestoreContextBits::decode(bit_field_);
5409 bool call_data_undefined = CallDataUndefinedBits::decode(bit_field_);
5410
5411 typedef FunctionCallbackArguments FCA;
5412
5413 STATIC_ASSERT(FCA::kContextSaveIndex == 6);
5414 STATIC_ASSERT(FCA::kCalleeIndex == 5);
5415 STATIC_ASSERT(FCA::kDataIndex == 4);
5416 STATIC_ASSERT(FCA::kReturnValueOffset == 3);
5417 STATIC_ASSERT(FCA::kReturnValueDefaultValueIndex == 2);
5418 STATIC_ASSERT(FCA::kIsolateIndex == 1);
5419 STATIC_ASSERT(FCA::kHolderIndex == 0);
5420 STATIC_ASSERT(FCA::kArgsLength == 7);
5421
5422 Isolate* isolate = masm->isolate();
5423
5424 __ pop(return_address);
5425
5426 // context save
5427 __ push(context);
5428 // load context from callee
5429 __ mov(context, FieldOperand(callee, JSFunction::kContextOffset));
5430
5431 // callee
5432 __ push(callee);
5433
5434 // call data
5435 __ push(call_data);
5436
5437 Register scratch = call_data;
5438 if (!call_data_undefined) {
5439 // return value
5440 __ push(Immediate(isolate->factory()->undefined_value()));
5441 // return value default
5442 __ push(Immediate(isolate->factory()->undefined_value()));
5443 } else {
5444 // return value
5445 __ push(scratch);
5446 // return value default
5447 __ push(scratch);
5448 }
5449 // isolate
5450 __ push(Immediate(reinterpret_cast<int>(isolate)));
5451 // holder
5452 __ push(holder);
5453
5454 __ mov(scratch, esp);
5455
5456 // return address
5457 __ push(return_address);
5458
5459 // API function gets reference to the v8::Arguments. If CPU profiler
5460 // is enabled wrapper function will be called and we need to pass
5461 // address of the callback as additional parameter, always allocate
5462 // space for it.
5463 const int kApiArgc = 1 + 1;
5464
5465 // Allocate the v8::Arguments structure in the arguments' space since
5466 // it's not controlled by GC.
5467 const int kApiStackSpace = 4;
5468
5469 __ PrepareCallApiFunction(kApiArgc + kApiStackSpace);
5470
5471 // FunctionCallbackInfo::implicit_args_.
5472 __ mov(ApiParameterOperand(2), scratch);
5473 __ add(scratch, Immediate((argc + FCA::kArgsLength - 1) * kPointerSize));
5474 // FunctionCallbackInfo::values_.
5475 __ mov(ApiParameterOperand(3), scratch);
5476 // FunctionCallbackInfo::length_.
5477 __ Set(ApiParameterOperand(4), Immediate(argc));
5478 // FunctionCallbackInfo::is_construct_call_.
5479 __ Set(ApiParameterOperand(5), Immediate(0));
5480
5481 // v8::InvocationCallback's argument.
5482 __ lea(scratch, ApiParameterOperand(2));
5483 __ mov(ApiParameterOperand(0), scratch);
5484
5485 Address thunk_address = FUNCTION_ADDR(&InvokeFunctionCallback);
5486
5487 Operand context_restore_operand(ebp,
5488 (2 + FCA::kContextSaveIndex) * kPointerSize);
5489 Operand return_value_operand(ebp,
5490 (2 + FCA::kReturnValueOffset) * kPointerSize);
5491 __ CallApiFunctionAndReturn(api_function_address,
5492 thunk_address,
5493 ApiParameterOperand(1),
5494 argc + FCA::kArgsLength + 1,
5495 return_value_operand,
5496 restore_context ?
5497 &context_restore_operand : NULL);
5498 }
5499
5500
5385 #undef __ 5501 #undef __
5386 5502
5387 } } // namespace v8::internal 5503 } } // namespace v8::internal
5388 5504
5389 #endif // V8_TARGET_ARCH_IA32 5505 #endif // V8_TARGET_ARCH_IA32
OLDNEW
« no previous file with comments | « src/code-stubs.h ('k') | src/ia32/macro-assembler-ia32.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698