Reviewers: Michael Starzinger,

Message:
pls take a look and if you're okay with the approach, i'll extend to keyed loads
and add remaining architectures

Description:
load ics for js api accessors

[email protected]
BUG=

Please review this at https://chromiumcodereview.appspot.com/23699002/

SVN Base: https://v8.googlecode.com/svn/branches/bleeding_edge

Affected files:
  M src/stub-cache.h
  M src/stub-cache.cc
  M src/x64/stub-cache-x64.cc


Index: src/stub-cache.cc
diff --git a/src/stub-cache.cc b/src/stub-cache.cc
index 19cfd5a1a83c7133c3fa8698b325112c0a81a3c9..4c181f3141518f244e7b3c2fa3ff111d5cca7d61 100644
--- a/src/stub-cache.cc
+++ b/src/stub-cache.cc
@@ -324,9 +324,14 @@ Handle<Code> StubCache::ComputeLoadViaGetter(Handle<Name> name,
       name, receiver, stub_holder, Code::LOAD_IC, Code::CALLBACKS);
   if (!stub.is_null()) return stub;

+  Handle<Code> handler;
+  CallOptimization call_opt(getter);
   LoadStubCompiler compiler(isolate_);
-  Handle<Code> handler =
-      compiler.CompileLoadViaGetter(receiver, holder, name, getter);
+  if (call_opt.is_simple_api_call()) {
+ handler = compiler.CompileLoadCallback(receiver, holder, name, call_opt);
+  } else {
+ handler = compiler.CompileLoadViaGetter(receiver, holder, name, getter);
+  }
   JSObject::UpdateMapCodeCache(stub_holder, name, handler);
   return handler;
 }
@@ -1648,6 +1653,25 @@ Handle<Code> BaseLoadStubCompiler::CompileLoadCallback(
 }


+Handle<Code> BaseLoadStubCompiler::CompileLoadCallback(
+    Handle<JSObject> object,
+    Handle<JSObject> holder,
+    Handle<Name> name,
+    const CallOptimization& call_optimization) {
+  ASSERT(call_optimization.is_simple_api_call());
+  Label success;
+
+  Handle<JSFunction> callback = call_optimization.constant_function();
+  Register reg = CallbackHandlerFrontend(
+      object, receiver(), holder, name, &success, callback);
+  __ bind(&success);
+  GenerateLoadCallback(reg, call_optimization);
+
+  // Return the generated code.
+  return GetCode(kind(), Code::CALLBACKS, name);
+}
+
+
 Handle<Code> BaseLoadStubCompiler::CompileLoadInterceptor(
     Handle<JSObject> object,
     Handle<JSObject> holder,
Index: src/stub-cache.h
diff --git a/src/stub-cache.h b/src/stub-cache.h
index 25009b9a66b4e670c2f7809223d343e2e2cf3b61..a9593af104c9d31e02c28f1c524f040565bcc43a 100644
--- a/src/stub-cache.h
+++ b/src/stub-cache.h
@@ -48,6 +48,8 @@ namespace internal {
 // invalidate the cache whenever a prototype map is changed.  The stub
 // validates the map chain as in the mono-morphic case.

+
+class CallOptimization;
 class SmallMapList;
 class StubCache;

@@ -705,6 +707,11 @@ class BaseLoadStubCompiler: public BaseLoadStoreStubCompiler {
                                    Handle<Name> name,
Handle<ExecutableAccessorInfo> callback);

+  Handle<Code> CompileLoadCallback(Handle<JSObject> object,
+                                   Handle<JSObject> holder,
+                                   Handle<Name> name,
+ const CallOptimization& call_optimization);
+
   Handle<Code> CompileLoadConstant(Handle<JSObject> object,
                                    Handle<JSObject> holder,
                                    Handle<Name> name,
@@ -730,7 +737,7 @@ class BaseLoadStubCompiler: public BaseLoadStoreStubCompiler {
                                    Handle<JSObject> holder,
                                    Handle<Name> name,
                                    Label* success,
- Handle<ExecutableAccessorInfo> callback);
+                                   Handle<Object> callback);
   void NonexistentHandlerFrontend(Handle<JSObject> object,
                                   Handle<JSObject> last,
                                   Handle<Name> name,
@@ -744,6 +751,8 @@ class BaseLoadStubCompiler: public BaseLoadStoreStubCompiler {
   void GenerateLoadConstant(Handle<Object> value);
   void GenerateLoadCallback(Register reg,
                             Handle<ExecutableAccessorInfo> callback);
+  void GenerateLoadCallback(Register reg,
+                            const CallOptimization& call_optimization);
   void GenerateLoadInterceptor(Register holder_reg,
                                Handle<JSObject> object,
                                Handle<JSObject> holder,
@@ -1028,8 +1037,6 @@ class KeyedStoreStubCompiler: public BaseStoreStubCompiler {
   V(ArrayCode)


-class CallOptimization;
-
 class CallStubCompiler: public StubCompiler {
  public:
   CallStubCompiler(Isolate* isolate,
Index: src/x64/stub-cache-x64.cc
diff --git a/src/x64/stub-cache-x64.cc b/src/x64/stub-cache-x64.cc
index 55e4a9b129556c070cfc8a3e39b1d9f6bc777864..7faebb06cfd3e8870a02921d7cc793d05e60a2ad 100644
--- a/src/x64/stub-cache-x64.cc
+++ b/src/x64/stub-cache-x64.cc
@@ -1191,7 +1191,7 @@ Register BaseLoadStubCompiler::CallbackHandlerFrontend(
     Handle<JSObject> holder,
     Handle<Name> name,
     Label* success,
-    Handle<ExecutableAccessorInfo> callback) {
+    Handle<Object> callback) {
   Label miss;

Register reg = HandlerFrontendHeader(object, object_reg, holder, name, &miss); @@ -1277,6 +1277,34 @@ void BaseLoadStubCompiler::GenerateLoadField(Register reg,

 void BaseLoadStubCompiler::GenerateLoadCallback(
     Register reg,
+    const CallOptimization& call_optimization) {
+  ASSERT(call_optimization.is_simple_api_call());
+  ASSERT(!scratch3().is(reg));
+  ASSERT(!receiver().is(reg));
+
+  // copy retun value
+  __ movq(scratch3(), StackSpaceOperand(0));
+  // assign stack space for the call arguments
+  __ subq(rsp, Immediate((kFastApiCallArguments + 1) * kPointerSize));
+  // Move the return address on top of the stack.
+  __ movq(StackOperandForReturnAddress(0), scratch3());
+
+  int argc = 0;
+  {
+    int api_call_argc = argc + kFastApiCallArguments;
+    StackArgumentsAccessor args(rsp, api_call_argc);
+    // write holder to stack frame
+    __ movq(args.GetArgumentOperand(api_call_argc), reg);
+    // write receiver to stack frame
+ __ movq(args.GetArgumentOperand(api_call_argc - (argc + 6)), receiver());
+  }
+
+  GenerateFastApiCall(masm(), call_optimization, argc);
+}
+
+
+void BaseLoadStubCompiler::GenerateLoadCallback(
+    Register reg,
     Handle<ExecutableAccessorInfo> callback) {
// Insert additional parameters into the stack frame above return address.
   ASSERT(!scratch4().is(reg));


--
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
--- You received this message because you are subscribed to the Google Groups "v8-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to