Revision: 20914
Author:   [email protected]
Date:     Wed Apr 23 15:08:03 2014 UTC
Log:      Clean up some uses of Failures and MaybeObjects.

[email protected]

Review URL: https://codereview.chromium.org/245963007
http://code.google.com/p/v8/source/detail?r=20914

Modified:
 /branches/bleeding_edge/src/accessors.cc
 /branches/bleeding_edge/src/accessors.h
 /branches/bleeding_edge/src/execution.cc
 /branches/bleeding_edge/src/heap.cc
 /branches/bleeding_edge/src/ia32/macro-assembler-ia32.h
 /branches/bleeding_edge/src/objects-inl.h
 /branches/bleeding_edge/src/objects.h
 /branches/bleeding_edge/src/spaces.cc
 /branches/bleeding_edge/src/spaces.h
 /branches/bleeding_edge/src/stub-cache.h
 /branches/bleeding_edge/src/v8globals.h
 /branches/bleeding_edge/src/x64/macro-assembler-x64.h
 /branches/bleeding_edge/test/cctest/test-alloc.cc
 /branches/bleeding_edge/test/cctest/test-heap.cc

=======================================
--- /branches/bleeding_edge/src/accessors.cc    Tue Apr 22 12:50:58 2014 UTC
+++ /branches/bleeding_edge/src/accessors.cc    Wed Apr 23 15:08:03 2014 UTC
@@ -73,10 +73,10 @@


 // Entry point that never should be called.
-MaybeObject* Accessors::IllegalSetter(Isolate* isolate,
-                                      JSObject*,
-                                      Object*,
-                                      void*) {
+Object* Accessors::IllegalSetter(Isolate* isolate,
+                                 JSObject*,
+                                 Object*,
+                                 void*) {
   UNREACHABLE();
   return NULL;
 }
@@ -90,10 +90,10 @@
 }


