Skip to content

Commit dc2e306

Browse files
camillobruniCommit bot
authored andcommitted
Reland of place all remaining Oddball checks with new function (patchset #1 id:1 of https://codereview.chromium.org/2060213002/ )
Reason for revert: Cannot reproduce gc-stress failures locally. Original issue's description: > Revert of Replace all remaining Oddball checks with new function (patchset v8#10 id:180001 of https://codereview.chromium.org/2043183003/ ) > > Reason for revert: > failing tests > > Original issue's description: > > Replace all remaining Oddball checks with new function > > > > This CL removes the IsUndefined() and Co. methods from Object and HeapObject. > > The new method all take the isolate as parameter. > > > > BUG= > > > > Committed: https://crrev.com/ccefb3ae5fe967288d568013fb04e8761eafebc5 > > Cr-Commit-Position: refs/heads/master@{#36921} > > TBR=mstarzinger@chromium.org,verwaest@chromium.org,yangguo@chromium.org,ahaas@chromium.org > # Skipping CQ checks because original CL landed less than 1 days ago. > NOPRESUBMIT=true > NOTREECHECKS=true > NOTRY=true > BUG= > > Committed: https://crrev.com/33b8bc24a12fb062100c0be84456faeb0b9fa5d1 > Cr-Commit-Position: refs/heads/master@{#36923} TBR=mstarzinger@chromium.org,verwaest@chromium.org,yangguo@chromium.org,ahaas@chromium.org BUG= Review-Url: https://codereview.chromium.org/2059173002 Cr-Commit-Position: refs/heads/master@{#36957}
1 parent c1b2499 commit dc2e306

65 files changed

Lines changed: 294 additions & 245 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

src/api-natives.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -287,7 +287,7 @@ void UncacheTemplateInstantiation(Isolate* isolate, uint32_t serial_number) {
287287
Handle<Object> result =
288288
UnseededNumberDictionary::DeleteProperty(cache, entry);
289289
USE(result);
290-
DCHECK(result->IsTrue());
290+
DCHECK(result->IsTrue(isolate));
291291
auto new_cache = UnseededNumberDictionary::Shrink(cache, entry);
292292
isolate->native_context()->set_template_instantiations_cache(*new_cache);
293293
}

src/api.cc

Lines changed: 31 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2603,7 +2603,7 @@ static bool getBoolProperty(const StackFrame* f, const char* propertyName) {
26032603
i::Handle<i::JSObject> self = Utils::OpenHandle(f);
26042604
i::Handle<i::Object> obj =
26052605
i::JSReceiver::GetProperty(isolate, self, propertyName).ToHandleChecked();
2606-
return obj->IsTrue();
2606+
return obj->IsTrue(isolate);
26072607
}
26082608

26092609
bool StackFrame::IsEval() const { return getBoolProperty(this, "isEval"); }
@@ -2771,26 +2771,38 @@ MaybeLocal<String> JSON::Stringify(Local<Context> context,
27712771
// --- D a t a ---
27722772

27732773
bool Value::FullIsUndefined() const {
2774-
bool result = Utils::OpenHandle(this)->IsUndefined();
2774+
i::Handle<i::Object> object = Utils::OpenHandle(this);
2775+
bool result = false;
2776+
if (!object->IsSmi()) {
2777+
result = object->IsUndefined(i::HeapObject::cast(*object)->GetIsolate());
2778+
}
27752779
DCHECK_EQ(result, QuickIsUndefined());
27762780
return result;
27772781
}
27782782

27792783

27802784
bool Value::FullIsNull() const {
2781-
bool result = Utils::OpenHandle(this)->IsNull();
2785+
i::Handle<i::Object> object = Utils::OpenHandle(this);
2786+
bool result = false;
2787+
if (!object->IsSmi()) {
2788+
result = object->IsNull(i::HeapObject::cast(*object)->GetIsolate());
2789+
}
27822790
DCHECK_EQ(result, QuickIsNull());
27832791
return result;
27842792
}
27852793

27862794

27872795
bool Value::IsTrue() const {
2788-
return Utils::OpenHandle(this)->IsTrue();
2796+
i::Handle<i::Object> object = Utils::OpenHandle(this);
2797+
if (object->IsSmi()) return false;
2798+
return object->IsTrue(i::HeapObject::cast(*object)->GetIsolate());
27892799
}
27902800

27912801

27922802
bool Value::IsFalse() const {
2793-
return Utils::OpenHandle(this)->IsFalse();
2803+
i::Handle<i::Object> object = Utils::OpenHandle(this);
2804+
if (object->IsSmi()) return false;
2805+
return object->IsFalse(i::HeapObject::cast(*object)->GetIsolate());
27942806
}
27952807

27962808

@@ -4039,7 +4051,7 @@ static Maybe<bool> ObjectSetAccessor(Local<Context> context, Object* self,
40394051
has_pending_exception =
40404052
!i::JSObject::SetAccessor(obj, info).ToHandle(&result);
40414053
RETURN_ON_FAILED_EXECUTION_PRIMITIVE(bool);
4042-
if (result->IsUndefined()) return Nothing<bool>();
4054+
if (result->IsUndefined(obj->GetIsolate())) return Nothing<bool>();
40434055
if (fast) {
40444056
i::JSObject::MigrateSlowToFast(obj, 0, "APISetAccessor");
40454057
}
@@ -5329,7 +5341,7 @@ double Number::Value() const {
53295341

53305342
bool Boolean::Value() const {
53315343
i::Handle<i::Object> obj = Utils::OpenHandle(this);
5332-
return obj->IsTrue();
5344+
return obj->IsTrue(i::HeapObject::cast(*obj)->GetIsolate());
53335345
}
53345346

53355347

@@ -5420,7 +5432,10 @@ void v8::Object::SetAlignedPointerInInternalField(int index, void* value) {
54205432

54215433
static void* ExternalValue(i::Object* obj) {
54225434
// Obscure semantics for undefined, but somehow checked in our unit tests...
5423-
if (obj->IsUndefined()) return NULL;
5435+
if (!obj->IsSmi() &&
5436+
obj->IsUndefined(i::HeapObject::cast(obj)->GetIsolate())) {
5437+
return NULL;
5438+
}
54245439
i::Object* foreign = i::JSObject::cast(obj)->GetInternalField(0);
54255440
return i::Foreign::cast(foreign)->foreign_address();
54265441
}
@@ -5673,7 +5688,8 @@ void Context::AllowCodeGenerationFromStrings(bool allow) {
56735688

56745689
bool Context::IsCodeGenerationFromStringsAllowed() {
56755690
i::Handle<i::Context> context = Utils::OpenHandle(this);
5676-
return !context->allow_code_gen_from_strings()->IsFalse();
5691+
return !context->allow_code_gen_from_strings()->IsFalse(
5692+
context->GetIsolate());
56775693
}
56785694

56795695

@@ -6057,7 +6073,7 @@ bool v8::BooleanObject::ValueOf() const {
60576073
i::Handle<i::JSValue> jsvalue = i::Handle<i::JSValue>::cast(obj);
60586074
i::Isolate* isolate = jsvalue->GetIsolate();
60596075
LOG_API(isolate, BooleanObject, BooleanValue);
6060-
return jsvalue->value()->IsTrue();
6076+
return jsvalue->value()->IsTrue(isolate);
60616077
}
60626078

60636079

@@ -6304,7 +6320,7 @@ Maybe<bool> Map::Has(Local<Context> context, Local<Value> key) {
63046320
arraysize(argv), argv)
63056321
.ToHandle(&result);
63066322
RETURN_ON_FAILED_EXECUTION_PRIMITIVE(bool);
6307-
return Just(result->IsTrue());
6323+
return Just(result->IsTrue(isolate));
63086324
}
63096325

63106326

@@ -6317,7 +6333,7 @@ Maybe<bool> Map::Delete(Local<Context> context, Local<Value> key) {
63176333
self, arraysize(argv), argv)
63186334
.ToHandle(&result);
63196335
RETURN_ON_FAILED_EXECUTION_PRIMITIVE(bool);
6320-
return Just(result->IsTrue());
6336+
return Just(result->IsTrue(isolate));
63216337
}
63226338

63236339

@@ -6396,7 +6412,7 @@ Maybe<bool> Set::Has(Local<Context> context, Local<Value> key) {
63966412
arraysize(argv), argv)
63976413
.ToHandle(&result);
63986414
RETURN_ON_FAILED_EXECUTION_PRIMITIVE(bool);
6399-
return Just(result->IsTrue());
6415+
return Just(result->IsTrue(isolate));
64006416
}
64016417

64026418

@@ -6409,7 +6425,7 @@ Maybe<bool> Set::Delete(Local<Context> context, Local<Value> key) {
64096425
self, arraysize(argv), argv)
64106426
.ToHandle(&result);
64116427
RETURN_ON_FAILED_EXECUTION_PRIMITIVE(bool);
6412-
return Just(result->IsTrue());
6428+
return Just(result->IsTrue(isolate));
64136429
}
64146430

64156431

@@ -6583,7 +6599,7 @@ bool Promise::HasHandler() {
65836599
LOG_API(isolate, Promise, HasRejectHandler);
65846600
ENTER_V8(isolate);
65856601
i::Handle<i::Symbol> key = isolate->factory()->promise_has_handler_symbol();
6586-
return i::JSReceiver::GetDataProperty(promise, key)->IsTrue();
6602+
return i::JSReceiver::GetDataProperty(promise, key)->IsTrue(isolate);
65876603
}
65886604

65896605

src/api.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -281,7 +281,9 @@ OPEN_HANDLE_LIST(DECLARE_OPEN_HANDLE)
281281

282282
template<class From, class To>
283283
static inline Local<To> Convert(v8::internal::Handle<From> obj) {
284-
DCHECK(obj.is_null() || !obj->IsTheHole());
284+
DCHECK(obj.is_null() ||
285+
(obj->IsSmi() ||
286+
!obj->IsTheHole(i::HeapObject::cast(*obj)->GetIsolate())));
285287
return Local<To>(reinterpret_cast<To*>(obj.location()));
286288
}
287289

src/ast/ast.cc

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -59,12 +59,19 @@ bool Expression::IsStringLiteral() const {
5959

6060

6161
bool Expression::IsNullLiteral() const {
62-
return IsLiteral() && AsLiteral()->value()->IsNull();
62+
if (!IsLiteral()) return false;
63+
Handle<Object> value = AsLiteral()->value();
64+
return !value->IsSmi() &&
65+
value->IsNull(HeapObject::cast(*value)->GetIsolate());
6366
}
6467

6568
bool Expression::IsUndefinedLiteral() const {
66-
if (IsLiteral() && AsLiteral()->value()->IsUndefined()) {
67-
return true;
69+
if (IsLiteral()) {
70+
Handle<Object> value = AsLiteral()->value();
71+
if (!value->IsSmi() &&
72+
value->IsUndefined(HeapObject::cast(*value)->GetIsolate())) {
73+
return true;
74+
}
6875
}
6976

7077
const VariableProxy* var_proxy = AsVariableProxy();
@@ -387,7 +394,7 @@ void ObjectLiteral::CalculateEmitStore(Zone* zone) {
387394
if (property->is_computed_name()) continue;
388395
if (property->kind() == ObjectLiteral::Property::PROTOTYPE) continue;
389396
Literal* literal = property->key()->AsLiteral();
390-
DCHECK(!literal->value()->IsNull());
397+
DCHECK(!literal->IsNullLiteral());
391398

392399
// If there is an existing entry do not emit a store unless the previous
393400
// entry was also an accessor.
@@ -457,11 +464,11 @@ void ObjectLiteral::BuildConstantProperties(Isolate* isolate) {
457464
// (value->IsNumber()).
458465
// TODO(verwaest): Remove once we can store them inline.
459466
if (FLAG_track_double_fields &&
460-
(value->IsNumber() || value->IsUninitialized())) {
467+
(value->IsNumber() || value->IsUninitialized(isolate))) {
461468
may_store_doubles_ = true;
462469
}
463470

464-
is_simple = is_simple && !value->IsUninitialized();
471+
is_simple = is_simple && !value->IsUninitialized(isolate);
465472

466473
// Keep track of the number of elements in the object literal and
467474
// the largest element index. If the largest element index is
@@ -529,7 +536,7 @@ void ArrayLiteral::BuildConstantElements(Isolate* isolate) {
529536
continue;
530537
}
531538

532-
if (boilerplate_value->IsUninitialized()) {
539+
if (boilerplate_value->IsUninitialized(isolate)) {
533540
boilerplate_value = handle(Smi::FromInt(0), isolate);
534541
is_simple = false;
535542
}

src/ast/prettyprinter.cc

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -441,11 +441,11 @@ void CallPrinter::PrintLiteral(Object* value, bool quote) {
441441
if (quote) Print("\"");
442442
Print("%s", String::cast(object)->ToCString().get());
443443
if (quote) Print("\"");
444-
} else if (object->IsNull()) {
444+
} else if (object->IsNull(isolate_)) {
445445
Print("null");
446-
} else if (object->IsTrue()) {
446+
} else if (object->IsTrue(isolate_)) {
447447
Print("true");
448-
} else if (object->IsFalse()) {
448+
} else if (object->IsFalse(isolate_)) {
449449
Print("false");
450450
} else if (object->IsUndefined(isolate_)) {
451451
Print("undefined");
@@ -1069,11 +1069,11 @@ void PrettyPrinter::PrintLiteral(Handle<Object> value, bool quote) {
10691069
Print("%c", string->Get(i));
10701070
}
10711071
if (quote) Print("\"");
1072-
} else if (object->IsNull()) {
1072+
} else if (object->IsNull(isolate_)) {
10731073
Print("null");
1074-
} else if (object->IsTrue()) {
1074+
} else if (object->IsTrue(isolate_)) {
10751075
Print("true");
1076-
} else if (object->IsFalse()) {
1076+
} else if (object->IsFalse(isolate_)) {
10771077
Print("false");
10781078
} else if (object->IsUndefined(isolate_)) {
10791079
Print("undefined");

src/builtins.cc

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,8 @@ BUILTIN_LIST_C(DEF_ARG_TYPE)
185185
// or converts the receiver to a String otherwise and assigns it to a new var
186186
// with the given {name}.
187187
#define TO_THIS_STRING(name, method) \
188-
if (args.receiver()->IsNull() || args.receiver()->IsUndefined(isolate)) { \
188+
if (args.receiver()->IsNull(isolate) || \
189+
args.receiver()->IsUndefined(isolate)) { \
189190
THROW_NEW_ERROR_RETURN_FAILURE( \
190191
isolate, \
191192
NewTypeError(MessageTemplate::kCalledOnNullOrUndefined, \
@@ -213,11 +214,11 @@ inline bool ClampedToInteger(Isolate* isolate, Object* object, int* out) {
213214
*out = static_cast<int>(value);
214215
}
215216
return true;
216-
} else if (object->IsUndefined(isolate) || object->IsNull()) {
217+
} else if (object->IsUndefined(isolate) || object->IsNull(isolate)) {
217218
*out = 0;
218219
return true;
219220
} else if (object->IsBoolean()) {
220-
*out = object->IsTrue();
221+
*out = object->IsTrue(isolate);
221222
return true;
222223
}
223224
return false;
@@ -1495,7 +1496,7 @@ BUILTIN(ArrayConcat) {
14951496

14961497
Handle<Object> receiver = args.receiver();
14971498
// TODO(bmeurer): Do we really care about the exact exception message here?
1498-
if (receiver->IsNull() || receiver->IsUndefined(isolate)) {
1499+
if (receiver->IsNull(isolate) || receiver->IsUndefined(isolate)) {
14991500
THROW_NEW_ERROR_RETURN_FAILURE(
15001501
isolate, NewTypeError(MessageTemplate::kCalledOnNullOrUndefined,
15011502
isolate->factory()->NewStringFromAsciiChecked(
@@ -1675,7 +1676,7 @@ BUILTIN(ObjectAssign) {
16751676
BUILTIN(ObjectCreate) {
16761677
HandleScope scope(isolate);
16771678
Handle<Object> prototype = args.atOrUndefined(isolate, 1);
1678-
if (!prototype->IsNull() && !prototype->IsJSReceiver()) {
1679+
if (!prototype->IsNull(isolate) && !prototype->IsJSReceiver()) {
16791680
THROW_NEW_ERROR_RETURN_FAILURE(
16801681
isolate, NewTypeError(MessageTemplate::kProtoObjectOrNull, prototype));
16811682
}
@@ -2180,7 +2181,7 @@ namespace {
21802181

21812182
bool CodeGenerationFromStringsAllowed(Isolate* isolate,
21822183
Handle<Context> context) {
2183-
DCHECK(context->allow_code_gen_from_strings()->IsFalse());
2184+
DCHECK(context->allow_code_gen_from_strings()->IsFalse(isolate));
21842185
// Check with callback if set.
21852186
AllowCodeGenerationFromStringsCallback callback =
21862187
isolate->allow_code_gen_callback();
@@ -2203,7 +2204,7 @@ MaybeHandle<JSFunction> CompileString(Handle<Context> context,
22032204

22042205
// Check if native context allows code generation from
22052206
// strings. Throw an exception if it doesn't.
2206-
if (native_context->allow_code_gen_from_strings()->IsFalse() &&
2207+
if (native_context->allow_code_gen_from_strings()->IsFalse(isolate) &&
22072208
!CodeGenerationFromStringsAllowed(isolate, native_context)) {
22082209
Handle<Object> error_message =
22092210
native_context->ErrorMessageForCodeGenerationFromStrings();
@@ -2904,7 +2905,7 @@ BUILTIN(ReflectSetPrototypeOf) {
29042905
"Reflect.setPrototypeOf")));
29052906
}
29062907

2907-
if (!proto->IsJSReceiver() && !proto->IsNull()) {
2908+
if (!proto->IsJSReceiver() && !proto->IsNull(isolate)) {
29082909
THROW_NEW_ERROR_RETURN_FAILURE(
29092910
isolate, NewTypeError(MessageTemplate::kProtoObjectOrNull, proto));
29102911
}
@@ -3330,7 +3331,7 @@ double ParseDateTimeString(Handle<String> str) {
33303331
double const time = MakeTime(tmp->get(3)->Number(), tmp->get(4)->Number(),
33313332
tmp->get(5)->Number(), tmp->get(6)->Number());
33323333
double date = MakeDate(day, time);
3333-
if (tmp->get(7)->IsNull()) {
3334+
if (tmp->get(7)->IsNull(isolate)) {
33343335
if (!std::isnan(date)) {
33353336
date = isolate->date_cache()->ToUTC(static_cast<int64_t>(date));
33363337
}
@@ -5091,7 +5092,7 @@ MUST_USE_RESULT MaybeHandle<Object> HandleApiCallHelper(
50915092

50925093
Object* raw_holder = fun_data->GetCompatibleReceiver(isolate, *receiver);
50935094

5094-
if (raw_holder->IsNull()) {
5095+
if (raw_holder->IsNull(isolate)) {
50955096
// This function cannot be called with the given receiver. Abort!
50965097
THROW_NEW_ERROR(isolate, NewTypeError(MessageTemplate::kIllegalInvocation),
50975098
Object);

src/code-stubs.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4502,8 +4502,8 @@ bool ToBooleanICStub::Types::UpdateStatus(Isolate* isolate,
45024502
return false;
45034503
} else if (object->IsBoolean()) {
45044504
Add(BOOLEAN);
4505-
return object->IsTrue();
4506-
} else if (object->IsNull()) {
4505+
return object->IsTrue(isolate);
4506+
} else if (object->IsNull(isolate)) {
45074507
Add(NULL_TYPE);
45084508
return false;
45094509
} else if (object->IsSmi()) {

src/compiler/access-info.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -321,7 +321,7 @@ bool AccessInfoFactory::ComputePropertyAccessInfo(
321321
.ToHandle(&constructor)) {
322322
map = handle(constructor->initial_map(), isolate());
323323
DCHECK(map->prototype()->IsJSObject());
324-
} else if (map->prototype()->IsNull()) {
324+
} else if (map->prototype()->IsNull(isolate())) {
325325
// Store to property not found on the receiver or any prototype, we need
326326
// to transition to a new data property.
327327
// Implemented according to ES6 section 9.1.9 [[Set]] (P, V, Receiver)

src/compiler/js-call-reducer.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -269,7 +269,7 @@ Reduction JSCallReducer::ReduceJSCallFunction(Node* node) {
269269
isolate());
270270
CallFunctionParameters const& p = CallFunctionParametersOf(node->op());
271271
ConvertReceiverMode const convert_mode =
272-
(bound_this->IsNull() || bound_this->IsUndefined(isolate()))
272+
(bound_this->IsNull(isolate()) || bound_this->IsUndefined(isolate()))
273273
? ConvertReceiverMode::kNullOrUndefined
274274
: ConvertReceiverMode::kNotNullOrUndefined;
275275
size_t arity = p.arity();

src/compiler/js-create-lowering.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -965,7 +965,7 @@ Node* JSCreateLowering::AllocateFastLiteral(
965965
graph()->NewNode(common()->FinishRegion(), value, effect);
966966
} else if (property_details.representation().IsSmi()) {
967967
// Ensure that value is stored as smi.
968-
value = boilerplate_value->IsUninitialized()
968+
value = boilerplate_value->IsUninitialized(isolate())
969969
? jsgraph()->ZeroConstant()
970970
: jsgraph()->Constant(boilerplate_value);
971971
} else {

0 commit comments

Comments
 (0)