// 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;
}
}
-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;
//
-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();
}
-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);
}
-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,
//
-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.
//
-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()
}
-static MaybeObject* ConstructArgumentsObjectForInlinedFunction(
+static Object* ConstructArgumentsObjectForInlinedFunction(
JavaScriptFrame* frame,
Handle<JSFunction> inlined_function,
int inlined_frame_index) {
}
-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();
};
-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);
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
isolate->clear_pending_message();
}
- return Handle<Object>(value->ToObjectUnchecked(), isolate);
+ return Handle<Object>(value, isolate);
}
#undef MAKE_CASE
default:
UNREACHABLE();
- return Failure::InternalError();
+ return exception();
}
int size = map->instance_size();
AllocationSpace space = SelectSpace(size, OLD_POINTER_SPACE, TENURED);
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,
}
-bool MaybeObject::IsException() {
- return this == Failure::Exception();
-}
-
-
Failure* Failure::cast(MaybeObject* obj) {
ASSERT(HAS_FAILURE_TAG(obj));
return reinterpret_cast<Failure*>(obj);
}
-Failure* Failure::InternalError() {
- return Construct(INTERNAL_ERROR);
-}
-
-
-Failure* Failure::Exception() {
- return Construct(EXCEPTION);
-}
-
-
intptr_t Failure::value() const {
return static_cast<intptr_t>(
reinterpret_cast<uintptr_t>(this) >> kFailureTagSize);
public:
inline bool IsFailure();
inline bool IsRetryAfterGC();
- inline bool IsException();
inline bool ToObject(Object** obj) {
if (IsFailure()) return false;
*obj = reinterpret_cast<Object*>(this);
};
-// 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:
// +-------------------------+---+--+--+
// 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
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;
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);
}
-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);
}
UNREACHABLE();
- return Failure::Exception();
+ return Smi::FromInt(0);
}
// 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.
}
bool owned = (chunk->owner() == this);
- SLOW_ASSERT(!owned || !FindObject(address)->IsFailure());
+ SLOW_ASSERT(!owned || FindObject(address)->IsHeapObject());
return owned;
}
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.
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.
#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_;
Isolate* isolate_;
const ExtraICState extra_ic_state_;
MacroAssembler masm_;
- Failure* failure_;
};
// 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;
};
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,
}
-static MaybeObject* TestAccessorGet(Isolate* isolate, Object* object, void*) {
- return AllocateAfterFailures();
+static Object* TestAccessorGet(Isolate* isolate, Object* object, void*) {
+ return *Test();
}
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());
}