Commit 82fc8fe3 authored by serya@chromium.org's avatar serya@chromium.org

Direct call API functions (ia32 implementation).

Review URL: http://codereview.chromium.org/4456002

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@5791 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent 8ebe8e47
...@@ -542,7 +542,7 @@ class ApiGetterEntryStub : public CodeStub { ...@@ -542,7 +542,7 @@ class ApiGetterEntryStub : public CodeStub {
ApiFunction* fun() { return fun_; } ApiFunction* fun() { return fun_; }
Major MajorKey() { return NoCache; } Major MajorKey() { return NoCache; }
int MinorKey() { return 0; } int MinorKey() { return 0; }
const char* GetName() { return "ApiEntryStub"; } const char* GetName() { return "ApiGetterEntryStub"; }
// The accessor info associated with the function. // The accessor info associated with the function.
Handle<AccessorInfo> info_; Handle<AccessorInfo> info_;
// The function to be called. // The function to be called.
...@@ -550,6 +550,32 @@ class ApiGetterEntryStub : public CodeStub { ...@@ -550,6 +550,32 @@ class ApiGetterEntryStub : public CodeStub {
}; };
class ApiCallEntryStub : public CodeStub {
public:
ApiCallEntryStub(Handle<CallHandlerInfo> info,
ApiFunction* fun)
: info_(info),
fun_(fun) { }
void Generate(MacroAssembler* masm);
virtual bool has_custom_cache() { return true; }
virtual bool GetCustomCache(Code** code_out);
virtual void SetCustomCache(Code* value);
static const int kStackSpace = 0;
static const int kArgc = 5;
private:
Handle<CallHandlerInfo> info() { return info_; }
ApiFunction* fun() { return fun_; }
Major MajorKey() { return NoCache; }
int MinorKey() { return 0; }
const char* GetName() { return "ApiCallEntryStub"; }
// The call handler info associated with the function.
Handle<CallHandlerInfo> info_;
// The function to be called.
ApiFunction* fun_;
};
class JSEntryStub : public CodeStub { class JSEntryStub : public CodeStub {
public: public:
JSEntryStub() { } JSEntryStub() { }
......
...@@ -482,8 +482,8 @@ int CEntryStub::MinorKey() { ...@@ -482,8 +482,8 @@ int CEntryStub::MinorKey() {
} }
bool ApiGetterEntryStub::GetCustomCache(Code** code_out) { // Implementation of CodeStub::GetCustomCache.
Object* cache = info()->load_stub_cache(); static bool GetCustomCacheHelper(Object* cache, Code** code_out) {
if (cache->IsUndefined()) { if (cache->IsUndefined()) {
return false; return false;
} else { } else {
...@@ -493,9 +493,24 @@ bool ApiGetterEntryStub::GetCustomCache(Code** code_out) { ...@@ -493,9 +493,24 @@ bool ApiGetterEntryStub::GetCustomCache(Code** code_out) {
} }
bool ApiGetterEntryStub::GetCustomCache(Code** code_out) {
return GetCustomCacheHelper(info()->load_stub_cache(), code_out);
}
void ApiGetterEntryStub::SetCustomCache(Code* value) { void ApiGetterEntryStub::SetCustomCache(Code* value) {
info()->set_load_stub_cache(value); info()->set_load_stub_cache(value);
} }
bool ApiCallEntryStub::GetCustomCache(Code** code_out) {
return GetCustomCacheHelper(info()->call_stub_cache(), code_out);
}
void ApiCallEntryStub::SetCustomCache(Code* value) {
info()->set_call_stub_cache(value);
}
} } // namespace v8::internal } } // namespace v8::internal
...@@ -521,7 +521,6 @@ class Assembler : public Malloced { ...@@ -521,7 +521,6 @@ class Assembler : public Malloced {
void push(const Immediate& x); void push(const Immediate& x);
void push(Register src); void push(Register src);
void push(const Operand& src); void push(const Operand& src);
void push(Label* label, RelocInfo::Mode relocation_mode);
void pop(Register dst); void pop(Register dst);
void pop(const Operand& dst); void pop(const Operand& dst);
......
...@@ -3067,6 +3067,26 @@ void ApiGetterEntryStub::Generate(MacroAssembler* masm) { ...@@ -3067,6 +3067,26 @@ void ApiGetterEntryStub::Generate(MacroAssembler* masm) {
} }
void ApiCallEntryStub::Generate(MacroAssembler* masm) {
__ PrepareCallApiFunction(kStackSpace, kArgc);
STATIC_ASSERT(kArgc == 5);
// Allocate the v8::Arguments structure in the arguments' space since
// it's not controlled by GC.
__ mov(ApiParameterOperand(1), eax); // v8::Arguments::implicit_args_.
__ mov(ApiParameterOperand(2), ebx); // v8::Arguments::values_.
__ mov(ApiParameterOperand(3), edx); // v8::Arguments::length_.
// v8::Arguments::is_construct_call_.
__ mov(ApiParameterOperand(4), Immediate(0));
// v8::InvocationCallback's argument.
__ lea(eax, ApiParameterOperand(1));
__ mov(ApiParameterOperand(0), eax);
__ CallApiFunctionAndReturn(fun(), kArgc);
}
void CEntryStub::GenerateCore(MacroAssembler* masm, void CEntryStub::GenerateCore(MacroAssembler* masm,
Label* throw_normal_exception, Label* throw_normal_exception,
Label* throw_termination_exception, Label* throw_termination_exception,
......
...@@ -488,7 +488,7 @@ class MacroAssembler: public Assembler { ...@@ -488,7 +488,7 @@ class MacroAssembler: public Assembler {
// stored in ApiParameterOperand(0), ApiParameterOperand(1) etc. // stored in ApiParameterOperand(0), ApiParameterOperand(1) etc.
void PrepareCallApiFunction(int stack_space, int argc); void PrepareCallApiFunction(int stack_space, int argc);
// Tail call an API function (jump). Allocates HandleScope, extracts // Calls an API function. Allocates HandleScope, extracts
// returned value from handle and propagates exceptions. // returned value from handle and propagates exceptions.
// Clobbers ebx, esi, edi and caller-save registers. // Clobbers ebx, esi, edi and caller-save registers.
void CallApiFunctionAndReturn(ApiFunction* function, int argc); void CallApiFunctionAndReturn(ApiFunction* function, int argc);
......
This diff is collapsed.
...@@ -997,6 +997,8 @@ void AccessorInfo::AccessorInfoPrint() { ...@@ -997,6 +997,8 @@ void AccessorInfo::AccessorInfoPrint() {
data()->ShortPrint(); data()->ShortPrint();
PrintF("\n - flag: "); PrintF("\n - flag: ");
flag()->ShortPrint(); flag()->ShortPrint();
PrintF("\n - load_stub_cache: ");
load_stub_cache()->ShortPrint();
} }
void AccessCheckInfo::AccessCheckInfoVerify() { void AccessCheckInfo::AccessCheckInfoVerify() {
...@@ -1046,6 +1048,7 @@ void CallHandlerInfo::CallHandlerInfoVerify() { ...@@ -1046,6 +1048,7 @@ void CallHandlerInfo::CallHandlerInfoVerify() {
CHECK(IsCallHandlerInfo()); CHECK(IsCallHandlerInfo());
VerifyPointer(callback()); VerifyPointer(callback());
VerifyPointer(data()); VerifyPointer(data());
VerifyPointer(call_stub_cache());
} }
void CallHandlerInfo::CallHandlerInfoPrint() { void CallHandlerInfo::CallHandlerInfoPrint() {
...@@ -1054,6 +1057,8 @@ void CallHandlerInfo::CallHandlerInfoPrint() { ...@@ -1054,6 +1057,8 @@ void CallHandlerInfo::CallHandlerInfoPrint() {
callback()->ShortPrint(); callback()->ShortPrint();
PrintF("\n - data: "); PrintF("\n - data: ");
data()->ShortPrint(); data()->ShortPrint();
PrintF("\n - call_stub_cache: ");
call_stub_cache()->ShortPrint();
} }
void TemplateInfo::TemplateInfoVerify() { void TemplateInfo::TemplateInfoVerify() {
......
...@@ -2557,6 +2557,7 @@ ACCESSORS(InterceptorInfo, data, Object, kDataOffset) ...@@ -2557,6 +2557,7 @@ ACCESSORS(InterceptorInfo, data, Object, kDataOffset)
ACCESSORS(CallHandlerInfo, callback, Object, kCallbackOffset) ACCESSORS(CallHandlerInfo, callback, Object, kCallbackOffset)
ACCESSORS(CallHandlerInfo, data, Object, kDataOffset) ACCESSORS(CallHandlerInfo, data, Object, kDataOffset)
ACCESSORS(CallHandlerInfo, call_stub_cache, Object, kCallStubCacheOffset)
ACCESSORS(TemplateInfo, tag, Object, kTagOffset) ACCESSORS(TemplateInfo, tag, Object, kTagOffset)
ACCESSORS(TemplateInfo, property_list, Object, kPropertyListOffset) ACCESSORS(TemplateInfo, property_list, Object, kPropertyListOffset)
......
...@@ -5423,6 +5423,7 @@ class CallHandlerInfo: public Struct { ...@@ -5423,6 +5423,7 @@ class CallHandlerInfo: public Struct {
public: public:
DECL_ACCESSORS(callback, Object) DECL_ACCESSORS(callback, Object)
DECL_ACCESSORS(data, Object) DECL_ACCESSORS(data, Object)
DECL_ACCESSORS(call_stub_cache, Object)
static inline CallHandlerInfo* cast(Object* obj); static inline CallHandlerInfo* cast(Object* obj);
...@@ -5433,7 +5434,8 @@ class CallHandlerInfo: public Struct { ...@@ -5433,7 +5434,8 @@ class CallHandlerInfo: public Struct {
static const int kCallbackOffset = HeapObject::kHeaderSize; static const int kCallbackOffset = HeapObject::kHeaderSize;
static const int kDataOffset = kCallbackOffset + kPointerSize; static const int kDataOffset = kCallbackOffset + kPointerSize;
static const int kSize = kDataOffset + kPointerSize; static const int kCallStubCacheOffset = kDataOffset + kPointerSize;
static const int kSize = kCallStubCacheOffset + kPointerSize;
private: private:
DISALLOW_IMPLICIT_CONSTRUCTORS(CallHandlerInfo); DISALLOW_IMPLICIT_CONSTRUCTORS(CallHandlerInfo);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment