Commit 139be49f authored by yangguo@chromium.org's avatar yangguo@chromium.org

Remove some uses of MaybeObject methods.

R=bmeurer@chromium.org

Review URL: https://codereview.chromium.org/236303015

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@20786 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent 9a71bc72
...@@ -893,7 +893,6 @@ Failure* Isolate::ReThrow(Object* exception) { ...@@ -893,7 +893,6 @@ Failure* Isolate::ReThrow(Object* exception) {
// Set the exception being re-thrown. // Set the exception being re-thrown.
set_pending_exception(exception); set_pending_exception(exception);
if (exception->IsFailure()) return exception->ToFailureUnchecked();
return Failure::Exception(); return Failure::Exception();
} }
......
...@@ -673,16 +673,6 @@ bool MaybeObject::IsException() { ...@@ -673,16 +673,6 @@ bool MaybeObject::IsException() {
} }
bool MaybeObject::IsTheHole() {
return !IsFailure() && ToObjectUnchecked()->IsTheHole();
}
bool MaybeObject::IsUninitialized() {
return !IsFailure() && ToObjectUnchecked()->IsUninitialized();
}
Failure* Failure::cast(MaybeObject* obj) { Failure* Failure::cast(MaybeObject* obj) {
ASSERT(HAS_FAILURE_TAG(obj)); ASSERT(HAS_FAILURE_TAG(obj));
return reinterpret_cast<Failure*>(obj); return reinterpret_cast<Failure*>(obj);
...@@ -1301,11 +1291,6 @@ Failure::Type Failure::type() const { ...@@ -1301,11 +1291,6 @@ Failure::Type Failure::type() const {
} }
bool Failure::IsInternalError() const {
return type() == INTERNAL_ERROR;
}
AllocationSpace Failure::allocation_space() const { AllocationSpace Failure::allocation_space() const {
ASSERT_EQ(RETRY_AFTER_GC, type()); ASSERT_EQ(RETRY_AFTER_GC, type());
return static_cast<AllocationSpace>((value() >> kFailureTypeTagSize) return static_cast<AllocationSpace>((value() >> kFailureTypeTagSize)
......
...@@ -924,17 +924,11 @@ class MaybeObject BASE_EMBEDDED { ...@@ -924,17 +924,11 @@ class MaybeObject BASE_EMBEDDED {
inline bool IsFailure(); inline bool IsFailure();
inline bool IsRetryAfterGC(); inline bool IsRetryAfterGC();
inline bool IsException(); inline bool IsException();
INLINE(bool IsTheHole());
INLINE(bool IsUninitialized());
inline bool ToObject(Object** obj) { inline bool ToObject(Object** obj) {
if (IsFailure()) return false; if (IsFailure()) return false;
*obj = reinterpret_cast<Object*>(this); *obj = reinterpret_cast<Object*>(this);
return true; return true;
} }
inline Failure* ToFailureUnchecked() {
ASSERT(IsFailure());
return reinterpret_cast<Failure*>(this);
}
inline Object* ToObjectUnchecked() { inline Object* ToObjectUnchecked() {
// TODO(jkummerow): Turn this back into an ASSERT when we can be certain // TODO(jkummerow): Turn this back into an ASSERT when we can be certain
// that it never fires in Release mode in the wild. // that it never fires in Release mode in the wild.
...@@ -953,13 +947,6 @@ class MaybeObject BASE_EMBEDDED { ...@@ -953,13 +947,6 @@ class MaybeObject BASE_EMBEDDED {
return true; return true;
} }
template<typename T>
inline bool ToHandle(Handle<T>* obj, Isolate* isolate) {
if (IsFailure()) return false;
*obj = handle(T::cast(reinterpret_cast<Object*>(this)), isolate);
return true;
}
#ifdef OBJECT_PRINT #ifdef OBJECT_PRINT
// Prints this object with details. // Prints this object with details.
void Print(); void Print();
...@@ -1710,8 +1697,6 @@ class Failure: public MaybeObject { ...@@ -1710,8 +1697,6 @@ class Failure: public MaybeObject {
// Returns the space that needs to be collected for RetryAfterGC failures. // Returns the space that needs to be collected for RetryAfterGC failures.
inline AllocationSpace allocation_space() const; inline AllocationSpace allocation_space() const;
inline bool IsInternalError() const;
static inline Failure* RetryAfterGC(AllocationSpace space); static inline Failure* RetryAfterGC(AllocationSpace space);
static inline Failure* RetryAfterGC(); // NEW_SPACE static inline Failure* RetryAfterGC(); // NEW_SPACE
static inline Failure* Exception(); static inline Failure* Exception();
......
...@@ -7272,6 +7272,7 @@ static void JoinSparseArrayWithSeparator(FixedArray* elements, ...@@ -7272,6 +7272,7 @@ static void JoinSparseArrayWithSeparator(FixedArray* elements,
uint32_t array_length, uint32_t array_length,
String* separator, String* separator,
Vector<Char> buffer) { Vector<Char> buffer) {
DisallowHeapAllocation no_gc;
int previous_separator_position = 0; int previous_separator_position = 0;
int separator_length = separator->length(); int separator_length = separator->length();
int cursor = 0; int cursor = 0;
...@@ -7310,10 +7311,10 @@ static void JoinSparseArrayWithSeparator(FixedArray* elements, ...@@ -7310,10 +7311,10 @@ static void JoinSparseArrayWithSeparator(FixedArray* elements,
RUNTIME_FUNCTION(MaybeObject*, Runtime_SparseJoinWithSeparator) { RUNTIME_FUNCTION(MaybeObject*, Runtime_SparseJoinWithSeparator) {
HandleScope scope(isolate); HandleScope scope(isolate);
ASSERT(args.length() == 3); ASSERT(args.length() == 3);
CONVERT_ARG_CHECKED(JSArray, elements_array, 0); CONVERT_ARG_HANDLE_CHECKED(JSArray, elements_array, 0);
RUNTIME_ASSERT(elements_array->HasFastSmiOrObjectElements()); RUNTIME_ASSERT(elements_array->HasFastSmiOrObjectElements());
CONVERT_NUMBER_CHECKED(uint32_t, array_length, Uint32, args[1]); CONVERT_NUMBER_CHECKED(uint32_t, array_length, Uint32, args[1]);
CONVERT_ARG_CHECKED(String, separator, 2); CONVERT_ARG_HANDLE_CHECKED(String, separator, 2);
// elements_array is fast-mode JSarray of alternating positions // elements_array is fast-mode JSarray of alternating positions
// (increasing order) and strings. // (increasing order) and strings.
// array_length is length of original array (used to add separators); // array_length is length of original array (used to add separators);
...@@ -7323,25 +7324,28 @@ RUNTIME_FUNCTION(MaybeObject*, Runtime_SparseJoinWithSeparator) { ...@@ -7323,25 +7324,28 @@ RUNTIME_FUNCTION(MaybeObject*, Runtime_SparseJoinWithSeparator) {
int string_length = 0; int string_length = 0;
bool is_ascii = separator->IsOneByteRepresentation(); bool is_ascii = separator->IsOneByteRepresentation();
bool overflow = false; bool overflow = false;
CONVERT_NUMBER_CHECKED(int, elements_length, CONVERT_NUMBER_CHECKED(int, elements_length, Int32, elements_array->length());
Int32, elements_array->length());
RUNTIME_ASSERT((elements_length & 1) == 0); // Even length. RUNTIME_ASSERT((elements_length & 1) == 0); // Even length.
FixedArray* elements = FixedArray::cast(elements_array->elements());
for (int i = 0; i < elements_length; i += 2) { { DisallowHeapAllocation no_gc;
RUNTIME_ASSERT(elements->get(i)->IsNumber()); FixedArray* elements = FixedArray::cast(elements_array->elements());
RUNTIME_ASSERT(elements->get(i + 1)->IsString()); for (int i = 0; i < elements_length; i += 2) {
String* string = String::cast(elements->get(i + 1)); RUNTIME_ASSERT(elements->get(i)->IsNumber());
int length = string->length(); RUNTIME_ASSERT(elements->get(i + 1)->IsString());
if (is_ascii && !string->IsOneByteRepresentation()) { String* string = String::cast(elements->get(i + 1));
is_ascii = false; int length = string->length();
} if (is_ascii && !string->IsOneByteRepresentation()) {
if (length > String::kMaxLength || is_ascii = false;
String::kMaxLength - length < string_length) { }
overflow = true; if (length > String::kMaxLength ||
break; String::kMaxLength - length < string_length) {
overflow = true;
break;
}
string_length += length;
} }
string_length += length;
} }
int separator_length = separator->length(); int separator_length = separator->length();
if (!overflow && separator_length > 0) { if (!overflow && separator_length > 0) {
if (array_length <= 0x7fffffffu) { if (array_length <= 0x7fffffffu) {
...@@ -7368,32 +7372,25 @@ RUNTIME_FUNCTION(MaybeObject*, Runtime_SparseJoinWithSeparator) { ...@@ -7368,32 +7372,25 @@ RUNTIME_FUNCTION(MaybeObject*, Runtime_SparseJoinWithSeparator) {
} }
if (is_ascii) { if (is_ascii) {
MaybeObject* result_allocation = Handle<SeqOneByteString> result = isolate->factory()->NewRawOneByteString(
isolate->heap()->AllocateRawOneByteString(string_length); string_length).ToHandleChecked();
if (result_allocation->IsFailure()) return result_allocation; JoinSparseArrayWithSeparator<uint8_t>(
SeqOneByteString* result_string = FixedArray::cast(elements_array->elements()),
SeqOneByteString::cast(result_allocation->ToObjectUnchecked()); elements_length,
JoinSparseArrayWithSeparator<uint8_t>(elements, array_length,
elements_length, *separator,
array_length, Vector<uint8_t>(result->GetChars(), string_length));
separator, return *result;
Vector<uint8_t>(
result_string->GetChars(),
string_length));
return result_string;
} else { } else {
MaybeObject* result_allocation = Handle<SeqTwoByteString> result = isolate->factory()->NewRawTwoByteString(
isolate->heap()->AllocateRawTwoByteString(string_length); string_length).ToHandleChecked();
if (result_allocation->IsFailure()) return result_allocation; JoinSparseArrayWithSeparator<uc16>(
SeqTwoByteString* result_string = FixedArray::cast(elements_array->elements()),
SeqTwoByteString::cast(result_allocation->ToObjectUnchecked()); elements_length,
JoinSparseArrayWithSeparator<uc16>(elements, array_length,
elements_length, *separator,
array_length, Vector<uc16>(result->GetChars(), string_length));
separator, return *result;
Vector<uc16>(result_string->GetChars(),
string_length));
return result_string;
} }
} }
...@@ -9171,15 +9168,6 @@ static inline ObjectPair MakePair(MaybeObject* x, MaybeObject* y) { ...@@ -9171,15 +9168,6 @@ static inline ObjectPair MakePair(MaybeObject* x, MaybeObject* y) {
#endif #endif
static inline MaybeObject* Unhole(Heap* heap,
MaybeObject* x,
PropertyAttributes attributes) {
ASSERT(!x->IsTheHole() || (attributes & READ_ONLY) != 0);
USE(attributes);
return x->IsTheHole() ? heap->undefined_value() : x;
}
static Object* ComputeReceiverForNonGlobal(Isolate* isolate, static Object* ComputeReceiverForNonGlobal(Isolate* isolate,
JSObject* holder) { JSObject* holder) {
ASSERT(!holder->IsGlobalObject()); ASSERT(!holder->IsGlobalObject());
...@@ -9249,7 +9237,11 @@ static ObjectPair LoadContextSlotHelper(Arguments args, ...@@ -9249,7 +9237,11 @@ static ObjectPair LoadContextSlotHelper(Arguments args,
ASSERT(!value->IsTheHole()); ASSERT(!value->IsTheHole());
return MakePair(value, *receiver); return MakePair(value, *receiver);
case IMMUTABLE_CHECK_INITIALIZED: case IMMUTABLE_CHECK_INITIALIZED:
return MakePair(Unhole(isolate->heap(), value, attributes), *receiver); if (value->IsTheHole()) {
ASSERT((attributes & READ_ONLY) != 0);
value = isolate->heap()->undefined_value();
}
return MakePair(value, *receiver);
case MISSING_BINDING: case MISSING_BINDING:
UNREACHABLE(); UNREACHABLE();
return MakePair(NULL, NULL); return MakePair(NULL, NULL);
......
...@@ -86,19 +86,19 @@ class TestObjectVisitor : public ObjectVisitor { ...@@ -86,19 +86,19 @@ class TestObjectVisitor : public ObjectVisitor {
TEST(IterateObjectGroupsOldApi) { TEST(IterateObjectGroupsOldApi) {
CcTest::InitializeVM(); CcTest::InitializeVM();
GlobalHandles* global_handles = CcTest::i_isolate()->global_handles(); Isolate* isolate = CcTest::i_isolate();
Heap* heap = CcTest::heap(); GlobalHandles* global_handles = isolate->global_handles();
v8::HandleScope handle_scope(CcTest::isolate()); v8::HandleScope handle_scope(CcTest::isolate());
Handle<Object> g1s1 = Handle<Object> g1s1 =
global_handles->Create(heap->AllocateFixedArray(1)->ToObjectChecked()); global_handles->Create(*isolate->factory()->NewFixedArray(1));
Handle<Object> g1s2 = Handle<Object> g1s2 =
global_handles->Create(heap->AllocateFixedArray(1)->ToObjectChecked()); global_handles->Create(*isolate->factory()->NewFixedArray(1));
Handle<Object> g2s1 = Handle<Object> g2s1 =
global_handles->Create(heap->AllocateFixedArray(1)->ToObjectChecked()); global_handles->Create(*isolate->factory()->NewFixedArray(1));
Handle<Object> g2s2 = Handle<Object> g2s2 =
global_handles->Create(heap->AllocateFixedArray(1)->ToObjectChecked()); global_handles->Create(*isolate->factory()->NewFixedArray(1));
TestRetainedObjectInfo info1; TestRetainedObjectInfo info1;
TestRetainedObjectInfo info2; TestRetainedObjectInfo info2;
...@@ -181,20 +181,20 @@ TEST(IterateObjectGroupsOldApi) { ...@@ -181,20 +181,20 @@ TEST(IterateObjectGroupsOldApi) {
TEST(IterateObjectGroups) { TEST(IterateObjectGroups) {
CcTest::InitializeVM(); CcTest::InitializeVM();
GlobalHandles* global_handles = CcTest::i_isolate()->global_handles(); Isolate* isolate = CcTest::i_isolate();
Heap* heap = CcTest::heap(); GlobalHandles* global_handles = isolate->global_handles();
v8::HandleScope handle_scope(CcTest::isolate()); v8::HandleScope handle_scope(CcTest::isolate());
Handle<Object> g1s1 = Handle<Object> g1s1 =
global_handles->Create(heap->AllocateFixedArray(1)->ToObjectChecked()); global_handles->Create(*isolate->factory()->NewFixedArray(1));
Handle<Object> g1s2 = Handle<Object> g1s2 =
global_handles->Create(heap->AllocateFixedArray(1)->ToObjectChecked()); global_handles->Create(*isolate->factory()->NewFixedArray(1));
Handle<Object> g2s1 = Handle<Object> g2s1 =
global_handles->Create(heap->AllocateFixedArray(1)->ToObjectChecked()); global_handles->Create(*isolate->factory()->NewFixedArray(1));
Handle<Object> g2s2 = Handle<Object> g2s2 =
global_handles->Create(heap->AllocateFixedArray(1)->ToObjectChecked()); global_handles->Create(*isolate->factory()->NewFixedArray(1));
TestRetainedObjectInfo info1; TestRetainedObjectInfo info1;
TestRetainedObjectInfo info2; TestRetainedObjectInfo info2;
...@@ -276,25 +276,25 @@ TEST(IterateObjectGroups) { ...@@ -276,25 +276,25 @@ TEST(IterateObjectGroups) {
TEST(ImplicitReferences) { TEST(ImplicitReferences) {
CcTest::InitializeVM(); CcTest::InitializeVM();
GlobalHandles* global_handles = CcTest::i_isolate()->global_handles(); Isolate* isolate = CcTest::i_isolate();
Heap* heap = CcTest::heap(); GlobalHandles* global_handles = isolate->global_handles();
v8::HandleScope handle_scope(CcTest::isolate()); v8::HandleScope handle_scope(CcTest::isolate());
Handle<Object> g1s1 = Handle<Object> g1s1 =
global_handles->Create(heap->AllocateFixedArray(1)->ToObjectChecked()); global_handles->Create(*isolate->factory()->NewFixedArray(1));
Handle<Object> g1c1 = Handle<Object> g1c1 =
global_handles->Create(heap->AllocateFixedArray(1)->ToObjectChecked()); global_handles->Create(*isolate->factory()->NewFixedArray(1));
Handle<Object> g1c2 = Handle<Object> g1c2 =
global_handles->Create(heap->AllocateFixedArray(1)->ToObjectChecked()); global_handles->Create(*isolate->factory()->NewFixedArray(1));
Handle<Object> g2s1 = Handle<Object> g2s1 =
global_handles->Create(heap->AllocateFixedArray(1)->ToObjectChecked()); global_handles->Create(*isolate->factory()->NewFixedArray(1));
Handle<Object> g2s2 = Handle<Object> g2s2 =
global_handles->Create(heap->AllocateFixedArray(1)->ToObjectChecked()); global_handles->Create(*isolate->factory()->NewFixedArray(1));
Handle<Object> g2c1 = Handle<Object> g2c1 =
global_handles->Create(heap->AllocateFixedArray(1)->ToObjectChecked()); global_handles->Create(*isolate->factory()->NewFixedArray(1));
global_handles->SetObjectGroupId(g1s1.location(), UniqueId(1)); global_handles->SetObjectGroupId(g1s1.location(), UniqueId(1));
global_handles->SetObjectGroupId(g2s1.location(), UniqueId(2)); global_handles->SetObjectGroupId(g2s1.location(), UniqueId(2));
......
...@@ -1087,7 +1087,7 @@ TEST(CachedHashOverflow) { ...@@ -1087,7 +1087,7 @@ TEST(CachedHashOverflow) {
CHECK_EQ(results[i]->IsUndefined(), result->IsUndefined()); CHECK_EQ(results[i]->IsUndefined(), result->IsUndefined());
CHECK_EQ(results[i]->IsNumber(), result->IsNumber()); CHECK_EQ(results[i]->IsNumber(), result->IsNumber());
if (result->IsNumber()) { if (result->IsNumber()) {
CHECK_EQ(Smi::cast(results[i]->ToSmi()->ToObjectChecked())->value(), CHECK_EQ(Handle<Smi>::cast(Object::ToSmi(isolate, results[i]))->value(),
result->ToInt32()->Value()); result->ToInt32()->Value());
} }
} }
......
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