Reviewers: Benedikt Meurer,
Description:
Introduce exception object and remove some uses of MaybeObject::IsFailure().
R=bmeu...@chromium.org
Please review this at https://codereview.chromium.org/240883003/
SVN Base: https://v8.googlecode.com/svn/branches/bleeding_edge
Affected files (+36, -36 lines):
M include/v8.h
M src/allocation-site-scopes.cc
M src/elements.cc
M src/heap.h
M src/heap.cc
M src/ic.cc
M src/isolate.h
M src/objects.h
M src/objects-debug.cc
M src/objects-inl.h
Index: include/v8.h
diff --git a/include/v8.h b/include/v8.h
index
4d99d151522b98b22d8d10fc2ec5e2f0b77e7798..fa2dfed1ac8f482cd3564d5a322adc7e74aab72b
100644
--- a/include/v8.h
+++ b/include/v8.h
@@ -5545,7 +5545,7 @@ class Internals {
static const int kNullValueRootIndex = 7;
static const int kTrueValueRootIndex = 8;
static const int kFalseValueRootIndex = 9;
- static const int kEmptyStringRootIndex = 160;
+ static const int kEmptyStringRootIndex = 162;
static const int kNodeClassIdOffset = 1 * kApiPointerSize;
static const int kNodeFlagsOffset = 1 * kApiPointerSize + 3;
Index: src/allocation-site-scopes.cc
diff --git a/src/allocation-site-scopes.cc b/src/allocation-site-scopes.cc
index
bbfb39b122c336ad7e8df8846550fb5fec85d831..80dab8b314e86172d4256a466bb3352e743b56e9
100644
--- a/src/allocation-site-scopes.cc
+++ b/src/allocation-site-scopes.cc
@@ -62,7 +62,7 @@ Handle<AllocationSite>
AllocationSiteCreationContext::EnterNewScope() {
void AllocationSiteCreationContext::ExitScope(
Handle<AllocationSite> scope_site,
Handle<JSObject> object) {
- if (!object.is_null() && !object->IsFailure()) {
+ if (!object.is_null()) {
bool top_level = !scope_site.is_null() &&
top().is_identical_to(scope_site);
Index: src/elements.cc
diff --git a/src/elements.cc b/src/elements.cc
index
18f2619ea3b53479a9f6311de1401e42e8d9dfc1..9f83122aecd0946c7a56980290ae6770d8b328c3
100644
--- a/src/elements.cc
+++ b/src/elements.cc
@@ -596,8 +596,6 @@ class ElementsAccessorBase : public ElementsAccessor {
static void ValidateImpl(Handle<JSObject> holder) {
Handle<FixedArrayBase> fixed_array_base(holder->elements());
- // When objects are first allocated, its elements are Failures.
- if (fixed_array_base->IsFailure()) return;
if (!fixed_array_base->IsHeapObject()) return;
// Arrays that have been shifted in place can't be verified.
if (fixed_array_base->IsFiller()) return;
Index: src/heap.cc
diff --git a/src/heap.cc b/src/heap.cc
index
f1a0bfa52b133da27ea64e3facf02c319a297924..87651ee48330040b56c8c804135ffda00f0a2eac
100644
--- a/src/heap.cc
+++ b/src/heap.cc
@@ -2561,6 +2561,7 @@ bool Heap::CreateInitialMaps() {
ALLOCATE_MAP(ODDBALL_TYPE, Oddball::kSize, uninitialized);
ALLOCATE_MAP(ODDBALL_TYPE, Oddball::kSize, arguments_marker);
ALLOCATE_MAP(ODDBALL_TYPE, Oddball::kSize,
no_interceptor_result_sentinel);
+ ALLOCATE_MAP(ODDBALL_TYPE, Oddball::kSize, exception);
ALLOCATE_MAP(ODDBALL_TYPE, Oddball::kSize, termination_exception);
for (unsigned i = 0; i < ARRAY_SIZE(string_type_table); i++) {
@@ -2865,6 +2866,12 @@ bool Heap::CreateInitialObjects() {
handle(Smi::FromInt(-3), isolate()),
Oddball::kOther));
+ set_exception(
+ *factory->NewOddball(factory->exception_map(),
+ "exception",
+ handle(Smi::FromInt(-5), isolate()),
+ Oddball::kException));
+
for (unsigned i = 0; i < ARRAY_SIZE(constant_string_table); i++) {
Handle<String> str =
factory->InternalizeUtf8String(constant_string_table[i].contents);
Index: src/heap.h
diff --git a/src/heap.h b/src/heap.h
index
e4e89412d21958f3749269823278bfa3168e625c..7c2ea98baa228061322342643d4a4a8ec999a926
100644
--- a/src/heap.h
+++ b/src/heap.h
@@ -60,6 +60,7 @@ namespace internal {
V(Oddball, true_value,
TrueValue) \
V(Oddball, false_value,
FalseValue) \
V(Oddball, uninitialized_value,
UninitializedValue) \
+ V(Oddball, exception,
Exception) \
V(Map, cell_map,
CellMap) \
V(Map, global_property_cell_map,
GlobalPropertyCellMap) \
V(Map, shared_function_info_map,
SharedFunctionInfoMap) \
@@ -187,6 +188,7 @@ namespace internal {
V(Map, uninitialized_map,
UninitializedMap) \
V(Map, arguments_marker_map,
ArgumentsMarkerMap) \
V(Map, no_interceptor_result_sentinel_map,
NoInterceptorResultSentinelMap) \
+ V(Map, exception_map,
ExceptionMap) \
V(Map, termination_exception_map,
TerminationExceptionMap) \
V(Map, message_object_map,
JSMessageObjectMap) \
V(Map, foreign_map,
ForeignMap) \
Index: src/ic.cc
diff --git a/src/ic.cc b/src/ic.cc
index
86bef05e221120a5de4bc06d9c0dffd2990de96e..b075c1492b1cf696811855e5513b8fe82bf1e102
100644
--- a/src/ic.cc
+++ b/src/ic.cc
@@ -1161,7 +1161,7 @@ MaybeHandle<Object> KeyedLoadIC::Load(Handle<Object>
object,
stub = sloppy_arguments_stub();
} else if (receiver->HasIndexedInterceptor()) {
stub = indexed_interceptor_stub();
- } else if (!key->ToSmi()->IsFailure() &&
+ } else if (!Object::ToSmi(isolate(), key).is_null() &&
(!target().is_identical_to(sloppy_arguments_stub()))) {
stub = LoadElementStub(receiver);
}
@@ -1655,10 +1655,9 @@ bool IsOutOfBoundsAccess(Handle<JSObject> receiver,
KeyedAccessStoreMode KeyedStoreIC::GetStoreMode(Handle<JSObject> receiver,
Handle<Object> key,
Handle<Object> value) {
- ASSERT(!key->ToSmi()->IsFailure());
- Smi* smi_key = NULL;
- key->ToSmi()->To(&smi_key);
- int index = smi_key->value();
+ Handle<Object> smi_key = Object::ToSmi(isolate(), key);
+ ASSERT(!smi_key.is_null() && smi_key->IsSmi());
+ int index = Handle<Smi>::cast(smi_key)->value();
bool oob_access = IsOutOfBoundsAccess(receiver, index);
// Don't consider this a growing store if the store would send the
receiver to
// dictionary mode.
@@ -1780,7 +1779,7 @@ MaybeHandle<Object>
KeyedStoreIC::Store(Handle<Object> object,
if (object->IsJSObject()) {
Handle<JSObject> receiver = Handle<JSObject>::cast(object);
- bool key_is_smi_like = key->IsSmi() || !key->ToSmi()->IsFailure();
+ bool key_is_smi_like = !Object::ToSmi(isolate(), key).is_null();
if (receiver->elements()->map() ==
isolate()->heap()->sloppy_arguments_elements_map()) {
if (strict_mode() == SLOPPY) {
Index: src/isolate.h
diff --git a/src/isolate.h b/src/isolate.h
index
5dd4b4e9a7dd4af4f75640b3c8c79f4f3f646690..b3e403c56b0c71bddfb6686d102a3972a2ba25be
100644
--- a/src/isolate.h
+++ b/src/isolate.h
@@ -588,17 +588,17 @@ class Isolate {
// Interface to pending exception.
Object* pending_exception() {
ASSERT(has_pending_exception());
- ASSERT(!thread_local_top_.pending_exception_->IsFailure());
+ ASSERT(!thread_local_top_.pending_exception_->IsException());
return thread_local_top_.pending_exception_;
}
- void set_pending_exception(Object* exception) {
- ASSERT(!exception->IsFailure());
- thread_local_top_.pending_exception_ = exception;
+ void set_pending_exception(Object* exception_obj) {
+ ASSERT(!exception_obj->IsException());
+ thread_local_top_.pending_exception_ = exception_obj;
}
void clear_pending_exception() {
- ASSERT(!thread_local_top_.pending_exception_->IsFailure());
+ ASSERT(!thread_local_top_.pending_exception_->IsException());
thread_local_top_.pending_exception_ = heap_.the_hole_value();
}
@@ -607,7 +607,7 @@ class Isolate {
}
bool has_pending_exception() {
- ASSERT(!thread_local_top_.pending_exception_->IsFailure());
+ ASSERT(!thread_local_top_.pending_exception_->IsException());
return !thread_local_top_.pending_exception_->IsTheHole();
}
@@ -649,15 +649,15 @@ class Isolate {
Object* scheduled_exception() {
ASSERT(has_scheduled_exception());
- ASSERT(!thread_local_top_.scheduled_exception_->IsFailure());
+ ASSERT(!thread_local_top_.scheduled_exception_->IsException());
return thread_local_top_.scheduled_exception_;
}
bool has_scheduled_exception() {
- ASSERT(!thread_local_top_.scheduled_exception_->IsFailure());
+ ASSERT(!thread_local_top_.scheduled_exception_->IsException());
return thread_local_top_.scheduled_exception_ !=
heap_.the_hole_value();
}
void clear_scheduled_exception() {
- ASSERT(!thread_local_top_.scheduled_exception_->IsFailure());
+ ASSERT(!thread_local_top_.scheduled_exception_->IsException());
thread_local_top_.scheduled_exception_ = heap_.the_hole_value();
}
Index: src/objects-debug.cc
diff --git a/src/objects-debug.cc b/src/objects-debug.cc
index
aa826141244413cdff2b3d0a362a5ed9153e5e19..1b6fabf7b63199fd91090241e43f7f55839beba1
100644
--- a/src/objects-debug.cc
+++ b/src/objects-debug.cc
@@ -612,7 +612,7 @@ void Oddball::OddballVerify() {
CHECK(number->IsSmi());
int value = Smi::cast(number)->value();
// Hidden oddballs have negative smis.
- const int kLeastHiddenOddballNumber = -4;
+ const int kLeastHiddenOddballNumber = -5;
CHECK_LE(value, 1);
CHECK(value >= kLeastHiddenOddballNumber);
}
@@ -633,6 +633,8 @@ void Oddball::OddballVerify() {
CHECK(this == heap->arguments_marker());
} else if (map() == heap->termination_exception_map()) {
CHECK(this == heap->termination_exception());
+ } else if (map() == heap->exception_map()) {
+ CHECK(this == heap->exception());
} else {
UNREACHABLE();
}
Index: src/objects-inl.h
diff --git a/src/objects-inl.h b/src/objects-inl.h
index
023caa5ddf93f7a2fdf595121a0581553a23440f..179def457e474a35a4b369ae85a97b4891a27a92
100644
--- a/src/objects-inl.h
+++ b/src/objects-inl.h
@@ -1000,6 +1000,11 @@ bool Object::IsTheHole() {
}
+bool Object::IsException() {
+ return IsOddball() && Oddball::cast(this)->kind() == Oddball::kException;
+}
+
+
bool Object::IsUninitialized() {
return IsOddball() && Oddball::cast(this)->kind() ==
Oddball::kUninitialized;
}
@@ -1046,20 +1051,6 @@ Handle<Object> Object::ToSmi(Isolate* isolate,
Handle<Object> object) {
}
-// TODO(ishell): Use handlified version instead.
-MaybeObject* Object::ToSmi() {
- if (IsSmi()) return this;
- if (IsHeapNumber()) {
- double value = HeapNumber::cast(this)->value();
- int int_value = FastD2I(value);
- if (value == FastI2D(int_value) && Smi::IsValid(int_value)) {
- return Smi::FromInt(int_value);
- }
- }
- return Failure::Exception();
-}
-
-
MaybeHandle<JSReceiver> Object::ToObject(Isolate* isolate,
Handle<Object> object) {
return ToObject(
Index: src/objects.h
diff --git a/src/objects.h b/src/objects.h
index
3af52a41993a8a7b857e56d751464f6f29fc86e6..2a959c968f244b1257a59b87beacbd2afcc9406b
100644
--- a/src/objects.h
+++ b/src/objects.h
@@ -1442,7 +1442,8 @@ class Object : public MaybeObject {
// Oddball testing.
INLINE(bool IsUndefined());
INLINE(bool IsNull());
- INLINE(bool IsTheHole()); // Shadows MaybeObject's implementation.
+ INLINE(bool IsTheHole());
+ INLINE(bool IsException());
INLINE(bool IsUninitialized());
INLINE(bool IsTrue());
INLINE(bool IsFalse());
@@ -1523,7 +1524,6 @@ class Object : public MaybeObject {
// Failure is returned otherwise.
static MUST_USE_RESULT inline Handle<Object> ToSmi(Isolate* isolate,
Handle<Object>
object);
- MUST_USE_RESULT inline MaybeObject* ToSmi();
void Lookup(Name* name, LookupResult* result);
@@ -9786,6 +9786,7 @@ class Oddball: public HeapObject {
static const byte kUndefined = 5;
static const byte kUninitialized = 6;
static const byte kOther = 7;
+ static const byte kException = 8;
typedef FixedBodyDescriptor<kToStringOffset,
kToNumberOffset + kPointerSize,
--
--
v8-dev mailing list
v8-dev@googlegroups.com
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 v8-dev+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.