Reviewers: Toon Verwaest,

Message:
PTAL

Description:
Handle retry-after-gc failures within LoadIC::Load and StoreIC::Store.

Follow-up for r14321, makes the remaining unsafe calls to runtime functions
during ic computation safe.

[email protected]
BUG=222301

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

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

Affected files:
  M src/accessors.h
  M src/accessors.cc
  M src/ic.cc
  M src/objects.h
  M src/objects.cc
  M src/runtime.h
  M src/runtime.cc


Index: src/accessors.cc
diff --git a/src/accessors.cc b/src/accessors.cc
index 0b0f9b0757252a1852c0cc6203f931680e303b6a..64047a284711927db3c3f2bd9d805a79ece11675 100644
--- a/src/accessors.cc
+++ b/src/accessors.cc
@@ -441,6 +441,13 @@ const AccessorDescriptor Accessors::ScriptEvalFromFunctionName = {
 //


+Handle<Object> Accessors::FunctionGetPrototype(Handle<Object> object) {
+  Isolate* isolate = Isolate::Current();
+  CALL_HEAP_FUNCTION(
+      isolate, Accessors::FunctionGetPrototype(*object, 0), Object);
+}
+
+
 MaybeObject* Accessors::FunctionGetPrototype(Object* object, void*) {
   Isolate* isolate = Isolate::Current();
   JSFunction* function = FindInstanceOf<JSFunction>(isolate, object);
Index: src/accessors.h
diff --git a/src/accessors.h b/src/accessors.h
index 0740d92e56bc962e4a36085bc25a8ba29559ef03..9a83ab8a85ed181ff3616cca18c467dbcbba107c 100644
--- a/src/accessors.h
+++ b/src/accessors.h
@@ -79,6 +79,8 @@ class Accessors : public AllStatic {
   // Accessor functions called directly from the runtime system.
   MUST_USE_RESULT static MaybeObject* FunctionGetPrototype(Object* object,
                                                            void*);
+  static Handle<Object> FunctionGetPrototype(Handle<Object> object);
+
MUST_USE_RESULT static MaybeObject* FunctionSetPrototype(JSObject* object,
                                                       Object* value,
                                                       void*);
Index: src/ic.cc
diff --git a/src/ic.cc b/src/ic.cc
index 78fb29753c4a08e2b4b52a4c6538fea5b17a848d..c512a862c2fb45d948452865581c0452af72332d 100644
--- a/src/ic.cc
+++ b/src/ic.cc
@@ -877,7 +877,7 @@ MaybeObject* LoadIC::Load(State state,
         if (FLAG_trace_ic) PrintF("[LoadIC : +#prototype /function]\n");
 #endif
       }
-      return Accessors::FunctionGetPrototype(*object, 0);
+      return *Accessors::FunctionGetPrototype(object);
     }
   }

@@ -887,7 +887,7 @@ MaybeObject* LoadIC::Load(State state,
   if (kind() == Code::KEYED_LOAD_IC && name->AsArrayIndex(&index)) {
     // Rewrite to the generic keyed load stub.
     if (FLAG_use_ic) set_target(*generic_stub());
-    return Runtime::GetElementOrCharAt(isolate(), object, index);
+    return Runtime::GetElementOrCharAtOrFail(isolate(), object, index);
   }

   // Named lookup in the object.
@@ -922,7 +922,7 @@ MaybeObject* LoadIC::Load(State state,
   }

   // Get the property.
-  return object->GetProperty(*object, &lookup, *name, &attr);
+  return Object::GetPropertyOrFail(object, object, &lookup, name, &attr);
 }


@@ -1476,8 +1476,8 @@ MaybeObject* StoreIC::Store(State state,
                             JSReceiver::StoreFromKeyed store_mode) {
   // Handle proxies.
   if (object->IsJSProxy()) {
-    return JSProxy::cast(*object)->
-        SetProperty(*name, *value, NONE, strict_mode);
+    return JSReceiver::SetPropertyOrFail(
+        Handle<JSReceiver>::cast(object), name, value, NONE, strict_mode);
   }

   // If the object is undefined or null it's illegal to try to set any
@@ -1509,7 +1509,8 @@ MaybeObject* StoreIC::Store(State state,

   // Observed objects are always modified through the runtime.
   if (FLAG_harmony_observation && receiver->map()->is_observed()) {
- return receiver->SetProperty(*name, *value, NONE, strict_mode, store_mode);
+    return JSReceiver::SetPropertyOrFail(
+        receiver, name, value, NONE, strict_mode, store_mode);
   }

   // Use specialized code for setting the length of arrays with fast
@@ -1524,7 +1525,8 @@ MaybeObject* StoreIC::Store(State state,
         StoreArrayLengthStub(kind(), strict_mode).GetCode(isolate());
     set_target(*stub);
     TRACE_IC("StoreIC", name, state, *stub);
- return receiver->SetProperty(*name, *value, NONE, strict_mode, store_mode);
+    return JSReceiver::SetPropertyOrFail(
+        receiver, name, value, NONE, strict_mode, store_mode);
   }

   if (receiver->IsJSGlobalProxy()) {
@@ -1537,7 +1539,8 @@ MaybeObject* StoreIC::Store(State state,
       set_target(*stub);
       TRACE_IC("StoreIC", name, state, *stub);
     }
- return receiver->SetProperty(*name, *value, NONE, strict_mode, store_mode);
+    return JSReceiver::SetPropertyOrFail(
+        receiver, name, value, NONE, strict_mode, store_mode);
   }

   LookupResult lookup(isolate());
@@ -1553,7 +1556,8 @@ MaybeObject* StoreIC::Store(State state,
   }

   // Set the property.
- return receiver->SetProperty(*name, *value, NONE, strict_mode, store_mode);
+  return JSReceiver::SetPropertyOrFail(
+      receiver, name, value, NONE, strict_mode, store_mode);
 }


Index: src/objects.cc
diff --git a/src/objects.cc b/src/objects.cc
index 33be173a56aecfa96e3ee6392dfb81b0e18a7520..dc7a36fa319620d03c93e3636e8902494ef562d7 100644
--- a/src/objects.cc
+++ b/src/objects.cc
@@ -745,6 +745,20 @@ Handle<Object> Object::GetProperty(Handle<Object> object,
 }


+MaybeObject* Object::GetPropertyOrFail(Handle<Object> object,
+                                       Handle<Object> receiver,
+                                       LookupResult* result,
+                                       Handle<Name> key,
+                                       PropertyAttributes* attributes) {
+  Isolate* isolate = object->IsHeapObject()
+      ? Handle<HeapObject>::cast(object)->GetIsolate()
+      : Isolate::Current();
+  CALL_HEAP_FUNCTION_PASS_EXCEPTION(
+      isolate,
+      object->GetProperty(*receiver, result, *key, attributes));
+}
+
+
 MaybeObject* Object::GetProperty(Object* receiver,
                                  LookupResult* result,
                                  Name* name,
@@ -2139,6 +2153,19 @@ Handle<Object> JSReceiver::SetProperty(Handle<JSReceiver> object,
 }


+MaybeObject* JSReceiver::SetPropertyOrFail(
+    Handle<JSReceiver> object,
+    Handle<Name> key,
+    Handle<Object> value,
+    PropertyAttributes attributes,
+    StrictModeFlag strict_mode,
+    JSReceiver::StoreFromKeyed store_mode) {
+  CALL_HEAP_FUNCTION_PASS_EXCEPTION(
+      object->GetIsolate(),
+ object->SetProperty(*key, *value, attributes, strict_mode, store_mode));
+}
+
+
 MaybeObject* JSReceiver::SetProperty(Name* name,
                                      Object* value,
                                      PropertyAttributes attributes,
Index: src/objects.h
diff --git a/src/objects.h b/src/objects.h
index 3230559ac3da46662f5226b71fc758cfad0484cc..998185575bc3466a79e61db54e0bb92943982e11 100644
--- a/src/objects.h
+++ b/src/objects.h
@@ -1096,11 +1096,19 @@ class Object : public MaybeObject {
                                     Handle<Name> key,
                                     PropertyAttributes* attributes);

+  MUST_USE_RESULT static MaybeObject* GetPropertyOrFail(
+      Handle<Object> object,
+      Handle<Object> receiver,
+      LookupResult* result,
+      Handle<Name> key,
+      PropertyAttributes* attributes);
+
   MUST_USE_RESULT MaybeObject* GetProperty(Object* receiver,
                                            LookupResult* result,
                                            Name* key,
                                            PropertyAttributes* attributes);

+
MUST_USE_RESULT MaybeObject* GetPropertyWithDefinedGetter(Object* receiver, JSReceiver* getter);

@@ -1569,6 +1577,15 @@ class JSReceiver: public HeapObject {
                                     Handle<Object> value,
                                     PropertyAttributes attributes,
                                     StrictModeFlag strict_mode);
+
+  MUST_USE_RESULT static MaybeObject* SetPropertyOrFail(
+      Handle<JSReceiver> object,
+      Handle<Name> key,
+      Handle<Object> value,
+      PropertyAttributes attributes,
+      StrictModeFlag strict_mode,
+      StoreFromKeyed store_from_keyed = MAY_BE_STORE_FROM_KEYED);
+
   // Can cause GC.
   MUST_USE_RESULT MaybeObject* SetProperty(
       Name* key,
Index: src/runtime.cc
diff --git a/src/runtime.cc b/src/runtime.cc
index 6261c12a9756ccf6620c8fb41ab45430457a0e1b..1cb96c6bc46dfa59f9ab39af79a3bdd9850d1314 100644
--- a/src/runtime.cc
+++ b/src/runtime.cc
@@ -4043,6 +4043,14 @@ static Handle<Object> GetCharAt(Handle<String> string, uint32_t index) {
 }


+MaybeObject* Runtime::GetElementOrCharAtOrFail(Isolate* isolate,
+                                               Handle<Object> object,
+                                               uint32_t index) {
+  CALL_HEAP_FUNCTION_PASS_EXCEPTION(isolate,
+      GetElementOrCharAt(isolate, object, index));
+}
+
+
 MaybeObject* Runtime::GetElementOrCharAt(Isolate* isolate,
                                          Handle<Object> object,
                                          uint32_t index) {
Index: src/runtime.h
diff --git a/src/runtime.h b/src/runtime.h
index 14133511eaa0183f5b5233512275b13ce49d629b..2252960b15536e50ec5e495d62780bbad7596f2b 100644
--- a/src/runtime.h
+++ b/src/runtime.h
@@ -694,6 +694,11 @@ class Runtime : public AllStatic {
Handle<Object> object,
                                                          uint32_t index);

+  MUST_USE_RESULT static MaybeObject* GetElementOrCharAtOrFail(
+      Isolate* isolate,
+      Handle<Object> object,
+      uint32_t index);
+
   MUST_USE_RESULT static MaybeObject* SetObjectProperty(
       Isolate* isolate,
       Handle<Object> object,


--
--
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