-MaybeObject* Accessors::ReadOnlySetAccessor(Isolate* isolate,
-                                            JSObject*,
-                                            Object* value,
-                                            void*) {
+Object* Accessors::ReadOnlySetAccessor(Isolate* isolate,
+                                       JSObject*,
+                                       Object* value,
+                                       void*) {
   // According to ECMA-262, section 8.6.2.2, page 28, setting
   // read-only properties must be silently ignored.
   return value;
@@ -174,9 +174,9 @@
 //


-MaybeObject* Accessors::ArrayGetLength(Isolate* isolate,
-                                       Object* object,
-                                       void*) {
+Object* Accessors::ArrayGetLength(Isolate* isolate,
+                                  Object* object,
+                                  void*) {
   // Traverse the prototype chain until we reach an array.
   JSArray* holder = FindInstanceOf<JSArray>(isolate, object);
   return holder == NULL ? Smi::FromInt(0) : holder->length();
@@ -199,10 +199,10 @@
 }


-MaybeObject* Accessors::ArraySetLength(Isolate* isolate,
-                                       JSObject* object_raw,
-                                       Object* value_raw,
-                                       void*) {
+Object* Accessors::ArraySetLength(Isolate* isolate,
+                                  JSObject* object_raw,
+                                  Object* value_raw,
+                                  void*) {
   HandleScope scope(isolate);
   Handle<JSObject> object(object_raw, isolate);
   Handle<Object> value(value_raw, isolate);
@@ -851,18 +851,18 @@
 }


-MaybeObject* Accessors::FunctionGetPrototype(Isolate* isolate,
-                                             Object* object,
-                                             void*) {
+Object* Accessors::FunctionGetPrototype(Isolate* isolate,
+                                        Object* object,
+                                        void*) {
   HandleScope scope(isolate);
   return *GetFunctionPrototype(isolate, Handle<Object>(object, isolate));
 }


-MaybeObject* Accessors::FunctionSetPrototype(Isolate* isolate,
-                                             JSObject* object,
-                                             Object* value,
-                                             void*) {
+Object* Accessors::FunctionSetPrototype(Isolate* isolate,
+                                        JSObject* object,
+                                        Object* value,
+                                        void*) {
   Handle<Object> result;
   ASSIGN_RETURN_FAILURE_ON_EXCEPTION(
       isolate, result,
@@ -885,9 +885,9 @@
 //


-MaybeObject* Accessors::FunctionGetLength(Isolate* isolate,
-                                          Object* object,
-                                          void*) {
+Object* Accessors::FunctionGetLength(Isolate* isolate,
+                                     Object* object,
+                                     void*) {
   JSFunction* function = FindInstanceOf<JSFunction>(isolate, object);
   if (function == NULL) return Smi::FromInt(0);
   // Check if already compiled.
@@ -917,9 +917,9 @@
 //


-MaybeObject* Accessors::FunctionGetName(Isolate* isolate,
-                                        Object* object,
-                                        void*) {
+Object* Accessors::FunctionGetName(Isolate* isolate,
+                                   Object* object,
+                                   void*) {
   JSFunction* holder = FindInstanceOf<JSFunction>(isolate, object);
   return holder == NULL
       ? isolate->heap()->undefined_value()
@@ -948,7 +948,7 @@
 }


-static MaybeObject* ConstructArgumentsObjectForInlinedFunction(
+static Object* ConstructArgumentsObjectForInlinedFunction(
     JavaScriptFrame* frame,
     Handle<JSFunction> inlined_function,
     int inlined_frame_index) {
@@ -976,9 +976,9 @@
 }


-MaybeObject* Accessors::FunctionGetArguments(Isolate* isolate,
-                                             Object* object,
-                                             void*) {
+Object* Accessors::FunctionGetArguments(Isolate* isolate,
+                                        Object* object,
+                                        void*) {
   HandleScope scope(isolate);
   JSFunction* holder = FindInstanceOf<JSFunction>(isolate, object);
   if (holder == NULL) return isolate->heap()->undefined_value();
@@ -1100,9 +1100,9 @@
 };


-MaybeObject* Accessors::FunctionGetCaller(Isolate* isolate,
-                                          Object* object,
-                                          void*) {
+Object* Accessors::FunctionGetCaller(Isolate* isolate,
+                                     Object* object,
+                                     void*) {
   HandleScope scope(isolate);
   DisallowHeapAllocation no_allocation;
   JSFunction* holder = FindInstanceOf<JSFunction>(isolate, object);
=======================================
--- /branches/bleeding_edge/src/accessors.h     Wed Apr 16 14:30:58 2014 UTC
+++ /branches/bleeding_edge/src/accessors.h     Wed Apr 23 15:08:03 2014 UTC
@@ -115,40 +115,40 @@

  private:
   // Accessor functions only used through the descriptor.
-  static MaybeObject* FunctionSetPrototype(Isolate* isolate,
-                                           JSObject* object,
-                                           Object*,
-                                           void*);
-  static MaybeObject* FunctionGetPrototype(Isolate* isolate,
-                                           Object* object,
-                                           void*);
-  static MaybeObject* FunctionGetLength(Isolate* isolate,
-                                        Object* object,
-                                        void*);
- static MaybeObject* FunctionGetName(Isolate* isolate, Object* object, void*);
-  static MaybeObject* FunctionGetArguments(Isolate* isolate,
-                                           Object* object,
-                                           void*);
-  static MaybeObject* FunctionGetCaller(Isolate* isolate,
-                                        Object* object,
-                                        void*);
-  static MaybeObject* ArraySetLength(Isolate* isolate,
-                                     JSObject* object,
-                                     Object*,
-                                     void*);
- static MaybeObject* ArrayGetLength(Isolate* isolate, Object* object, void*);
+  static Object* FunctionSetPrototype(Isolate* isolate,
+                                      JSObject* object,
+                                      Object*,
+                                      void*);
+  static Object* FunctionGetPrototype(Isolate* isolate,
+                                      Object* object,
+                                      void*);
+  static Object* FunctionGetLength(Isolate* isolate,
+                                   Object* object,
+                                   void*);
+  static Object* FunctionGetName(Isolate* isolate, Object* object, void*);
+  static Object* FunctionGetArguments(Isolate* isolate,
+                                      Object* object,
+                                      void*);
+  static Object* FunctionGetCaller(Isolate* isolate,
+                                   Object* object,
+                                   void*);
+  static Object* ArraySetLength(Isolate* isolate,
+                                JSObject* object,
+                                Object*,
+                                void*);
+  static Object* ArrayGetLength(Isolate* isolate, Object* object, void*);

   // Helper functions.
static Handle<Object> FlattenNumber(Isolate* isolate, Handle<Object> value);
-  static MaybeObject* IllegalSetter(Isolate* isolate,
-                                    JSObject*,
-                                    Object*,
-                                    void*);
+  static Object* IllegalSetter(Isolate* isolate,
+                               JSObject*,
+                               Object*,
+                               void*);
static Object* IllegalGetAccessor(Isolate* isolate, Object* object, void*);
-  static MaybeObject* ReadOnlySetAccessor(Isolate* isolate,
-                                          JSObject*,
-                                          Object* value,
-                                          void*);
+  static Object* ReadOnlySetAccessor(Isolate* isolate,
+                                     JSObject*,
+                                     Object* value,
+                                     void*);
 };

 } }  // namespace v8::internal
=======================================
--- /branches/bleeding_edge/src/execution.cc    Tue Apr 22 12:50:58 2014 UTC
+++ /branches/bleeding_edge/src/execution.cc    Wed Apr 23 15:08:03 2014 UTC
@@ -114,7 +114,7 @@
     isolate->clear_pending_message();
   }

-  return Handle<Object>(value->ToObjectUnchecked(), isolate);
+  return Handle<Object>(value, isolate);
 }


=======================================
--- /branches/bleeding_edge/src/heap.cc Tue Apr 22 12:50:58 2014 UTC
+++ /branches/bleeding_edge/src/heap.cc Wed Apr 23 15:08:03 2014 UTC
@@ -4531,7 +4531,7 @@
 #undef MAKE_CASE
     default:
       UNREACHABLE();
-      return Failure::InternalError();
+      return exception();
   }
   int size = map->instance_size();
   AllocationSpace space = SelectSpace(size, OLD_POINTER_SPACE, TENURED);
=======================================
--- /branches/bleeding_edge/src/ia32/macro-assembler-ia32.h Mon Mar 24 13:00:05 2014 UTC +++ /branches/bleeding_edge/src/ia32/macro-assembler-ia32.h Wed Apr 23 15:08:03 2014 UTC
@@ -1012,13 +1012,6 @@
                                  Register scratch,
                                  AllocationFlags flags);

-  // Helper for PopHandleScope.  Allowed to perform a GC and returns
-  // NULL if gc_allowed.  Does not perform a GC if !gc_allowed, and
-  // possibly returns a failure object indicating an allocation failure.
-  MUST_USE_RESULT MaybeObject* PopHandleScopeHelper(Register saved,
-                                                    Register scratch,
-                                                    bool gc_allowed);
-
   // Helper for implementing JumpIfNotInNewSpace and JumpIfInNewSpace.
   void InNewSpace(Register object,
                   Register scratch,
=======================================
--- /branches/bleeding_edge/src/objects-inl.h   Wed Apr 23 07:07:54 2014 UTC
+++ /branches/bleeding_edge/src/objects-inl.h   Wed Apr 23 15:08:03 2014 UTC
@@ -659,11 +659,6 @@
   return HAS_FAILURE_TAG(this)
     && Failure::cast(this)->type() == Failure::RETRY_AFTER_GC;
 }
-
-
-bool MaybeObject::IsException() {
-  return this == Failure::Exception();
-}


 Failure* Failure::cast(MaybeObject* obj) {
@@ -1295,16 +1290,6 @@
   return static_cast<AllocationSpace>((value() >> kFailureTypeTagSize)
                                       & kSpaceTagMask);
 }
-
-
-Failure* Failure::InternalError() {
-  return Construct(INTERNAL_ERROR);
-}
-
-
-Failure* Failure::Exception() {
-  return Construct(EXCEPTION);
-}


 intptr_t Failure::value() const {
=======================================
--- /branches/bleeding_edge/src/objects.h       Wed Apr 23 08:58:41 2014 UTC
+++ /branches/bleeding_edge/src/objects.h       Wed Apr 23 15:08:03 2014 UTC
@@ -929,7 +929,6 @@
  public:
   inline bool IsFailure();
   inline bool IsRetryAfterGC();
-  inline bool IsException();
   inline bool ToObject(Object** obj) {
     if (IsFailure()) return false;
     *obj = reinterpret_cast<Object*>(this);
@@ -1665,9 +1664,8 @@
 };


-// Failure is used for reporting out of memory situations and
-// propagating exceptions through the runtime system.  Failure objects
-// are transient and cannot occur as part of the object graph.
+// Failure is mainly used for reporting a situation requiring a GC.
+// Failure objects are transient and cannot occur as part of the object graph.
 //
 // Failures are a single word, encoded as follows:
 // +-------------------------+---+--+--+
@@ -1679,9 +1677,6 @@
 // The low two bits, 0-1, are the failure tag, 11.  The next two bits,
 // 2-3, are a failure type tag 'tt' with possible values:
 //   00 RETRY_AFTER_GC
-//   01 EXCEPTION
-//   10 INTERNAL_ERROR
-//   11 OUT_OF_MEMORY_EXCEPTION
 //
 // The next three bits, 4-6, are an allocation space tag 'sss'.  The
 // allocation space tag is 000 for all failure types except
@@ -1694,13 +1689,8 @@

 class Failure: public MaybeObject {
  public:
-  // RuntimeStubs assumes EXCEPTION = 1 in the compiler-generated code.
   enum Type {
-    RETRY_AFTER_GC = 0,
-    EXCEPTION = 1,       // Returning this marker tells the real exception
-                         // is in Isolate::pending_exception.
-    INTERNAL_ERROR = 2,
-    OUT_OF_MEMORY_EXCEPTION = 3
+    RETRY_AFTER_GC = 0
   };

   inline Type type() const;
@@ -1710,8 +1700,6 @@

   static inline Failure* RetryAfterGC(AllocationSpace space);
   static inline Failure* RetryAfterGC();  // NEW_SPACE
-  static inline Failure* Exception();
-  static inline Failure* InternalError();
   // Casting.
   static inline Failure* cast(MaybeObject* object);

=======================================
--- /branches/bleeding_edge/src/spaces.cc       Wed Apr 16 21:57:48 2014 UTC
+++ /branches/bleeding_edge/src/spaces.cc       Wed Apr 23 15:08:03 2014 UTC
@@ -1005,11 +1005,11 @@
 }


-MaybeObject* PagedSpace::FindObject(Address addr) {
+Object* PagedSpace::FindObject(Address addr) {
   // Note: this function can only be called on precisely swept spaces.
   ASSERT(!heap()->mark_compact_collector()->in_use());

-  if (!Contains(addr)) return Failure::Exception();
+  if (!Contains(addr)) return Smi::FromInt(0);  // Signaling not found.

   Page* p = Page::FromAddress(addr);
   HeapObjectIterator it(p, NULL);
@@ -1020,7 +1020,7 @@
   }

   UNREACHABLE();
-  return Failure::Exception();
+  return Smi::FromInt(0);
 }


@@ -3015,12 +3015,12 @@


 // GC support
-MaybeObject* LargeObjectSpace::FindObject(Address a) {
+Object* LargeObjectSpace::FindObject(Address a) {
   LargePage* page = FindPage(a);
   if (page != NULL) {
     return page->GetObject();
   }
-  return Failure::Exception();
+  return Smi::FromInt(0);  // Signaling not found.
 }


@@ -3101,7 +3101,7 @@

   bool owned = (chunk->owner() == this);

-  SLOW_ASSERT(!owned || !FindObject(address)->IsFailure());
+  SLOW_ASSERT(!owned || FindObject(address)->IsHeapObject());

   return owned;
 }
=======================================
--- /branches/bleeding_edge/src/spaces.h        Wed Apr  9 12:45:56 2014 UTC
+++ /branches/bleeding_edge/src/spaces.h        Wed Apr 23 15:08:03 2014 UTC
@@ -1722,10 +1722,10 @@
   bool Contains(HeapObject* o) { return Contains(o->address()); }

// Given an address occupied by a live object, return that object if it is - // in this space, or Failure::Exception() if it is not. The implementation
-  // iterates over objects in the page containing the address, the cost is
-  // linear in the number of objects in the page. It may be slow.
-  MUST_USE_RESULT MaybeObject* FindObject(Address addr);
+ // in this space, or a Smi if it is not. The implementation iterates over
+  // objects in the page containing the address, the cost is linear in the
+  // number of objects in the page.  It may be slow.
+  Object* FindObject(Address addr);

   // During boot the free_space_map is created, and afterwards we may need
   // to write it into the free list nodes that were already created.
@@ -2841,10 +2841,9 @@
     return page_count_;
   }

-  // Finds an object for a given address, returns Failure::Exception()
-  // if it is not found. The function iterates through all objects in this
-  // space, may be slow.
-  MaybeObject* FindObject(Address a);
+  // Finds an object for a given address, returns a Smi if it is not found.
+  // The function iterates through all objects in this space, may be slow.
+  Object* FindObject(Address a);

   // Finds a large object page containing the given address, returns NULL
   // if such a page doesn't exist.
@@ -2872,7 +2871,7 @@
 #endif
   // Checks whether an address is in the object area in this space.  It
   // iterates all objects in the space. May be slow.
- bool SlowContains(Address addr) { return !FindObject(addr)->IsFailure(); } + bool SlowContains(Address addr) { return FindObject(addr)->IsHeapObject(); }

  private:
   intptr_t max_capacity_;
=======================================
--- /branches/bleeding_edge/src/stub-cache.h    Tue Apr 22 12:50:58 2014 UTC
+++ /branches/bleeding_edge/src/stub-cache.h    Wed Apr 23 15:08:03 2014 UTC
@@ -432,7 +432,6 @@
   Isolate* isolate_;
   const ExtraICState extra_ic_state_;
   MacroAssembler masm_;
-  Failure* failure_;
 };


=======================================
--- /branches/bleeding_edge/src/v8globals.h     Fri Apr  4 16:18:59 2014 UTC
+++ /branches/bleeding_edge/src/v8globals.h     Wed Apr 23 15:08:03 2014 UTC
@@ -349,8 +349,8 @@

 // AccessorCallback
 struct AccessorDescriptor {
-  MaybeObject* (*getter)(Isolate* isolate, Object* object, void* data);
-  MaybeObject* (*setter)(
+  Object* (*getter)(Isolate* isolate, Object* object, void* data);
+  Object* (*setter)(
       Isolate* isolate, JSObject* object, Object* value, void* data);
   void* data;
 };
=======================================
--- /branches/bleeding_edge/src/x64/macro-assembler-x64.h Thu Apr 17 23:25:02 2014 UTC +++ /branches/bleeding_edge/src/x64/macro-assembler-x64.h Wed Apr 23 15:08:03 2014 UTC
@@ -1506,13 +1506,6 @@
                                  Register scratch,
                                  AllocationFlags flags);

-  // Helper for PopHandleScope.  Allowed to perform a GC and returns
-  // NULL if gc_allowed.  Does not perform a GC if !gc_allowed, and
-  // possibly returns a failure object indicating an allocation failure.
-  Object* PopHandleScopeHelper(Register saved,
-                               Register scratch,
-                               bool gc_allowed);
-
   // Helper for implementing JumpIfNotInNewSpace and JumpIfInNewSpace.
   void InNewSpace(Register object,
                   Register scratch,
=======================================
--- /branches/bleeding_edge/test/cctest/test-alloc.cc Tue Apr 22 08:30:09 2014 UTC +++ /branches/bleeding_edge/test/cctest/test-alloc.cc Wed Apr 23 15:08:03 2014 UTC
@@ -104,8 +104,8 @@
 }


-static MaybeObject* TestAccessorGet(Isolate* isolate, Object* object, void*) {
-  return AllocateAfterFailures();
+static Object* TestAccessorGet(Isolate* isolate, Object* object, void*) {
+  return *Test();
 }


=======================================
--- /branches/bleeding_edge/test/cctest/test-heap.cc Tue Apr 22 08:30:09 2014 UTC +++ /branches/bleeding_edge/test/cctest/test-heap.cc Wed Apr 23 15:08:03 2014 UTC
@@ -240,7 +240,6 @@
            Failure::RetryAfterGC(NEW_SPACE)->allocation_space());
   CHECK_EQ(OLD_POINTER_SPACE,
            Failure::RetryAfterGC(OLD_POINTER_SPACE)->allocation_space());
-  CHECK(Failure::Exception()->IsFailure());
   CHECK(Smi::FromInt(Smi::kMinValue)->IsSmi());
   CHECK(Smi::FromInt(Smi::kMaxValue)->IsSmi());
 }

--
--
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/d/optout.

Reply via email to