Revision: 20871
Author: [email protected]
Date: Tue Apr 22 07:33:20 2014 UTC
Log: Introduce exception object and remove some uses of
MaybeObject::IsFailure().
[email protected]
Review URL: https://codereview.chromium.org/240883003
http://code.google.com/p/v8/source/detail?r=20871
Modified:
/branches/bleeding_edge/include/v8.h
/branches/bleeding_edge/src/allocation-site-scopes.cc
/branches/bleeding_edge/src/elements.cc
/branches/bleeding_edge/src/heap.cc
/branches/bleeding_edge/src/heap.h
/branches/bleeding_edge/src/ic.cc
/branches/bleeding_edge/src/isolate.h
/branches/bleeding_edge/src/objects-debug.cc
/branches/bleeding_edge/src/objects-inl.h
/branches/bleeding_edge/src/objects.h
=======================================
--- /branches/bleeding_edge/include/v8.h Thu Apr 17 11:27:45 2014 UTC
+++ /branches/bleeding_edge/include/v8.h Tue Apr 22 07:33:20 2014 UTC
@@ -5545,7 +5545,7 @@
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;
=======================================
--- /branches/bleeding_edge/src/allocation-site-scopes.cc Wed Nov 27
14:03:40 2013 UTC
+++ /branches/bleeding_edge/src/allocation-site-scopes.cc Tue Apr 22
07:33:20 2014 UTC
@@ -62,7 +62,7 @@
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);
=======================================
--- /branches/bleeding_edge/src/elements.cc Wed Apr 16 06:18:37 2014 UTC
+++ /branches/bleeding_edge/src/elements.cc Tue Apr 22 07:33:20 2014 UTC
@@ -596,8 +596,6 @@
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;
=======================================
--- /branches/bleeding_edge/src/heap.cc Thu Apr 17 14:58:03 2014 UTC
+++ /branches/bleeding_edge/src/heap.cc Tue Apr 22 07:33:20 2014 UTC
@@ -2578,6 +2578,7 @@
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++) {
@@ -2882,6 +2883,12 @@
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);
=======================================
--- /branches/bleeding_edge/src/heap.h Thu Apr 17 14:58:03 2014 UTC
+++ /branches/bleeding_edge/src/heap.h Tue Apr 22 07:33:20 2014 UTC
@@ -60,6 +60,7 @@
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 @@
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) \
=======================================
--- /branches/bleeding_edge/src/ic.cc Wed Apr 16 16:16:37 2014 UTC
+++ /branches/bleeding_edge/src/ic.cc Tue Apr 22 07:33:20 2014 UTC
@@ -1161,7 +1161,7 @@
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 @@
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 @@
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) {
=======================================
--- /branches/bleeding_edge/src/isolate.h Thu Apr 17 08:33:18 2014 UTC
+++ /branches/bleeding_edge/src/isolate.h Tue Apr 22 07:33:20 2014 UTC
@@ -588,17 +588,17 @@
// 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 @@
}
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 @@
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();
}
=======================================
--- /branches/bleeding_edge/src/objects-debug.cc Thu Apr 17 17:45:32 2014
UTC
+++ /branches/bleeding_edge/src/objects-debug.cc Tue Apr 22 07:33:20 2014
UTC
@@ -618,7 +618,7 @@
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);
}
@@ -639,6 +639,8 @@
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();
}
=======================================
--- /branches/bleeding_edge/src/objects-inl.h Thu Apr 17 17:45:32 2014 UTC
+++ /branches/bleeding_edge/src/objects-inl.h Tue Apr 22 07:33:20 2014 UTC
@@ -1000,6 +1000,11 @@
bool Object::IsTheHole() {
return IsOddball() && Oddball::cast(this)->kind() == Oddball::kTheHole;
}
+
+
+bool Object::IsException() {
+ return IsOddball() && Oddball::cast(this)->kind() == Oddball::kException;
+}
bool Object::IsUninitialized() {
@@ -1046,20 +1051,6 @@
}
return Handle<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,
=======================================
--- /branches/bleeding_edge/src/objects.h Thu Apr 17 17:45:32 2014 UTC
+++ /branches/bleeding_edge/src/objects.h Tue Apr 22 07:33:20 2014 UTC
@@ -1450,7 +1450,8 @@
// 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());
@@ -1531,7 +1532,6 @@
// 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);
@@ -9814,6 +9814,7 @@
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
[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.