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