Removed funky Maybe constructor and made fields private.

BUG=v8:3929
LOG=y
R=dcarney@chromium.org

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

Cr-Commit-Position: refs/heads/master@{#26937}
This commit is contained in:
Sven Panne 2015-03-02 13:22:27 +01:00
parent 30637108dd
commit 602d0dab93
19 changed files with 185 additions and 223 deletions

View File

@ -5726,14 +5726,11 @@ class V8_EXPORT V8 {
/**
* A simple Maybe type, representing an object which may or may not have a
* value.
* value, see https://hackage.haskell.org/package/base/docs/Data-Maybe.html.
*/
template <class T>
class Maybe {
public:
// TODO(dcarney): remove this constructor, it makes no sense.
Maybe(bool has, const T& t) : has_value(has), value(t) {}
V8_INLINE bool IsJust() const { return has_value; }
V8_INLINE T FromJust() const {
@ -5747,18 +5744,26 @@ class Maybe {
return has_value ? value : default_value;
}
// TODO(dcarney): make private.
V8_INLINE bool operator==(const Maybe& other) const {
return (IsJust() == other.IsJust()) &&
(!IsJust() || FromJust() == other.FromJust());
}
V8_INLINE bool operator!=(const Maybe& other) const {
return !operator==(other);
}
private:
Maybe() : has_value(false) {}
explicit Maybe(const T& t) : has_value(true), value(t) {}
bool has_value;
T value;
private:
template <class U>
friend Maybe<U> Nothing();
template <class U>
friend Maybe<U> Just(const U& u);
Maybe() : has_value(false) {}
explicit Maybe(const T& t) : has_value(true), value(t) {}
};

View File

@ -81,14 +81,14 @@ MaybeHandle<Object> DefineDataProperty(Isolate* isolate,
LookupIterator it(object, Handle<Name>::cast(key),
LookupIterator::OWN_SKIP_INTERCEPTOR);
Maybe<PropertyAttributes> maybe = JSReceiver::GetPropertyAttributes(&it);
DCHECK(maybe.has_value);
DCHECK(maybe.IsJust());
duplicate = it.IsFound();
} else {
uint32_t index = 0;
key->ToArrayIndex(&index);
Maybe<bool> maybe = JSReceiver::HasOwnElement(object, index);
if (!maybe.has_value) return MaybeHandle<Object>();
duplicate = maybe.value;
if (!maybe.IsJust()) return MaybeHandle<Object>();
duplicate = maybe.FromJust();
}
if (duplicate) {
Handle<Object> args[1] = {key};

View File

@ -1943,9 +1943,9 @@ v8::Local<Value> v8::TryCatch::StackTrace() const {
{
EXCEPTION_PREAMBLE(isolate_);
Maybe<bool> maybe = i::JSReceiver::HasProperty(obj, name);
has_pending_exception = !maybe.has_value;
has_pending_exception = !maybe.IsJust();
EXCEPTION_BAILOUT_CHECK(isolate_, v8::Local<Value>());
if (!maybe.value) return v8::Local<Value>();
if (!maybe.FromJust()) return v8::Local<Value>();
}
i::Handle<i::Object> value;
EXCEPTION_PREAMBLE(isolate_);
@ -3358,10 +3358,10 @@ PropertyAttribute v8::Object::GetPropertyAttributes(v8::Handle<Value> key) {
EXCEPTION_PREAMBLE(isolate);
Maybe<PropertyAttributes> result =
i::JSReceiver::GetPropertyAttributes(self, key_name);
has_pending_exception = !result.has_value;
has_pending_exception = !result.IsJust();
EXCEPTION_BAILOUT_CHECK(isolate, static_cast<PropertyAttribute>(NONE));
if (result.value == ABSENT) return static_cast<PropertyAttribute>(NONE);
return static_cast<PropertyAttribute>(result.value);
if (result.FromJust() == ABSENT) return static_cast<PropertyAttribute>(NONE);
return static_cast<PropertyAttribute>(result.FromJust());
}
@ -3597,10 +3597,10 @@ bool v8::Object::Has(v8::Handle<Value> key) {
maybe = i::JSReceiver::HasProperty(self, name);
}
}
if (!maybe.has_value) has_pending_exception = true;
if (!maybe.IsJust()) has_pending_exception = true;
EXCEPTION_BAILOUT_CHECK(isolate, false);
DCHECK(maybe.has_value);
return maybe.value;
DCHECK(maybe.IsJust());
return maybe.FromJust();
}
@ -3634,9 +3634,9 @@ bool v8::Object::Has(uint32_t index) {
i::Handle<i::JSObject> self = Utils::OpenHandle(this);
EXCEPTION_PREAMBLE(isolate);
Maybe<bool> maybe = i::JSReceiver::HasElement(self, index);
has_pending_exception = !maybe.has_value;
has_pending_exception = !maybe.IsJust();
EXCEPTION_BAILOUT_CHECK(isolate, false);
return maybe.value;
return maybe.FromJust();
}
@ -3721,9 +3721,9 @@ bool v8::Object::HasOwnProperty(Handle<String> key) {
EXCEPTION_PREAMBLE(isolate);
Maybe<bool> maybe = i::JSReceiver::HasOwnProperty(Utils::OpenHandle(this),
Utils::OpenHandle(*key));
has_pending_exception = !maybe.has_value;
has_pending_exception = !maybe.IsJust();
EXCEPTION_BAILOUT_CHECK(isolate, false);
return maybe.value;
return maybe.FromJust();
}
@ -3734,9 +3734,9 @@ bool v8::Object::HasRealNamedProperty(Handle<String> key) {
EXCEPTION_PREAMBLE(isolate);
Maybe<bool> maybe = i::JSObject::HasRealNamedProperty(
Utils::OpenHandle(this), Utils::OpenHandle(*key));
has_pending_exception = !maybe.has_value;
has_pending_exception = !maybe.IsJust();
EXCEPTION_BAILOUT_CHECK(isolate, false);
return maybe.value;
return maybe.FromJust();
}
@ -3747,9 +3747,9 @@ bool v8::Object::HasRealIndexedProperty(uint32_t index) {
EXCEPTION_PREAMBLE(isolate);
Maybe<bool> maybe =
i::JSObject::HasRealElementProperty(Utils::OpenHandle(this), index);
has_pending_exception = !maybe.has_value;
has_pending_exception = !maybe.IsJust();
EXCEPTION_BAILOUT_CHECK(isolate, false);
return maybe.value;
return maybe.FromJust();
}
@ -3762,9 +3762,9 @@ bool v8::Object::HasRealNamedCallbackProperty(Handle<String> key) {
EXCEPTION_PREAMBLE(isolate);
Maybe<bool> maybe = i::JSObject::HasRealNamedCallbackProperty(
Utils::OpenHandle(this), Utils::OpenHandle(*key));
has_pending_exception = !maybe.has_value;
has_pending_exception = !maybe.IsJust();
EXCEPTION_BAILOUT_CHECK(isolate, false);
return maybe.value;
return maybe.FromJust();
}
@ -3800,7 +3800,7 @@ static Maybe<PropertyAttribute> GetPropertyAttributesByLookup(
i::LookupIterator* it) {
Maybe<PropertyAttributes> attr = i::JSReceiver::GetPropertyAttributes(it);
return it->IsFound() ? Just<PropertyAttribute>(
static_cast<PropertyAttribute>(attr.value))
static_cast<PropertyAttribute>(attr.FromJust()))
: Nothing<PropertyAttribute>();
}

View File

@ -2076,8 +2076,8 @@ class BinaryOperation FINAL : public Expression {
return has_fixed_right_arg_ ? Just(fixed_right_arg_value_) : Nothing<int>();
}
void set_fixed_right_arg(Maybe<int> arg) {
has_fixed_right_arg_ = arg.has_value;
if (arg.has_value) fixed_right_arg_value_ = arg.value;
has_fixed_right_arg_ = arg.IsJust();
if (arg.IsJust()) fixed_right_arg_value_ = arg.FromJust();
}
virtual void RecordToBooleanTypeFeedback(

View File

@ -122,8 +122,8 @@ static Maybe<PropertyAttributes> UnscopableLookup(LookupIterator* it) {
Isolate* isolate = it->isolate();
Maybe<PropertyAttributes> attrs = JSReceiver::GetPropertyAttributes(it);
DCHECK(attrs.has_value || isolate->has_pending_exception());
if (!attrs.has_value || attrs.value == ABSENT) return attrs;
DCHECK(attrs.IsJust() || isolate->has_pending_exception());
if (!attrs.IsJust() || attrs.FromJust() == ABSENT) return attrs;
Handle<Symbol> unscopables_symbol = isolate->factory()->unscopables_symbol();
Handle<Object> receiver = it->GetReceiver();
@ -264,11 +264,11 @@ Handle<Object> Context::Lookup(Handle<String> name,
maybe = JSReceiver::GetPropertyAttributes(object, name);
}
if (!maybe.has_value) return Handle<Object>();
if (!maybe.IsJust()) return Handle<Object>();
DCHECK(!isolate->has_pending_exception());
*attributes = maybe.value;
*attributes = maybe.FromJust();
if (maybe.value != ABSENT) {
if (maybe.FromJust() != ABSENT) {
if (FLAG_trace_contexts) {
PrintF("=> found property in context object %p\n",
reinterpret_cast<void*>(*object));

View File

@ -2946,7 +2946,7 @@ Maybe<HConstant*> HConstant::CopyToTruncatedInt32(Zone* zone) {
HConstant(DoubleToInt32(double_value_), Representation::Integer32(),
NotInNewSpace(), object_);
}
return Maybe<HConstant*>(res != NULL, res);
return res != NULL ? Just(res) : Nothing<HConstant*>();
}
@ -2962,7 +2962,7 @@ Maybe<HConstant*> HConstant::CopyToTruncatedNumber(Isolate* isolate,
} else if (handle->IsNull()) {
res = new(zone) HConstant(0);
}
return Maybe<HConstant*>(res != NULL, res);
return res != NULL ? Just(res) : Nothing<HConstant*>();
}

View File

@ -29,7 +29,7 @@ void HRepresentationChangesPhase::InsertRepresentationChangeForUse(
// Try to create a new copy of the constant with the new representation.
if (is_truncating_to_int && to.IsInteger32()) {
Maybe<HConstant*> res = constant->CopyToTruncatedInt32(graph()->zone());
if (res.has_value) new_value = res.value;
if (res.IsJust()) new_value = res.FromJust();
} else {
new_value = constant->CopyToRepresentation(to, graph()->zone());
}

View File

@ -10341,9 +10341,9 @@ HValue* HGraphBuilder::TruncateToNumber(HValue* value, Type** expected) {
HConstant* constant = HConstant::cast(value);
Maybe<HConstant*> number =
constant->CopyToTruncatedNumber(isolate(), zone());
if (number.has_value) {
if (number.IsJust()) {
*expected = Type::Number(zone());
return AddInstruction(number.value);
return AddInstruction(number.FromJust());
}
}
@ -10564,10 +10564,10 @@ HValue* HGraphBuilder::BuildBinaryOperation(
instr = AddUncasted<HMul>(left, right);
break;
case Token::MOD: {
if (fixed_right_arg.has_value &&
!right->EqualsInteger32Constant(fixed_right_arg.value)) {
HConstant* fixed_right = Add<HConstant>(
static_cast<int>(fixed_right_arg.value));
if (fixed_right_arg.IsJust() &&
!right->EqualsInteger32Constant(fixed_right_arg.FromJust())) {
HConstant* fixed_right =
Add<HConstant>(static_cast<int>(fixed_right_arg.FromJust()));
IfBuilder if_same(this);
if_same.If<HCompareNumericAndBranch>(right, fixed_right, Token::EQ);
if_same.Then();

View File

@ -395,8 +395,8 @@ void SetResolvedNumberSettings(Isolate* isolate,
Handle<String> key =
factory->NewStringFromStaticChars("minimumSignificantDigits");
Maybe<bool> maybe = JSReceiver::HasOwnProperty(resolved, key);
CHECK(maybe.has_value);
if (maybe.value) {
CHECK(maybe.IsJust());
if (maybe.FromJust()) {
JSObject::SetProperty(
resolved, factory->NewStringFromStaticChars("minimumSignificantDigits"),
factory->NewNumberFromInt(number_format->getMinimumSignificantDigits()),
@ -405,8 +405,8 @@ void SetResolvedNumberSettings(Isolate* isolate,
key = factory->NewStringFromStaticChars("maximumSignificantDigits");
maybe = JSReceiver::HasOwnProperty(resolved, key);
CHECK(maybe.has_value);
if (maybe.value) {
CHECK(maybe.IsJust());
if (maybe.FromJust()) {
JSObject::SetProperty(
resolved, factory->NewStringFromStaticChars("maximumSignificantDigits"),
factory->NewNumberFromInt(number_format->getMaximumSignificantDigits()),
@ -725,8 +725,8 @@ icu::SimpleDateFormat* DateFormat::UnpackDateFormat(
Handle<String> key =
isolate->factory()->NewStringFromStaticChars("dateFormat");
Maybe<bool> maybe = JSReceiver::HasOwnProperty(obj, key);
CHECK(maybe.has_value);
if (maybe.value) {
CHECK(maybe.IsJust());
if (maybe.FromJust()) {
return reinterpret_cast<icu::SimpleDateFormat*>(
obj->GetInternalField(0));
}
@ -805,8 +805,8 @@ icu::DecimalFormat* NumberFormat::UnpackNumberFormat(
Handle<String> key =
isolate->factory()->NewStringFromStaticChars("numberFormat");
Maybe<bool> maybe = JSReceiver::HasOwnProperty(obj, key);
CHECK(maybe.has_value);
if (maybe.value) {
CHECK(maybe.IsJust());
if (maybe.FromJust()) {
return reinterpret_cast<icu::DecimalFormat*>(obj->GetInternalField(0));
}
@ -866,8 +866,8 @@ icu::Collator* Collator::UnpackCollator(Isolate* isolate,
Handle<JSObject> obj) {
Handle<String> key = isolate->factory()->NewStringFromStaticChars("collator");
Maybe<bool> maybe = JSReceiver::HasOwnProperty(obj, key);
CHECK(maybe.has_value);
if (maybe.value) {
CHECK(maybe.IsJust());
if (maybe.FromJust()) {
return reinterpret_cast<icu::Collator*>(obj->GetInternalField(0));
}
@ -931,8 +931,8 @@ icu::BreakIterator* BreakIterator::UnpackBreakIterator(Isolate* isolate,
Handle<String> key =
isolate->factory()->NewStringFromStaticChars("breakIterator");
Maybe<bool> maybe = JSReceiver::HasOwnProperty(obj, key);
CHECK(maybe.has_value);
if (maybe.value) {
CHECK(maybe.IsJust());
if (maybe.FromJust()) {
return reinterpret_cast<icu::BreakIterator*>(obj->GetInternalField(0));
}

View File

@ -45,18 +45,17 @@ STATIC_CONST_MEMBER_DEFINITION const int BinaryOpICState::LAST_TOKEN;
BinaryOpICState::BinaryOpICState(Isolate* isolate, ExtraICState extra_ic_state)
: fixed_right_arg_(Nothing<int>()), isolate_(isolate) {
: fixed_right_arg_(
HasFixedRightArgField::decode(extra_ic_state)
? Just(1 << FixedRightArgValueField::decode(extra_ic_state))
: Nothing<int>()),
isolate_(isolate) {
op_ =
static_cast<Token::Value>(FIRST_TOKEN + OpField::decode(extra_ic_state));
fixed_right_arg_ =
Maybe<int>(HasFixedRightArgField::decode(extra_ic_state),
1 << FixedRightArgValueField::decode(extra_ic_state));
left_kind_ = LeftKindField::decode(extra_ic_state);
if (fixed_right_arg_.has_value) {
right_kind_ = Smi::IsValid(fixed_right_arg_.value) ? SMI : INT32;
} else {
right_kind_ = RightKindField::decode(extra_ic_state);
}
right_kind_ = fixed_right_arg_.IsJust()
? (Smi::IsValid(fixed_right_arg_.FromJust()) ? SMI : INT32)
: RightKindField::decode(extra_ic_state);
result_kind_ = ResultKindField::decode(extra_ic_state);
DCHECK_LE(FIRST_TOKEN, op_);
DCHECK_LE(op_, LAST_TOKEN);
@ -67,10 +66,10 @@ ExtraICState BinaryOpICState::GetExtraICState() const {
ExtraICState extra_ic_state =
OpField::encode(op_ - FIRST_TOKEN) | LeftKindField::encode(left_kind_) |
ResultKindField::encode(result_kind_) |
HasFixedRightArgField::encode(fixed_right_arg_.has_value);
if (fixed_right_arg_.has_value) {
HasFixedRightArgField::encode(fixed_right_arg_.IsJust());
if (fixed_right_arg_.IsJust()) {
extra_ic_state = FixedRightArgValueField::update(
extra_ic_state, WhichPowerOf2(fixed_right_arg_.value));
extra_ic_state, WhichPowerOf2(fixed_right_arg_.FromJust()));
} else {
extra_ic_state = RightKindField::update(extra_ic_state, right_kind_);
}
@ -89,7 +88,7 @@ void BinaryOpICState::GenerateAheadOfTime(
do { \
BinaryOpICState state(isolate, op); \
state.left_kind_ = left_kind; \
state.fixed_right_arg_.has_value = false; \
state.fixed_right_arg_ = Nothing<int>(); \
state.right_kind_ = right_kind; \
state.result_kind_ = result_kind; \
Generate(isolate, state); \
@ -191,8 +190,7 @@ void BinaryOpICState::GenerateAheadOfTime(
do { \
BinaryOpICState state(isolate, op); \
state.left_kind_ = left_kind; \
state.fixed_right_arg_.has_value = true; \
state.fixed_right_arg_.value = fixed_right_arg_value; \
state.fixed_right_arg_ = Just(fixed_right_arg_value); \
state.right_kind_ = SMI; \
state.result_kind_ = result_kind; \
Generate(isolate, state); \
@ -225,8 +223,8 @@ std::ostream& operator<<(std::ostream& os, const BinaryOpICState& s) {
os << "(" << Token::Name(s.op_);
if (s.CouldCreateAllocationMementos()) os << "_CreateAllocationMementos";
os << ":" << BinaryOpICState::KindToString(s.left_kind_) << "*";
if (s.fixed_right_arg_.has_value) {
os << s.fixed_right_arg_.value;
if (s.fixed_right_arg_.IsJust()) {
os << s.fixed_right_arg_.FromJust();
} else {
os << BinaryOpICState::KindToString(s.right_kind_);
}
@ -248,9 +246,9 @@ void BinaryOpICState::Update(Handle<Object> left, Handle<Object> right,
base::bits::IsPowerOfTwo32(fixed_right_arg_value) &&
FixedRightArgValueField::is_valid(WhichPowerOf2(fixed_right_arg_value)) &&
(left_kind_ == SMI || left_kind_ == INT32) &&
(result_kind_ == NONE || !fixed_right_arg_.has_value);
fixed_right_arg_ = Maybe<int32_t>(has_fixed_right_arg, fixed_right_arg_value);
(result_kind_ == NONE || !fixed_right_arg_.IsJust());
fixed_right_arg_ =
has_fixed_right_arg ? Just(fixed_right_arg_value) : Nothing<int32_t>();
result_kind_ = UpdateKind(result, result_kind_);
if (!Token::IsTruncatingBinaryOp(op_)) {

View File

@ -6961,7 +6961,7 @@ Maybe<bool> JSReceiver::HasProperty(Handle<JSReceiver> object,
return JSProxy::HasPropertyWithHandler(proxy, name);
}
Maybe<PropertyAttributes> result = GetPropertyAttributes(object, name);
return result.has_value ? Just(result.value != ABSENT) : Nothing<bool>();
return result.IsJust() ? Just(result.FromJust() != ABSENT) : Nothing<bool>();
}
@ -6972,7 +6972,7 @@ Maybe<bool> JSReceiver::HasOwnProperty(Handle<JSReceiver> object,
return JSProxy::HasPropertyWithHandler(proxy, name);
}
Maybe<PropertyAttributes> result = GetOwnPropertyAttributes(object, name);
return result.has_value ? Just(result.value != ABSENT) : Nothing<bool>();
return result.IsJust() ? Just(result.FromJust() != ABSENT) : Nothing<bool>();
}
@ -7031,7 +7031,7 @@ Maybe<bool> JSReceiver::HasElement(Handle<JSReceiver> object, uint32_t index) {
}
Maybe<PropertyAttributes> result = JSObject::GetElementAttributeWithReceiver(
Handle<JSObject>::cast(object), object, index, true);
return result.has_value ? Just(result.value != ABSENT) : Nothing<bool>();
return result.IsJust() ? Just(result.FromJust() != ABSENT) : Nothing<bool>();
}
@ -7043,7 +7043,7 @@ Maybe<bool> JSReceiver::HasOwnElement(Handle<JSReceiver> object,
}
Maybe<PropertyAttributes> result = JSObject::GetElementAttributeWithReceiver(
Handle<JSObject>::cast(object), object, index, false);
return result.has_value ? Just(result.value != ABSENT) : Nothing<bool>();
return result.IsJust() ? Just(result.FromJust() != ABSENT) : Nothing<bool>();
}

View File

@ -487,7 +487,7 @@ Maybe<PropertyAttributes> JSObject::GetPropertyAttributesWithFailedAccessCheck(
auto result = GetPropertyAttributesWithInterceptor(
it->GetHolder<JSObject>(), it->GetReceiver(), it->name());
if (it->isolate()->has_scheduled_exception()) break;
if (result.has_value && result.value != ABSENT) return result;
if (result.IsJust() && result.FromJust() != ABSENT) return result;
}
it->isolate()->ReportFailedAccessCheck(checked);
RETURN_VALUE_IF_SCHEDULED_EXCEPTION(it->isolate(),
@ -625,7 +625,7 @@ Maybe<PropertyAttributes> JSObject::GetElementAttributesWithFailedAccessCheck(
auto result =
JSObject::GetElementAttributeFromInterceptor(object, receiver, index);
if (isolate->has_scheduled_exception()) break;
if (result.has_value && result.value != ABSENT) return result;
if (result.IsJust() && result.FromJust() != ABSENT) return result;
where_to_start = PrototypeIterator::START_AT_PROTOTYPE;
}
isolate->ReportFailedAccessCheck(object);
@ -723,12 +723,12 @@ MaybeHandle<Object> Object::SetElementWithReceiver(
Maybe<PropertyAttributes> from_interceptor =
JSObject::GetElementAttributeFromInterceptor(js_object, receiver,
index);
if (!from_interceptor.has_value) return MaybeHandle<Object>();
if ((from_interceptor.value & READ_ONLY) != 0) {
if (!from_interceptor.IsJust()) return MaybeHandle<Object>();
if ((from_interceptor.FromJust() & READ_ONLY) != 0) {
return WriteToReadOnlyElement(isolate, receiver, index, value,
language_mode);
}
done = from_interceptor.value != ABSENT;
done = from_interceptor.FromJust() != ABSENT;
}
if (!done &&
@ -3118,9 +3118,9 @@ MaybeHandle<Object> Object::SetPropertyInternal(LookupIterator* it,
Maybe<PropertyAttributes> maybe_attributes =
JSObject::GetPropertyAttributesWithInterceptor(
it->GetHolder<JSObject>(), it->GetReceiver(), it->name());
if (!maybe_attributes.has_value) return MaybeHandle<Object>();
done = maybe_attributes.value != ABSENT;
if (done && (maybe_attributes.value & READ_ONLY) != 0) {
if (!maybe_attributes.IsJust()) return MaybeHandle<Object>();
done = maybe_attributes.FromJust() != ABSENT;
if (done && (maybe_attributes.FromJust() & READ_ONLY) != 0) {
return WriteToReadOnlyProperty(it, value, language_mode);
}
}
@ -4162,7 +4162,7 @@ void JSObject::AddProperty(Handle<JSObject> object, Handle<Name> name,
DCHECK(!object->IsJSProxy());
DCHECK(!name->AsArrayIndex(&index));
Maybe<PropertyAttributes> maybe = GetPropertyAttributes(&it);
DCHECK(maybe.has_value);
DCHECK(maybe.IsJust());
DCHECK(!it.IsFound());
DCHECK(object->map()->is_extensible() ||
it.isolate()->IsInternallyUsedPropertyName(name));
@ -4357,8 +4357,8 @@ Maybe<PropertyAttributes> JSReceiver::GetPropertyAttributes(
Maybe<PropertyAttributes> result =
JSObject::GetPropertyAttributesWithInterceptor(
it->GetHolder<JSObject>(), it->GetReceiver(), it->name());
if (!result.has_value) return result;
if (result.value != ABSENT) return result;
if (!result.IsJust()) return result;
if (result.FromJust() != ABSENT) return result;
break;
}
case LookupIterator::ACCESS_CHECK:
@ -4418,8 +4418,9 @@ Maybe<PropertyAttributes> JSObject::GetElementAttributeWithInterceptor(
Maybe<PropertyAttributes> from_interceptor =
GetElementAttributeFromInterceptor(object, receiver, index);
if (!from_interceptor.has_value) return Nothing<PropertyAttributes>();
if (from_interceptor.value != ABSENT) return Just(from_interceptor.value);
if (!from_interceptor.IsJust()) return Nothing<PropertyAttributes>();
if (from_interceptor.FromJust() != ABSENT)
return Just(from_interceptor.FromJust());
return GetElementAttributeWithoutInterceptor(object, receiver, index,
check_prototype);
@ -5086,8 +5087,8 @@ bool JSObject::HasHiddenProperties(Handle<JSObject> object) {
LookupIterator it(object, hidden, LookupIterator::OWN_SKIP_INTERCEPTOR);
Maybe<PropertyAttributes> maybe = GetPropertyAttributes(&it);
// Cannot get an exception since the hidden_string isn't accessible to JS.
DCHECK(maybe.has_value);
return maybe.value != ABSENT;
DCHECK(maybe.IsJust());
return maybe.FromJust() != ABSENT;
}
@ -5262,8 +5263,8 @@ MaybeHandle<Object> JSObject::DeleteElement(Handle<JSObject> object,
bool should_enqueue_change_record = false;
if (object->map()->is_observed()) {
Maybe<bool> maybe = HasOwnElement(object, index);
if (!maybe.has_value) return MaybeHandle<Object>();
should_enqueue_change_record = maybe.value;
if (!maybe.IsJust()) return MaybeHandle<Object>();
should_enqueue_change_record = maybe.FromJust();
if (should_enqueue_change_record) {
if (!GetOwnElementAccessorPair(object, index).is_null()) {
old_value = Handle<Object>::cast(factory->the_hole_value());
@ -5287,8 +5288,8 @@ MaybeHandle<Object> JSObject::DeleteElement(Handle<JSObject> object,
if (should_enqueue_change_record) {
Maybe<bool> maybe = HasOwnElement(object, index);
if (!maybe.has_value) return MaybeHandle<Object>();
if (!maybe.value) {
if (!maybe.IsJust()) return MaybeHandle<Object>();
if (!maybe.FromJust()) {
Handle<String> name = factory->Uint32ToString(index);
RETURN_ON_EXCEPTION(
isolate, EnqueueChangeRecord(object, "delete", name, old_value),
@ -5939,8 +5940,8 @@ MaybeHandle<JSObject> JSObjectWalkVisitor<ContextObject>::StructureWalk(
Handle<String> key_string(String::cast(names->get(i)));
Maybe<PropertyAttributes> maybe =
JSReceiver::GetOwnPropertyAttributes(copy, key_string);
DCHECK(maybe.has_value);
PropertyAttributes attributes = maybe.value;
DCHECK(maybe.IsJust());
PropertyAttributes attributes = maybe.FromJust();
// Only deep copy fields from the object literal expression.
// In particular, don't try to copy the length attribute of
// an array.
@ -6599,18 +6600,18 @@ MaybeHandle<Object> JSObject::DefineAccessor(Handle<JSObject> object,
Maybe<bool> maybe = HasOwnElement(object, index);
// Workaround for a GCC 4.4.3 bug which leads to "preexists may be used
// uninitialized in this function".
if (!maybe.has_value) {
if (!maybe.IsJust()) {
DCHECK(false);
return isolate->factory()->undefined_value();
}
preexists = maybe.value;
preexists = maybe.FromJust();
if (preexists && GetOwnElementAccessorPair(object, index).is_null()) {
old_value =
Object::GetElement(isolate, object, index).ToHandleChecked();
}
} else {
LookupIterator it(object, name, LookupIterator::HIDDEN_SKIP_INTERCEPTOR);
CHECK(GetPropertyAttributes(&it).has_value);
CHECK(GetPropertyAttributes(&it).IsJust());
preexists = it.IsFound();
if (preexists && (it.state() == LookupIterator::DATA ||
it.GetAccessors()->IsAccessorInfo())) {
@ -6716,7 +6717,7 @@ MaybeHandle<Object> JSObject::SetAccessor(Handle<JSObject> object,
} else {
// Lookup the name.
LookupIterator it(object, name, LookupIterator::HIDDEN_SKIP_INTERCEPTOR);
CHECK(GetPropertyAttributes(&it).has_value);
CHECK(GetPropertyAttributes(&it).IsJust());
// ES5 forbids turning a property into an accessor if it's not
// configurable. See 8.6.1 (Table 5).
if (it.IsFound() && (it.IsReadOnly() || !it.IsConfigurable())) {
@ -11804,9 +11805,9 @@ static bool GetOldValue(Isolate* isolate,
List<uint32_t>* indices) {
Maybe<PropertyAttributes> maybe =
JSReceiver::GetOwnElementAttribute(object, index);
DCHECK(maybe.has_value);
DCHECK(maybe.value != ABSENT);
if (maybe.value == DONT_DELETE) return false;
DCHECK(maybe.IsJust());
DCHECK(maybe.FromJust() != ABSENT);
if (maybe.FromJust() == DONT_DELETE) return false;
Handle<Object> value;
if (!JSObject::GetOwnElementAccessorPair(object, index).is_null()) {
value = Handle<Object>::cast(isolate->factory()->the_hole_value());
@ -13086,8 +13087,8 @@ MaybeHandle<Object> JSObject::SetElement(Handle<JSObject> object,
Maybe<PropertyAttributes> maybe =
JSReceiver::GetOwnElementAttribute(object, index);
if (!maybe.has_value) return MaybeHandle<Object>();
PropertyAttributes old_attributes = maybe.value;
if (!maybe.IsJust()) return MaybeHandle<Object>();
PropertyAttributes old_attributes = maybe.FromJust();
Handle<Object> old_value = isolate->factory()->the_hole_value();
Handle<Object> old_length_handle;
@ -13117,8 +13118,8 @@ MaybeHandle<Object> JSObject::SetElement(Handle<JSObject> object,
Handle<String> name = isolate->factory()->Uint32ToString(index);
maybe = GetOwnElementAttribute(object, index);
if (!maybe.has_value) return MaybeHandle<Object>();
PropertyAttributes new_attributes = maybe.value;
if (!maybe.IsJust()) return MaybeHandle<Object>();
PropertyAttributes new_attributes = maybe.FromJust();
if (old_attributes == ABSENT) {
if (object->IsJSArray() &&
@ -13915,7 +13916,7 @@ Maybe<bool> JSObject::HasRealNamedProperty(Handle<JSObject> object,
Handle<Name> key) {
LookupIterator it(object, key, LookupIterator::OWN_SKIP_INTERCEPTOR);
Maybe<PropertyAttributes> maybe_result = GetPropertyAttributes(&it);
if (!maybe_result.has_value) return Nothing<bool>();
if (!maybe_result.IsJust()) return Nothing<bool>();
return Just(it.IsFound());
}
@ -13944,7 +13945,7 @@ Maybe<bool> JSObject::HasRealElementProperty(Handle<JSObject> object,
Maybe<PropertyAttributes> result =
GetElementAttributeWithoutInterceptor(object, object, index, false);
return result.has_value ? Just(result.value != ABSENT) : Nothing<bool>();
return result.IsJust() ? Just(result.FromJust() != ABSENT) : Nothing<bool>();
}
@ -13952,7 +13953,7 @@ Maybe<bool> JSObject::HasRealNamedCallbackProperty(Handle<JSObject> object,
Handle<Name> key) {
LookupIterator it(object, key, LookupIterator::OWN_SKIP_INTERCEPTOR);
Maybe<PropertyAttributes> maybe_result = GetPropertyAttributes(&it);
return maybe_result.has_value ? Just(it.state() == LookupIterator::ACCESSOR)
return maybe_result.IsJust() ? Just(it.state() == LookupIterator::ACCESSOR)
: Nothing<bool>();
}

View File

@ -444,8 +444,8 @@ static bool IterateElementsSlow(Isolate* isolate, Handle<JSObject> receiver,
for (uint32_t i = 0; i < length; ++i) {
HandleScope loop_scope(isolate);
Maybe<bool> maybe = JSReceiver::HasElement(receiver, i);
if (!maybe.has_value) return false;
if (maybe.value) {
if (!maybe.IsJust()) return false;
if (maybe.FromJust()) {
Handle<Object> element_value;
ASSIGN_RETURN_ON_EXCEPTION_VALUE(
isolate, element_value,
@ -511,8 +511,8 @@ static bool IterateElements(Isolate* isolate, Handle<JSObject> receiver,
visitor->visit(j, element_value);
} else {
Maybe<bool> maybe = JSReceiver::HasElement(receiver, j);
if (!maybe.has_value) return false;
if (maybe.value) {
if (!maybe.IsJust()) return false;
if (maybe.FromJust()) {
// Call GetElement on receiver, not its prototype, or getters won't
// have the correct receiver.
ASSIGN_RETURN_ON_EXCEPTION_VALUE(
@ -547,8 +547,8 @@ static bool IterateElements(Isolate* isolate, Handle<JSObject> receiver,
visitor->visit(j, element_value);
} else {
Maybe<bool> maybe = JSReceiver::HasElement(receiver, j);
if (!maybe.has_value) return false;
if (maybe.value) {
if (!maybe.IsJust()) return false;
if (maybe.FromJust()) {
// Call GetElement on receiver, not its prototype, or getters won't
// have the correct receiver.
Handle<Object> element_value;

View File

@ -913,8 +913,8 @@ static bool SetLocalVariableValue(Isolate* isolate, JavaScriptFrame* frame,
Handle<JSObject> ext(JSObject::cast(function_context->extension()));
Maybe<bool> maybe = JSReceiver::HasProperty(ext, variable_name);
DCHECK(maybe.has_value);
if (maybe.value) {
DCHECK(maybe.IsJust());
if (maybe.FromJust()) {
// We don't expect this to do anything except replacing
// property value.
Runtime::SetObjectProperty(isolate, ext, variable_name, new_value,
@ -996,8 +996,8 @@ static bool SetClosureVariableValue(Isolate* isolate, Handle<Context> context,
if (context->has_extension()) {
Handle<JSObject> ext(JSObject::cast(context->extension()));
Maybe<bool> maybe = JSReceiver::HasProperty(ext, variable_name);
DCHECK(maybe.has_value);
if (maybe.value) {
DCHECK(maybe.IsJust());
if (maybe.FromJust()) {
// We don't expect this to do anything except replacing property value.
Runtime::DefineObjectProperty(ext, variable_name, new_value, NONE)
.Assert();
@ -2113,8 +2113,8 @@ MUST_USE_RESULT static MaybeHandle<JSObject> MaterializeArgumentsObject(
if (!function->shared()->is_function()) return target;
Maybe<bool> maybe = JSReceiver::HasOwnProperty(
target, isolate->factory()->arguments_string());
if (!maybe.has_value) return MaybeHandle<JSObject>();
if (maybe.value) return target;
if (!maybe.IsJust()) return MaybeHandle<JSObject>();
if (maybe.FromJust()) return target;
// FunctionGetArguments can't throw an exception.
Handle<JSObject> arguments =

View File

@ -368,8 +368,8 @@ MUST_USE_RESULT static MaybeHandle<Object> GetOwnProperty(Isolate* isolate,
// Get attributes.
Maybe<PropertyAttributes> maybe =
JSReceiver::GetOwnElementAttribute(obj, index);
if (!maybe.has_value) return MaybeHandle<Object>();
attrs = maybe.value;
if (!maybe.IsJust()) return MaybeHandle<Object>();
attrs = maybe.FromJust();
if (attrs == ABSENT) return factory->undefined_value();
// Get AccessorPair if present.
@ -385,8 +385,8 @@ MUST_USE_RESULT static MaybeHandle<Object> GetOwnProperty(Isolate* isolate,
// Get attributes.
LookupIterator it(obj, name, LookupIterator::HIDDEN);
Maybe<PropertyAttributes> maybe = JSObject::GetPropertyAttributes(&it);
if (!maybe.has_value) return MaybeHandle<Object>();
attrs = maybe.value;
if (!maybe.IsJust()) return MaybeHandle<Object>();
attrs = maybe.FromJust();
if (attrs == ABSENT) return factory->undefined_value();
// Get AccessorPair if present.
@ -667,7 +667,7 @@ RUNTIME_FUNCTION(Runtime_AddNamedProperty) {
DCHECK(!key->ToArrayIndex(&index));
LookupIterator it(object, key, LookupIterator::OWN_SKIP_INTERCEPTOR);
Maybe<PropertyAttributes> maybe = JSReceiver::GetPropertyAttributes(&it);
if (!maybe.has_value) return isolate->heap()->exception();
if (!maybe.IsJust()) return isolate->heap()->exception();
RUNTIME_ASSERT(!it.IsFound());
#endif
@ -736,8 +736,8 @@ static Object* HasOwnPropertyImplementation(Isolate* isolate,
Handle<JSObject> object,
Handle<Name> key) {
Maybe<bool> maybe = JSReceiver::HasOwnProperty(object, key);
if (!maybe.has_value) return isolate->heap()->exception();
if (maybe.value) return isolate->heap()->true_value();
if (!maybe.IsJust()) return isolate->heap()->exception();
if (maybe.FromJust()) return isolate->heap()->true_value();
// Handle hidden prototypes. If there's a hidden prototype above this thing
// then we have to check it for properties, because they are supposed to
// look like they are on this object.
@ -778,9 +778,9 @@ RUNTIME_FUNCTION(Runtime_HasOwnProperty) {
} else {
maybe = JSObject::HasRealNamedProperty(js_obj, key);
}
if (!maybe.has_value) return isolate->heap()->exception();
if (!maybe.IsJust()) return isolate->heap()->exception();
DCHECK(!isolate->has_pending_exception());
if (maybe.value) {
if (maybe.FromJust()) {
return isolate->heap()->true_value();
}
Map* map = js_obj->map();
@ -809,8 +809,8 @@ RUNTIME_FUNCTION(Runtime_HasProperty) {
CONVERT_ARG_HANDLE_CHECKED(Name, key, 1);
Maybe<bool> maybe = JSReceiver::HasProperty(receiver, key);
if (!maybe.has_value) return isolate->heap()->exception();
return isolate->heap()->ToBoolean(maybe.value);
if (!maybe.IsJust()) return isolate->heap()->exception();
return isolate->heap()->ToBoolean(maybe.FromJust());
}
@ -821,8 +821,8 @@ RUNTIME_FUNCTION(Runtime_HasElement) {
CONVERT_SMI_ARG_CHECKED(index, 1);
Maybe<bool> maybe = JSReceiver::HasElement(receiver, index);
if (!maybe.has_value) return isolate->heap()->exception();
return isolate->heap()->ToBoolean(maybe.value);
if (!maybe.IsJust()) return isolate->heap()->exception();
return isolate->heap()->ToBoolean(maybe.FromJust());
}
@ -835,9 +835,9 @@ RUNTIME_FUNCTION(Runtime_IsPropertyEnumerable) {
Maybe<PropertyAttributes> maybe =
JSReceiver::GetOwnPropertyAttributes(object, key);
if (!maybe.has_value) return isolate->heap()->exception();
if (maybe.value == ABSENT) maybe.value = DONT_ENUM;
return isolate->heap()->ToBoolean((maybe.value & DONT_ENUM) == 0);
if (!maybe.IsJust()) return isolate->heap()->exception();
if (maybe.FromJust() == ABSENT) maybe = Just(DONT_ENUM);
return isolate->heap()->ToBoolean((maybe.FromJust() & DONT_ENUM) == 0);
}

View File

@ -46,10 +46,10 @@ static Object* DeclareGlobals(Isolate* isolate, Handle<GlobalObject> global,
// Do the lookup own properties only, see ES5 erratum.
LookupIterator it(global, name, LookupIterator::HIDDEN_SKIP_INTERCEPTOR);
Maybe<PropertyAttributes> maybe = JSReceiver::GetPropertyAttributes(&it);
if (!maybe.has_value) return isolate->heap()->exception();
if (!maybe.IsJust()) return isolate->heap()->exception();
if (it.IsFound()) {
PropertyAttributes old_attributes = maybe.value;
PropertyAttributes old_attributes = maybe.FromJust();
// The name was declared before; check for conflicting re-declarations.
if (is_const) return ThrowRedeclarationError(isolate, name);
@ -178,8 +178,8 @@ RUNTIME_FUNCTION(Runtime_InitializeConstGlobal) {
// Lookup the property as own on the global object.
LookupIterator it(global, name, LookupIterator::HIDDEN_SKIP_INTERCEPTOR);
Maybe<PropertyAttributes> maybe = JSReceiver::GetPropertyAttributes(&it);
DCHECK(maybe.has_value);
PropertyAttributes old_attributes = maybe.value;
DCHECK(maybe.IsJust());
PropertyAttributes old_attributes = maybe.FromJust();
PropertyAttributes attr =
static_cast<PropertyAttributes>(DONT_DELETE | READ_ONLY);
@ -331,8 +331,8 @@ RUNTIME_FUNCTION(Runtime_InitializeLegacyConstLookupSlot) {
LookupIterator it(holder, name, LookupIterator::HIDDEN_SKIP_INTERCEPTOR);
Maybe<PropertyAttributes> maybe = JSReceiver::GetPropertyAttributes(&it);
if (!maybe.has_value) return isolate->heap()->exception();
PropertyAttributes old_attributes = maybe.value;
if (!maybe.IsJust()) return isolate->heap()->exception();
PropertyAttributes old_attributes = maybe.FromJust();
// Ignore if we can't reconfigure the value.
if ((old_attributes & DONT_DELETE) != 0) {
@ -596,8 +596,8 @@ static Object* FindNameClash(Handle<ScopeInfo> scope_info,
LookupIterator it(global_object, name,
LookupIterator::HIDDEN_SKIP_INTERCEPTOR);
Maybe<PropertyAttributes> maybe = JSReceiver::GetPropertyAttributes(&it);
if (!maybe.has_value) return isolate->heap()->exception();
if ((maybe.value & DONT_DELETE) != 0) {
if (!maybe.IsJust()) return isolate->heap()->exception();
if ((maybe.FromJust() & DONT_DELETE) != 0) {
return ThrowRedeclarationError(isolate, name);
}

View File

@ -10716,8 +10716,7 @@ THREADED_TEST(VariousGetPropertiesAndThrowingCallbacks) {
Maybe<PropertyAttribute> attr =
instance->GetRealNamedPropertyAttributes(v8_str("f"));
CHECK(!try_catch.HasCaught());
CHECK(attr.has_value);
CHECK_EQ(attr.value, None);
CHECK(Just(None) == attr);
result = another->GetRealNamedProperty(v8_str("f"));
CHECK(try_catch.HasCaught());
@ -10726,8 +10725,7 @@ THREADED_TEST(VariousGetPropertiesAndThrowingCallbacks) {
attr = another->GetRealNamedPropertyAttributes(v8_str("f"));
CHECK(!try_catch.HasCaught());
CHECK(attr.has_value);
CHECK_EQ(attr.value, None);
CHECK(Just(None) == attr);
result = another->GetRealNamedPropertyInPrototypeChain(v8_str("f"));
CHECK(try_catch.HasCaught());
@ -10736,8 +10734,7 @@ THREADED_TEST(VariousGetPropertiesAndThrowingCallbacks) {
attr = another->GetRealNamedPropertyAttributesInPrototypeChain(v8_str("f"));
CHECK(!try_catch.HasCaught());
CHECK(attr.has_value);
CHECK_EQ(attr.value, None);
CHECK(Just(None) == attr);
result = another->Get(v8_str("f"));
CHECK(try_catch.HasCaught());
@ -10751,8 +10748,7 @@ THREADED_TEST(VariousGetPropertiesAndThrowingCallbacks) {
attr = with_js_getter->GetRealNamedPropertyAttributes(v8_str("f"));
CHECK(!try_catch.HasCaught());
CHECK(attr.has_value);
CHECK_EQ(attr.value, None);
CHECK(Just(None) == attr);
result = with_js_getter->Get(v8_str("f"));
CHECK(try_catch.HasCaught());

View File

@ -40,6 +40,7 @@
#include "test/cctest/cctest.h"
using namespace v8::internal;
using v8::Just;
static void CheckMap(Map* map, int type, int instance_size) {
CHECK(map->IsHeapObject());
@ -191,9 +192,7 @@ TEST(HeapObjects) {
Handle<String> object_string = Handle<String>::cast(factory->Object_string());
Handle<GlobalObject> global(CcTest::i_isolate()->context()->global_object());
v8::Maybe<bool> maybe = JSReceiver::HasOwnProperty(global, object_string);
CHECK(maybe.has_value);
CHECK(maybe.value);
CHECK(Just(true) == JSReceiver::HasOwnProperty(global, object_string));
// Check ToString for oddballs
CheckOddball(isolate, heap->true_value(), "true");
@ -260,9 +259,7 @@ TEST(GarbageCollection) {
heap->CollectGarbage(NEW_SPACE);
// Function should be alive.
v8::Maybe<bool> maybe = JSReceiver::HasOwnProperty(global, name);
CHECK(maybe.has_value);
CHECK(maybe.value);
CHECK(Just(true) == JSReceiver::HasOwnProperty(global, name));
// Check function is retained.
Handle<Object> func_value =
Object::GetProperty(global, name).ToHandleChecked();
@ -280,9 +277,7 @@ TEST(GarbageCollection) {
// After gc, it should survive.
heap->CollectGarbage(NEW_SPACE);
maybe = JSReceiver::HasOwnProperty(global, obj_name);
CHECK(maybe.has_value);
CHECK(maybe.value);
CHECK(Just(true) == JSReceiver::HasOwnProperty(global, obj_name));
Handle<Object> obj =
Object::GetProperty(global, obj_name).ToHandleChecked();
CHECK(obj->IsJSObject());
@ -639,85 +634,55 @@ TEST(ObjectProperties) {
Handle<Smi> two(Smi::FromInt(2), isolate);
// check for empty
v8::Maybe<bool> maybe = JSReceiver::HasOwnProperty(obj, first);
CHECK(maybe.has_value);
CHECK(!maybe.value);
CHECK(Just(false) == JSReceiver::HasOwnProperty(obj, first));
// add first
JSReceiver::SetProperty(obj, first, one, SLOPPY).Check();
maybe = JSReceiver::HasOwnProperty(obj, first);
CHECK(maybe.has_value);
CHECK(maybe.value);
CHECK(Just(true) == JSReceiver::HasOwnProperty(obj, first));
// delete first
JSReceiver::DeleteProperty(obj, first, SLOPPY).Check();
maybe = JSReceiver::HasOwnProperty(obj, first);
CHECK(maybe.has_value);
CHECK(!maybe.value);
CHECK(Just(false) == JSReceiver::HasOwnProperty(obj, first));
// add first and then second
JSReceiver::SetProperty(obj, first, one, SLOPPY).Check();
JSReceiver::SetProperty(obj, second, two, SLOPPY).Check();
maybe = JSReceiver::HasOwnProperty(obj, first);
CHECK(maybe.has_value);
CHECK(maybe.value);
maybe = JSReceiver::HasOwnProperty(obj, second);
CHECK(maybe.has_value);
CHECK(maybe.value);
CHECK(Just(true) == JSReceiver::HasOwnProperty(obj, first));
CHECK(Just(true) == JSReceiver::HasOwnProperty(obj, second));
// delete first and then second
JSReceiver::DeleteProperty(obj, first, SLOPPY).Check();
maybe = JSReceiver::HasOwnProperty(obj, second);
CHECK(maybe.has_value);
CHECK(maybe.value);
CHECK(Just(true) == JSReceiver::HasOwnProperty(obj, second));
JSReceiver::DeleteProperty(obj, second, SLOPPY).Check();
maybe = JSReceiver::HasOwnProperty(obj, first);
CHECK(maybe.has_value);
CHECK(!maybe.value);
maybe = JSReceiver::HasOwnProperty(obj, second);
CHECK(maybe.has_value);
CHECK(!maybe.value);
CHECK(Just(false) == JSReceiver::HasOwnProperty(obj, first));
CHECK(Just(false) == JSReceiver::HasOwnProperty(obj, second));
// add first and then second
JSReceiver::SetProperty(obj, first, one, SLOPPY).Check();
JSReceiver::SetProperty(obj, second, two, SLOPPY).Check();
maybe = JSReceiver::HasOwnProperty(obj, first);
CHECK(maybe.has_value);
CHECK(maybe.value);
maybe = JSReceiver::HasOwnProperty(obj, second);
CHECK(maybe.has_value);
CHECK(maybe.value);
CHECK(Just(true) == JSReceiver::HasOwnProperty(obj, first));
CHECK(Just(true) == JSReceiver::HasOwnProperty(obj, second));
// delete second and then first
JSReceiver::DeleteProperty(obj, second, SLOPPY).Check();
maybe = JSReceiver::HasOwnProperty(obj, first);
CHECK(maybe.has_value);
CHECK(maybe.value);
CHECK(Just(true) == JSReceiver::HasOwnProperty(obj, first));
JSReceiver::DeleteProperty(obj, first, SLOPPY).Check();
maybe = JSReceiver::HasOwnProperty(obj, first);
CHECK(maybe.has_value);
CHECK(!maybe.value);
maybe = JSReceiver::HasOwnProperty(obj, second);
CHECK(maybe.has_value);
CHECK(!maybe.value);
CHECK(Just(false) == JSReceiver::HasOwnProperty(obj, first));
CHECK(Just(false) == JSReceiver::HasOwnProperty(obj, second));
// check string and internalized string match
const char* string1 = "fisk";
Handle<String> s1 = factory->NewStringFromAsciiChecked(string1);
JSReceiver::SetProperty(obj, s1, one, SLOPPY).Check();
Handle<String> s1_string = factory->InternalizeUtf8String(string1);
maybe = JSReceiver::HasOwnProperty(obj, s1_string);
CHECK(maybe.has_value);
CHECK(maybe.value);
CHECK(Just(true) == JSReceiver::HasOwnProperty(obj, s1_string));
// check internalized string and string match
const char* string2 = "fugl";
Handle<String> s2_string = factory->InternalizeUtf8String(string2);
JSReceiver::SetProperty(obj, s2_string, one, SLOPPY).Check();
Handle<String> s2 = factory->NewStringFromAsciiChecked(string2);
maybe = JSReceiver::HasOwnProperty(obj, s2);
CHECK(maybe.has_value);
CHECK(maybe.value);
CHECK(Just(true) == JSReceiver::HasOwnProperty(obj, s2));
}

View File

@ -45,6 +45,7 @@
#include "test/cctest/cctest.h"
using namespace v8::internal;
using v8::Just;
TEST(MarkingDeque) {
@ -167,9 +168,7 @@ TEST(MarkCompactCollector) {
{ HandleScope scope(isolate);
Handle<String> func_name = factory->InternalizeUtf8String("theFunction");
v8::Maybe<bool> maybe = JSReceiver::HasOwnProperty(global, func_name);
CHECK(maybe.has_value);
CHECK(maybe.value);
CHECK(Just(true) == JSReceiver::HasOwnProperty(global, func_name));
Handle<Object> func_value =
Object::GetProperty(global, func_name).ToHandleChecked();
CHECK(func_value->IsJSFunction());
@ -187,9 +186,7 @@ TEST(MarkCompactCollector) {
{ HandleScope scope(isolate);
Handle<String> obj_name = factory->InternalizeUtf8String("theObject");
v8::Maybe<bool> maybe = JSReceiver::HasOwnProperty(global, obj_name);
CHECK(maybe.has_value);
CHECK(maybe.value);
CHECK(Just(true) == JSReceiver::HasOwnProperty(global, obj_name));
Handle<Object> object =
Object::GetProperty(global, obj_name).ToHandleChecked();
CHECK(object->IsJSObject());