[cleanup] Avoid {Object::operator->}

This CL was generated by an automatic clang AST rewriter using this
matcher expression:

  callExpr(
    callee(
      cxxMethodDecl(
        hasName("operator->"),
        ofClass(isSameOrDerivedFrom("v8::internal::Object"))
      )
    ),
    argumentCountIs(1)
  )

The "->" at the expression location was then rewritten to ".".

R=jkummerow@chromium.org
TBR=mstarzinger@chromium.org,verwaest@chromium.org,yangguo@chromium.org

Bug: v8:9183, v8:3770
No-Try: true
No-Tree-Checks: true
Change-Id: I0a7ecabdeafe51d0cf427f5280af0c7cab96869e
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1624209
Reviewed-by: Clemens Hammacher <clemensh@chromium.org>
Reviewed-by: Jakob Kummerow <jkummerow@chromium.org>
Reviewed-by: Toon Verwaest <verwaest@chromium.org>
Commit-Queue: Yang Guo <yangguo@chromium.org>
Commit-Queue: Clemens Hammacher <clemensh@chromium.org>
Cr-Commit-Position: refs/heads/master@{#61764}
This commit is contained in:
Clemens Hammacher 2019-05-23 09:47:44 +02:00 committed by Commit Bot
parent f1d016229c
commit 878ccb33bd
393 changed files with 9074 additions and 9171 deletions

View File

@ -18,7 +18,7 @@ RootIndexMap::RootIndexMap(Isolate* isolate) {
for (RootIndex root_index = RootIndex::kFirstStrongOrReadOnlyRoot; for (RootIndex root_index = RootIndex::kFirstStrongOrReadOnlyRoot;
root_index <= RootIndex::kLastStrongOrReadOnlyRoot; ++root_index) { root_index <= RootIndex::kLastStrongOrReadOnlyRoot; ++root_index) {
Object root = isolate->root(root_index); Object root = isolate->root(root_index);
if (!root->IsHeapObject()) continue; if (!root.IsHeapObject()) continue;
// Omit root entries that can be written after initialization. They must // Omit root entries that can be written after initialization. They must
// not be referenced through the root list in the snapshot. // not be referenced through the root list in the snapshot.
// Since we map the raw address of an root item to its root list index, the // Since we map the raw address of an root item to its root list index, the

View File

@ -39,7 +39,7 @@ void AllocationSiteUsageContext::ExitScope(Handle<AllocationSite> scope_site,
} }
bool AllocationSiteUsageContext::ShouldCreateMemento(Handle<JSObject> object) { bool AllocationSiteUsageContext::ShouldCreateMemento(Handle<JSObject> object) {
if (activated_ && AllocationSite::CanTrack(object->map()->instance_type())) { if (activated_ && AllocationSite::CanTrack(object->map().instance_type())) {
if (FLAG_allocation_site_pretenuring || if (FLAG_allocation_site_pretenuring ||
AllocationSite::ShouldTrack(object->GetElementsKind())) { AllocationSite::ShouldTrack(object->GetElementsKind())) {
if (FLAG_trace_creation_allocation_sites) { if (FLAG_trace_creation_allocation_sites) {

View File

@ -30,7 +30,7 @@ class AllocationSiteContext {
protected: protected:
void update_current_site(AllocationSite site) { void update_current_site(AllocationSite site) {
*(current_.location()) = site->ptr(); *(current_.location()) = site.ptr();
} }
inline void InitializeTraversal(Handle<AllocationSite> site); inline void InitializeTraversal(Handle<AllocationSite> site);

View File

@ -43,7 +43,7 @@ Handle<V> CustomArguments<T>::GetReturnValue(Isolate* isolate) {
// Check the ReturnValue. // Check the ReturnValue.
FullObjectSlot slot = slot_at(kReturnValueOffset); FullObjectSlot slot = slot_at(kReturnValueOffset);
// Nothing was set, return empty handle as per previous behaviour. // Nothing was set, return empty handle as per previous behaviour.
if ((*slot)->IsTheHole(isolate)) return Handle<V>(); if ((*slot).IsTheHole(isolate)) return Handle<V>();
Handle<V> result = Handle<V>::cast(Handle<Object>(slot.location())); Handle<V> result = Handle<V>::cast(Handle<Object>(slot.location()));
result->VerifyApiCallResultType(); result->VerifyApiCallResultType();
return result; return result;
@ -144,7 +144,7 @@ Handle<Object> FunctionCallbackArguments::Call(CallHandlerInfo handler) {
LOG(isolate, ApiObjectAccess("call", holder())); LOG(isolate, ApiObjectAccess("call", holder()));
RuntimeCallTimerScope timer(isolate, RuntimeCallCounterId::kFunctionCallback); RuntimeCallTimerScope timer(isolate, RuntimeCallCounterId::kFunctionCallback);
v8::FunctionCallback f = v8::FunctionCallback f =
v8::ToCData<v8::FunctionCallback>(handler->callback()); v8::ToCData<v8::FunctionCallback>(handler.callback());
Handle<Object> receiver_check_unsupported; Handle<Object> receiver_check_unsupported;
if (isolate->debug_execution_mode() == DebugInfo::kSideEffects && if (isolate->debug_execution_mode() == DebugInfo::kSideEffects &&
!isolate->debug()->PerformSideEffectCheckForCallback( !isolate->debug()->PerformSideEffectCheckForCallback(

View File

@ -28,8 +28,8 @@ PropertyCallbackArguments::PropertyCallbackArguments(
HeapObject the_hole = ReadOnlyRoots(isolate).the_hole_value(); HeapObject the_hole = ReadOnlyRoots(isolate).the_hole_value();
slot_at(T::kReturnValueDefaultValueIndex).store(the_hole); slot_at(T::kReturnValueDefaultValueIndex).store(the_hole);
slot_at(T::kReturnValueIndex).store(the_hole); slot_at(T::kReturnValueIndex).store(the_hole);
DCHECK((*slot_at(T::kHolderIndex))->IsHeapObject()); DCHECK((*slot_at(T::kHolderIndex)).IsHeapObject());
DCHECK((*slot_at(T::kIsolateIndex))->IsSmi()); DCHECK((*slot_at(T::kIsolateIndex)).IsSmi());
} }
FunctionCallbackArguments::FunctionCallbackArguments( FunctionCallbackArguments::FunctionCallbackArguments(
@ -46,8 +46,8 @@ FunctionCallbackArguments::FunctionCallbackArguments(
HeapObject the_hole = ReadOnlyRoots(isolate).the_hole_value(); HeapObject the_hole = ReadOnlyRoots(isolate).the_hole_value();
slot_at(T::kReturnValueDefaultValueIndex).store(the_hole); slot_at(T::kReturnValueDefaultValueIndex).store(the_hole);
slot_at(T::kReturnValueIndex).store(the_hole); slot_at(T::kReturnValueIndex).store(the_hole);
DCHECK((*slot_at(T::kHolderIndex))->IsHeapObject()); DCHECK((*slot_at(T::kHolderIndex)).IsHeapObject());
DCHECK((*slot_at(T::kIsolateIndex))->IsSmi()); DCHECK((*slot_at(T::kIsolateIndex)).IsSmi());
} }
} // namespace internal } // namespace internal

View File

@ -18,13 +18,13 @@ inline T ToCData(v8::internal::Object obj) {
STATIC_ASSERT(sizeof(T) == sizeof(v8::internal::Address)); STATIC_ASSERT(sizeof(T) == sizeof(v8::internal::Address));
if (obj == v8::internal::Smi::kZero) return nullptr; if (obj == v8::internal::Smi::kZero) return nullptr;
return reinterpret_cast<T>( return reinterpret_cast<T>(
v8::internal::Foreign::cast(obj)->foreign_address()); v8::internal::Foreign::cast(obj).foreign_address());
} }
template <> template <>
inline v8::internal::Address ToCData(v8::internal::Object obj) { inline v8::internal::Address ToCData(v8::internal::Object obj) {
if (obj == v8::internal::Smi::kZero) return v8::internal::kNullAddress; if (obj == v8::internal::Smi::kZero) return v8::internal::kNullAddress;
return v8::internal::Foreign::cast(obj)->foreign_address(); return v8::internal::Foreign::cast(obj).foreign_address();
} }
template <typename T> template <typename T>
@ -117,7 +117,7 @@ MAKE_TO_LOCAL(ScriptOrModuleToLocal, Script, ScriptOrModule)
DCHECK(that == nullptr || \ DCHECK(that == nullptr || \
v8::internal::Object( \ v8::internal::Object( \
*reinterpret_cast<const v8::internal::Address*>(that)) \ *reinterpret_cast<const v8::internal::Address*>(that)) \
->Is##To()); \ .Is##To()); \
return v8::internal::Handle<v8::internal::To>( \ return v8::internal::Handle<v8::internal::To>( \
reinterpret_cast<v8::internal::Address*>( \ reinterpret_cast<v8::internal::Address*>( \
const_cast<v8::From*>(that))); \ const_cast<v8::From*>(that))); \

View File

@ -65,12 +65,12 @@ MaybeHandle<Object> DefineAccessorProperty(
Handle<Object> getter, Handle<Object> setter, PropertyAttributes attributes, Handle<Object> getter, Handle<Object> setter, PropertyAttributes attributes,
bool force_instantiate) { bool force_instantiate) {
DCHECK(!getter->IsFunctionTemplateInfo() || DCHECK(!getter->IsFunctionTemplateInfo() ||
!FunctionTemplateInfo::cast(*getter)->do_not_cache()); !FunctionTemplateInfo::cast(*getter).do_not_cache());
DCHECK(!setter->IsFunctionTemplateInfo() || DCHECK(!setter->IsFunctionTemplateInfo() ||
!FunctionTemplateInfo::cast(*setter)->do_not_cache()); !FunctionTemplateInfo::cast(*setter).do_not_cache());
if (getter->IsFunctionTemplateInfo()) { if (getter->IsFunctionTemplateInfo()) {
if (force_instantiate || if (force_instantiate ||
FunctionTemplateInfo::cast(*getter)->BreakAtEntry()) { FunctionTemplateInfo::cast(*getter).BreakAtEntry()) {
ASSIGN_RETURN_ON_EXCEPTION( ASSIGN_RETURN_ON_EXCEPTION(
isolate, getter, isolate, getter,
InstantiateFunction(isolate, InstantiateFunction(isolate,
@ -80,7 +80,7 @@ MaybeHandle<Object> DefineAccessorProperty(
} }
if (setter->IsFunctionTemplateInfo()) { if (setter->IsFunctionTemplateInfo()) {
if (force_instantiate || if (force_instantiate ||
FunctionTemplateInfo::cast(*setter)->BreakAtEntry()) { FunctionTemplateInfo::cast(*setter).BreakAtEntry()) {
ASSIGN_RETURN_ON_EXCEPTION( ASSIGN_RETURN_ON_EXCEPTION(
isolate, setter, isolate, setter,
InstantiateFunction(isolate, InstantiateFunction(isolate,
@ -145,7 +145,7 @@ class AccessCheckDisableScope {
public: public:
AccessCheckDisableScope(Isolate* isolate, Handle<JSObject> obj) AccessCheckDisableScope(Isolate* isolate, Handle<JSObject> obj)
: isolate_(isolate), : isolate_(isolate),
disabled_(obj->map()->is_access_check_needed()), disabled_(obj->map().is_access_check_needed()),
obj_(obj) { obj_(obj) {
if (disabled_) { if (disabled_) {
DisableAccessChecks(isolate_, obj_); DisableAccessChecks(isolate_, obj_);
@ -188,11 +188,11 @@ MaybeHandle<JSObject> ConfigureInstance(Isolate* isolate, Handle<JSObject> obj,
int max_number_of_properties = 0; int max_number_of_properties = 0;
TemplateInfoT info = *data; TemplateInfoT info = *data;
while (!info.is_null()) { while (!info.is_null()) {
Object props = info->property_accessors(); Object props = info.property_accessors();
if (!props->IsUndefined(isolate)) { if (!props.IsUndefined(isolate)) {
max_number_of_properties += TemplateList::cast(props)->length(); max_number_of_properties += TemplateList::cast(props).length();
} }
info = info->GetParent(isolate); info = info.GetParent(isolate);
} }
if (max_number_of_properties > 0) { if (max_number_of_properties > 0) {
@ -205,7 +205,7 @@ MaybeHandle<JSObject> ConfigureInstance(Isolate* isolate, Handle<JSObject> obj,
temp = handle(temp->GetParent(isolate), isolate)) { temp = handle(temp->GetParent(isolate), isolate)) {
// Accumulate accessors. // Accumulate accessors.
Object maybe_properties = temp->property_accessors(); Object maybe_properties = temp->property_accessors();
if (!maybe_properties->IsUndefined(isolate)) { if (!maybe_properties.IsUndefined(isolate)) {
valid_descriptors = AccessorInfo::AppendUnique( valid_descriptors = AccessorInfo::AppendUnique(
isolate, handle(maybe_properties, isolate), array, isolate, handle(maybe_properties, isolate), array,
valid_descriptors); valid_descriptors);
@ -223,7 +223,7 @@ MaybeHandle<JSObject> ConfigureInstance(Isolate* isolate, Handle<JSObject> obj,
} }
Object maybe_property_list = data->property_list(); Object maybe_property_list = data->property_list();
if (maybe_property_list->IsUndefined(isolate)) return obj; if (maybe_property_list.IsUndefined(isolate)) return obj;
Handle<TemplateList> properties(TemplateList::cast(maybe_property_list), Handle<TemplateList> properties(TemplateList::cast(maybe_property_list),
isolate); isolate);
if (properties->length() == 0) return obj; if (properties->length() == 0) return obj;
@ -232,7 +232,7 @@ MaybeHandle<JSObject> ConfigureInstance(Isolate* isolate, Handle<JSObject> obj,
for (int c = 0; c < data->number_of_properties(); c++) { for (int c = 0; c < data->number_of_properties(); c++) {
auto name = handle(Name::cast(properties->get(i++)), isolate); auto name = handle(Name::cast(properties->get(i++)), isolate);
Object bit = properties->get(i++); Object bit = properties->get(i++);
if (bit->IsSmi()) { if (bit.IsSmi()) {
PropertyDetails details(Smi::cast(bit)); PropertyDetails details(Smi::cast(bit));
PropertyAttributes attributes = details.attributes(); PropertyAttributes attributes = details.attributes();
PropertyKind kind = details.kind(); PropertyKind kind = details.kind();
@ -336,7 +336,7 @@ void UncacheTemplateInstantiation(Isolate* isolate, int serial_number,
if (serial_number <= TemplateInfo::kFastTemplateInstantiationsCacheSize) { if (serial_number <= TemplateInfo::kFastTemplateInstantiationsCacheSize) {
Handle<FixedArray> fast_cache = Handle<FixedArray> fast_cache =
isolate->fast_template_instantiations_cache(); isolate->fast_template_instantiations_cache();
DCHECK(!fast_cache->get(serial_number - 1)->IsUndefined(isolate)); DCHECK(!fast_cache->get(serial_number - 1).IsUndefined(isolate));
fast_cache->set_undefined(serial_number - 1); fast_cache->set_undefined(serial_number - 1);
} else if (caching_mode == CachingMode::kUnlimited || } else if (caching_mode == CachingMode::kUnlimited ||
(serial_number <= (serial_number <=
@ -354,11 +354,11 @@ bool IsSimpleInstantiation(Isolate* isolate, ObjectTemplateInfo info,
JSReceiver new_target) { JSReceiver new_target) {
DisallowHeapAllocation no_gc; DisallowHeapAllocation no_gc;
if (!new_target->IsJSFunction()) return false; if (!new_target.IsJSFunction()) return false;
JSFunction fun = JSFunction::cast(new_target); JSFunction fun = JSFunction::cast(new_target);
if (fun->shared()->function_data() != info->constructor()) return false; if (fun.shared().function_data() != info.constructor()) return false;
if (info->immutable_proto()) return false; if (info.immutable_proto()) return false;
return fun->context()->native_context() == isolate->raw_native_context(); return fun.context().native_context() == isolate->raw_native_context();
} }
MaybeHandle<JSObject> InstantiateObject(Isolate* isolate, MaybeHandle<JSObject> InstantiateObject(Isolate* isolate,
@ -387,7 +387,7 @@ MaybeHandle<JSObject> InstantiateObject(Isolate* isolate,
if (constructor.is_null()) { if (constructor.is_null()) {
Object maybe_constructor_info = info->constructor(); Object maybe_constructor_info = info->constructor();
if (maybe_constructor_info->IsUndefined(isolate)) { if (maybe_constructor_info.IsUndefined(isolate)) {
constructor = isolate->object_function(); constructor = isolate->object_function();
} else { } else {
// Enter a new scope. Recursion could otherwise create a lot of handles. // Enter a new scope. Recursion could otherwise create a lot of handles.
@ -471,9 +471,9 @@ MaybeHandle<JSFunction> InstantiateFunction(Isolate* isolate,
Handle<Object> prototype; Handle<Object> prototype;
if (!data->remove_prototype()) { if (!data->remove_prototype()) {
Object prototype_templ = data->GetPrototypeTemplate(); Object prototype_templ = data->GetPrototypeTemplate();
if (prototype_templ->IsUndefined(isolate)) { if (prototype_templ.IsUndefined(isolate)) {
Object protoype_provider_templ = data->GetPrototypeProviderTemplate(); Object protoype_provider_templ = data->GetPrototypeProviderTemplate();
if (protoype_provider_templ->IsUndefined(isolate)) { if (protoype_provider_templ.IsUndefined(isolate)) {
prototype = isolate->factory()->NewJSObject(isolate->object_function()); prototype = isolate->factory()->NewJSObject(isolate->object_function());
} else { } else {
ASSIGN_RETURN_ON_EXCEPTION( ASSIGN_RETURN_ON_EXCEPTION(
@ -490,7 +490,7 @@ MaybeHandle<JSFunction> InstantiateFunction(Isolate* isolate,
JSFunction); JSFunction);
} }
Object parent = data->GetParentTemplate(); Object parent = data->GetParentTemplate();
if (!parent->IsUndefined(isolate)) { if (!parent.IsUndefined(isolate)) {
Handle<Object> parent_prototype; Handle<Object> parent_prototype;
ASSIGN_RETURN_ON_EXCEPTION(isolate, parent_prototype, ASSIGN_RETURN_ON_EXCEPTION(isolate, parent_prototype,
GetInstancePrototype(isolate, parent), GetInstancePrototype(isolate, parent),
@ -502,8 +502,8 @@ MaybeHandle<JSFunction> InstantiateFunction(Isolate* isolate,
} }
InstanceType function_type = InstanceType function_type =
(!data->needs_access_check() && (!data->needs_access_check() &&
data->GetNamedPropertyHandler()->IsUndefined(isolate) && data->GetNamedPropertyHandler().IsUndefined(isolate) &&
data->GetIndexedPropertyHandler()->IsUndefined(isolate)) data->GetIndexedPropertyHandler().IsUndefined(isolate))
? JS_API_OBJECT_TYPE ? JS_API_OBJECT_TYPE
: JS_SPECIAL_API_OBJECT_TYPE; : JS_SPECIAL_API_OBJECT_TYPE;
@ -531,7 +531,7 @@ void AddPropertyToPropertyList(Isolate* isolate, Handle<TemplateInfo> templ,
int length, Handle<Object>* data) { int length, Handle<Object>* data) {
Object maybe_list = templ->property_list(); Object maybe_list = templ->property_list();
Handle<TemplateList> list; Handle<TemplateList> list;
if (maybe_list->IsUndefined(isolate)) { if (maybe_list.IsUndefined(isolate)) {
list = TemplateList::New(isolate, length); list = TemplateList::New(isolate, length);
} else { } else {
list = handle(TemplateList::cast(maybe_list), isolate); list = handle(TemplateList::cast(maybe_list), isolate);
@ -623,7 +623,7 @@ void ApiNatives::AddNativeDataProperty(Isolate* isolate,
Handle<AccessorInfo> property) { Handle<AccessorInfo> property) {
Object maybe_list = info->property_accessors(); Object maybe_list = info->property_accessors();
Handle<TemplateList> list; Handle<TemplateList> list;
if (maybe_list->IsUndefined(isolate)) { if (maybe_list.IsUndefined(isolate)) {
list = TemplateList::New(isolate, 1); list = TemplateList::New(isolate, 1);
} else { } else {
list = handle(TemplateList::cast(maybe_list), isolate); list = handle(TemplateList::cast(maybe_list), isolate);
@ -647,7 +647,7 @@ Handle<JSFunction> ApiNatives::CreateApiFunction(
if (obj->remove_prototype()) { if (obj->remove_prototype()) {
DCHECK(prototype.is_null()); DCHECK(prototype.is_null());
DCHECK(result->shared()->IsApiFunction()); DCHECK(result->shared().IsApiFunction());
DCHECK(!result->IsConstructor()); DCHECK(!result->IsConstructor());
DCHECK(!result->has_prototype_slot()); DCHECK(!result->has_prototype_slot());
return result; return result;
@ -663,7 +663,7 @@ Handle<JSFunction> ApiNatives::CreateApiFunction(
if (prototype->IsTheHole(isolate)) { if (prototype->IsTheHole(isolate)) {
prototype = isolate->factory()->NewFunctionPrototype(result); prototype = isolate->factory()->NewFunctionPrototype(result);
} else if (obj->GetPrototypeProviderTemplate()->IsUndefined(isolate)) { } else if (obj->GetPrototypeProviderTemplate().IsUndefined(isolate)) {
JSObject::AddProperty(isolate, Handle<JSObject>::cast(prototype), JSObject::AddProperty(isolate, Handle<JSObject>::cast(prototype),
isolate->factory()->constructor_string(), result, isolate->factory()->constructor_string(), result,
DONT_ENUM); DONT_ENUM);
@ -671,7 +671,7 @@ Handle<JSFunction> ApiNatives::CreateApiFunction(
int embedder_field_count = 0; int embedder_field_count = 0;
bool immutable_proto = false; bool immutable_proto = false;
if (!obj->GetInstanceTemplate()->IsUndefined(isolate)) { if (!obj->GetInstanceTemplate().IsUndefined(isolate)) {
Handle<ObjectTemplateInfo> GetInstanceTemplate = Handle<ObjectTemplateInfo>( Handle<ObjectTemplateInfo> GetInstanceTemplate = Handle<ObjectTemplateInfo>(
ObjectTemplateInfo::cast(obj->GetInstanceTemplate()), isolate); ObjectTemplateInfo::cast(obj->GetInstanceTemplate()), isolate);
embedder_field_count = GetInstanceTemplate->embedder_field_count(); embedder_field_count = GetInstanceTemplate->embedder_field_count();
@ -694,7 +694,7 @@ Handle<JSFunction> ApiNatives::CreateApiFunction(
// undetectable and callable. If we ever see the need to have an object // undetectable and callable. If we ever see the need to have an object
// that is undetectable but not callable, we need to update the types.h // that is undetectable but not callable, we need to update the types.h
// to allow encoding this. // to allow encoding this.
CHECK(!obj->GetInstanceCallHandler()->IsUndefined(isolate)); CHECK(!obj->GetInstanceCallHandler().IsUndefined(isolate));
map->set_is_undetectable(true); map->set_is_undetectable(true);
} }
@ -705,16 +705,16 @@ Handle<JSFunction> ApiNatives::CreateApiFunction(
} }
// Set interceptor information in the map. // Set interceptor information in the map.
if (!obj->GetNamedPropertyHandler()->IsUndefined(isolate)) { if (!obj->GetNamedPropertyHandler().IsUndefined(isolate)) {
map->set_has_named_interceptor(true); map->set_has_named_interceptor(true);
map->set_may_have_interesting_symbols(true); map->set_may_have_interesting_symbols(true);
} }
if (!obj->GetIndexedPropertyHandler()->IsUndefined(isolate)) { if (!obj->GetIndexedPropertyHandler().IsUndefined(isolate)) {
map->set_has_indexed_interceptor(true); map->set_has_indexed_interceptor(true);
} }
// Mark instance as callable in the map. // Mark instance as callable in the map.
if (!obj->GetInstanceCallHandler()->IsUndefined(isolate)) { if (!obj->GetInstanceCallHandler().IsUndefined(isolate)) {
map->set_is_callable(true); map->set_is_callable(true);
map->set_is_constructor(!obj->undetectable()); map->set_is_constructor(!obj->undetectable());
} }

File diff suppressed because it is too large Load Diff

View File

@ -122,7 +122,7 @@ void RelocInfo::set_target_object(Heap* heap, HeapObject target,
WriteBarrierMode write_barrier_mode, WriteBarrierMode write_barrier_mode,
ICacheFlushMode icache_flush_mode) { ICacheFlushMode icache_flush_mode) {
DCHECK(IsCodeTarget(rmode_) || rmode_ == FULL_EMBEDDED_OBJECT); DCHECK(IsCodeTarget(rmode_) || rmode_ == FULL_EMBEDDED_OBJECT);
Assembler::set_target_address_at(pc_, constant_pool_, target->ptr(), Assembler::set_target_address_at(pc_, constant_pool_, target.ptr(),
icache_flush_mode); icache_flush_mode);
if (write_barrier_mode == UPDATE_WRITE_BARRIER && !host().is_null()) { if (write_barrier_mode == UPDATE_WRITE_BARRIER && !host().is_null()) {
WriteBarrierForCode(host(), this, target); WriteBarrierForCode(host(), this, target);

View File

@ -290,7 +290,7 @@ void ArmDebugger::Debug() {
Object obj(value); Object obj(value);
os << arg1 << ": \n"; os << arg1 << ": \n";
#ifdef DEBUG #ifdef DEBUG
obj->Print(os); obj.Print(os);
os << "\n"; os << "\n";
#else #else
os << Brief(obj) << "\n"; os << Brief(obj) << "\n";
@ -339,7 +339,7 @@ void ArmDebugger::Debug() {
if (obj.IsSmi()) { if (obj.IsSmi()) {
PrintF("smi %d", Smi::ToInt(obj)); PrintF("smi %d", Smi::ToInt(obj));
} else { } else {
obj->ShortPrint(); obj.ShortPrint();
} }
PrintF(")"); PrintF(")");
} }

View File

@ -702,7 +702,7 @@ void RelocInfo::set_target_object(Heap* heap, HeapObject target,
WriteBarrierMode write_barrier_mode, WriteBarrierMode write_barrier_mode,
ICacheFlushMode icache_flush_mode) { ICacheFlushMode icache_flush_mode) {
DCHECK(IsCodeTarget(rmode_) || IsFullEmbeddedObject(rmode_)); DCHECK(IsCodeTarget(rmode_) || IsFullEmbeddedObject(rmode_));
Assembler::set_target_address_at(pc_, constant_pool_, target->ptr(), Assembler::set_target_address_at(pc_, constant_pool_, target.ptr(),
icache_flush_mode); icache_flush_mode);
if (write_barrier_mode == UPDATE_WRITE_BARRIER && !host().is_null()) { if (write_barrier_mode == UPDATE_WRITE_BARRIER && !host().is_null()) {
WriteBarrierForCode(host(), this, target); WriteBarrierForCode(host(), this, target);

View File

@ -3296,7 +3296,7 @@ void Simulator::Debug() {
if (obj.IsSmi()) { if (obj.IsSmi()) {
PrintF("smi %" PRId32, Smi::ToInt(obj)); PrintF("smi %" PRId32, Smi::ToInt(obj));
} else { } else {
obj->ShortPrint(); obj.ShortPrint();
} }
PrintF(")"); PrintF(")");
} }

View File

@ -73,11 +73,11 @@ bool AreStdlibMembersValid(Isolate* isolate, Handle<JSReceiver> stdlib,
Handle<Object> value = StdlibMathMember(isolate, stdlib, name); \ Handle<Object> value = StdlibMathMember(isolate, stdlib, name); \
if (!value->IsJSFunction()) return false; \ if (!value->IsJSFunction()) return false; \
SharedFunctionInfo shared = Handle<JSFunction>::cast(value)->shared(); \ SharedFunctionInfo shared = Handle<JSFunction>::cast(value)->shared(); \
if (!shared->HasBuiltinId() || \ if (!shared.HasBuiltinId() || \
shared->builtin_id() != Builtins::kMath##FName) { \ shared.builtin_id() != Builtins::kMath##FName) { \
return false; \ return false; \
} \ } \
DCHECK_EQ(shared->GetCode(), \ DCHECK_EQ(shared.GetCode(), \
isolate->builtins()->builtin(Builtins::kMath##FName)); \ isolate->builtins()->builtin(Builtins::kMath##FName)); \
} }
STDLIB_MATH_FUNCTION_LIST(STDLIB_MATH_FUNC) STDLIB_MATH_FUNCTION_LIST(STDLIB_MATH_FUNC)

View File

@ -310,8 +310,8 @@ Scope* Scope::DeserializeScopeChain(Isolate* isolate, Zone* zone,
Scope* innermost_scope = nullptr; Scope* innermost_scope = nullptr;
Scope* outer_scope = nullptr; Scope* outer_scope = nullptr;
while (!scope_info.is_null()) { while (!scope_info.is_null()) {
if (scope_info->scope_type() == WITH_SCOPE) { if (scope_info.scope_type() == WITH_SCOPE) {
if (scope_info->IsDebugEvaluateScope()) { if (scope_info.IsDebugEvaluateScope()) {
outer_scope = new (zone) outer_scope = new (zone)
DeclarationScope(zone, FUNCTION_SCOPE, handle(scope_info, isolate)); DeclarationScope(zone, FUNCTION_SCOPE, handle(scope_info, isolate));
outer_scope->set_is_debug_evaluate_scope(); outer_scope->set_is_debug_evaluate_scope();
@ -321,46 +321,46 @@ Scope* Scope::DeserializeScopeChain(Isolate* isolate, Zone* zone,
new (zone) Scope(zone, WITH_SCOPE, handle(scope_info, isolate)); new (zone) Scope(zone, WITH_SCOPE, handle(scope_info, isolate));
} }
} else if (scope_info->scope_type() == SCRIPT_SCOPE) { } else if (scope_info.scope_type() == SCRIPT_SCOPE) {
// If we reach a script scope, it's the outermost scope. Install the // If we reach a script scope, it's the outermost scope. Install the
// scope info of this script context onto the existing script scope to // scope info of this script context onto the existing script scope to
// avoid nesting script scopes. // avoid nesting script scopes.
if (deserialization_mode == DeserializationMode::kIncludingVariables) { if (deserialization_mode == DeserializationMode::kIncludingVariables) {
script_scope->SetScriptScopeInfo(handle(scope_info, isolate)); script_scope->SetScriptScopeInfo(handle(scope_info, isolate));
} }
DCHECK(!scope_info->HasOuterScopeInfo()); DCHECK(!scope_info.HasOuterScopeInfo());
break; break;
} else if (scope_info->scope_type() == FUNCTION_SCOPE) { } else if (scope_info.scope_type() == FUNCTION_SCOPE) {
outer_scope = new (zone) outer_scope = new (zone)
DeclarationScope(zone, FUNCTION_SCOPE, handle(scope_info, isolate)); DeclarationScope(zone, FUNCTION_SCOPE, handle(scope_info, isolate));
if (scope_info->IsAsmModule()) { if (scope_info.IsAsmModule()) {
outer_scope->AsDeclarationScope()->set_is_asm_module(); outer_scope->AsDeclarationScope()->set_is_asm_module();
} }
} else if (scope_info->scope_type() == EVAL_SCOPE) { } else if (scope_info.scope_type() == EVAL_SCOPE) {
outer_scope = new (zone) outer_scope = new (zone)
DeclarationScope(zone, EVAL_SCOPE, handle(scope_info, isolate)); DeclarationScope(zone, EVAL_SCOPE, handle(scope_info, isolate));
} else if (scope_info->scope_type() == CLASS_SCOPE) { } else if (scope_info.scope_type() == CLASS_SCOPE) {
outer_scope = new (zone) outer_scope = new (zone)
ClassScope(zone, ast_value_factory, handle(scope_info, isolate)); ClassScope(zone, ast_value_factory, handle(scope_info, isolate));
} else if (scope_info->scope_type() == BLOCK_SCOPE) { } else if (scope_info.scope_type() == BLOCK_SCOPE) {
if (scope_info->is_declaration_scope()) { if (scope_info.is_declaration_scope()) {
outer_scope = new (zone) outer_scope = new (zone)
DeclarationScope(zone, BLOCK_SCOPE, handle(scope_info, isolate)); DeclarationScope(zone, BLOCK_SCOPE, handle(scope_info, isolate));
} else { } else {
outer_scope = outer_scope =
new (zone) Scope(zone, BLOCK_SCOPE, handle(scope_info, isolate)); new (zone) Scope(zone, BLOCK_SCOPE, handle(scope_info, isolate));
} }
} else if (scope_info->scope_type() == MODULE_SCOPE) { } else if (scope_info.scope_type() == MODULE_SCOPE) {
outer_scope = new (zone) outer_scope = new (zone)
ModuleScope(isolate, handle(scope_info, isolate), ast_value_factory); ModuleScope(isolate, handle(scope_info, isolate), ast_value_factory);
} else { } else {
DCHECK_EQ(scope_info->scope_type(), CATCH_SCOPE); DCHECK_EQ(scope_info.scope_type(), CATCH_SCOPE);
DCHECK_EQ(scope_info->ContextLocalCount(), 1); DCHECK_EQ(scope_info.ContextLocalCount(), 1);
DCHECK_EQ(scope_info->ContextLocalMode(0), VariableMode::kVar); DCHECK_EQ(scope_info.ContextLocalMode(0), VariableMode::kVar);
DCHECK_EQ(scope_info->ContextLocalInitFlag(0), kCreatedInitialized); DCHECK_EQ(scope_info.ContextLocalInitFlag(0), kCreatedInitialized);
String name = scope_info->ContextLocalName(0); String name = scope_info.ContextLocalName(0);
MaybeAssignedFlag maybe_assigned = MaybeAssignedFlag maybe_assigned =
scope_info->ContextLocalMaybeAssignedFlag(0); scope_info.ContextLocalMaybeAssignedFlag(0);
outer_scope = new (zone) outer_scope = new (zone)
Scope(zone, ast_value_factory->GetString(handle(name, isolate)), Scope(zone, ast_value_factory->GetString(handle(name, isolate)),
maybe_assigned, handle(scope_info, isolate)); maybe_assigned, handle(scope_info, isolate));
@ -373,8 +373,8 @@ Scope* Scope::DeserializeScopeChain(Isolate* isolate, Zone* zone,
} }
current_scope = outer_scope; current_scope = outer_scope;
if (innermost_scope == nullptr) innermost_scope = current_scope; if (innermost_scope == nullptr) innermost_scope = current_scope;
scope_info = scope_info->HasOuterScopeInfo() ? scope_info->OuterScopeInfo() scope_info = scope_info.HasOuterScopeInfo() ? scope_info.OuterScopeInfo()
: ScopeInfo(); : ScopeInfo();
} }
if (deserialization_mode == DeserializationMode::kIncludingVariables && if (deserialization_mode == DeserializationMode::kIncludingVariables &&

View File

@ -152,7 +152,7 @@ void Accessors::ArrayLengthGetter(
DisallowHeapAllocation no_allocation; DisallowHeapAllocation no_allocation;
HandleScope scope(isolate); HandleScope scope(isolate);
JSArray holder = JSArray::cast(*Utils::OpenHandle(*info.Holder())); JSArray holder = JSArray::cast(*Utils::OpenHandle(*info.Holder()));
Object result = holder->length(); Object result = holder.length();
info.GetReturnValue().Set(Utils::ToLocal(Handle<Object>(result, isolate))); info.GetReturnValue().Set(Utils::ToLocal(Handle<Object>(result, isolate)));
} }
@ -180,7 +180,7 @@ void Accessors::ArrayLengthSetter(
} }
if (!was_readonly && V8_UNLIKELY(JSArray::HasReadOnlyLength(array)) && if (!was_readonly && V8_UNLIKELY(JSArray::HasReadOnlyLength(array)) &&
length != array->length()->Number()) { length != array->length().Number()) {
// AnythingToArrayLength() may have called setter re-entrantly and modified // AnythingToArrayLength() may have called setter re-entrantly and modified
// its property descriptor. Don't perform this check if "length" was // its property descriptor. Don't perform this check if "length" was
// previously readonly, as this may have been called during // previously readonly, as this may have been called during
@ -200,7 +200,7 @@ void Accessors::ArrayLengthSetter(
JSArray::SetLength(array, length); JSArray::SetLength(array, length);
uint32_t actual_new_len = 0; uint32_t actual_new_len = 0;
CHECK(array->length()->ToArrayLength(&actual_new_len)); CHECK(array->length().ToArrayLength(&actual_new_len));
// Fail if there were non-deletable elements. // Fail if there were non-deletable elements.
if (actual_new_len != length) { if (actual_new_len != length) {
if (info.ShouldThrowOnError()) { if (info.ShouldThrowOnError()) {
@ -233,8 +233,7 @@ void Accessors::ModuleNamespaceEntryGetter(
JSModuleNamespace holder = JSModuleNamespace holder =
JSModuleNamespace::cast(*Utils::OpenHandle(*info.Holder())); JSModuleNamespace::cast(*Utils::OpenHandle(*info.Holder()));
Handle<Object> result; Handle<Object> result;
if (!holder if (!holder.GetExport(isolate, Handle<String>::cast(Utils::OpenHandle(*name)))
->GetExport(isolate, Handle<String>::cast(Utils::OpenHandle(*name)))
.ToHandle(&result)) { .ToHandle(&result)) {
isolate->OptionalRescheduleException(false); isolate->OptionalRescheduleException(false);
} else { } else {
@ -285,12 +284,12 @@ void Accessors::StringLengthGetter(
// in the hierarchy, in this case for String values. // in the hierarchy, in this case for String values.
Object value = *Utils::OpenHandle(*v8::Local<v8::Value>(info.This())); Object value = *Utils::OpenHandle(*v8::Local<v8::Value>(info.This()));
if (!value->IsString()) { if (!value.IsString()) {
// Not a string value. That means that we either got a String wrapper or // Not a string value. That means that we either got a String wrapper or
// a Value with a String wrapper in its prototype chain. // a Value with a String wrapper in its prototype chain.
value = JSValue::cast(*Utils::OpenHandle(*info.Holder()))->value(); value = JSValue::cast(*Utils::OpenHandle(*info.Holder())).value();
} }
Object result = Smi::FromInt(String::cast(value)->length()); Object result = Smi::FromInt(String::cast(value).length());
info.GetReturnValue().Set(Utils::ToLocal(Handle<Object>(result, isolate))); info.GetReturnValue().Set(Utils::ToLocal(Handle<Object>(result, isolate)));
} }
@ -479,10 +478,10 @@ Handle<JSObject> GetFrameArguments(Isolate* isolate,
DCHECK(array->length() == length); DCHECK(array->length() == length);
for (int i = 0; i < length; i++) { for (int i = 0; i < length; i++) {
Object value = frame->GetParameter(i); Object value = frame->GetParameter(i);
if (value->IsTheHole(isolate)) { if (value.IsTheHole(isolate)) {
// Generators currently use holes as dummy arguments when resuming. We // Generators currently use holes as dummy arguments when resuming. We
// must not leak those. // must not leak those.
DCHECK(IsResumableFunction(function->shared()->kind())); DCHECK(IsResumableFunction(function->shared().kind()));
value = ReadOnlyRoots(isolate).undefined_value(); value = ReadOnlyRoots(isolate).undefined_value();
} }
array->set(i, value); array->set(i, value);
@ -516,7 +515,7 @@ void Accessors::FunctionArgumentsGetter(
Handle<JSFunction> function = Handle<JSFunction> function =
Handle<JSFunction>::cast(Utils::OpenHandle(*info.Holder())); Handle<JSFunction>::cast(Utils::OpenHandle(*info.Holder()));
Handle<Object> result = isolate->factory()->null_value(); Handle<Object> result = isolate->factory()->null_value();
if (!function->shared()->native()) { if (!function->shared().native()) {
// Find the top invocation of the function by traversing frames. // Find the top invocation of the function by traversing frames.
for (JavaScriptFrameIterator it(isolate); !it.done(); it.Advance()) { for (JavaScriptFrameIterator it(isolate); !it.done(); it.Advance()) {
JavaScriptFrame* frame = it.frame(); JavaScriptFrame* frame = it.frame();
@ -541,7 +540,7 @@ Handle<AccessorInfo> Accessors::MakeFunctionArgumentsInfo(Isolate* isolate) {
static inline bool AllowAccessToFunction(Context current_context, static inline bool AllowAccessToFunction(Context current_context,
JSFunction function) { JSFunction function) {
return current_context->HasSameSecurityTokenAs(function->context()); return current_context.HasSameSecurityTokenAs(function.context());
} }
class FrameFunctionIterator { class FrameFunctionIterator {
@ -565,7 +564,7 @@ class FrameFunctionIterator {
bool FindNextNonTopLevel() { bool FindNextNonTopLevel() {
do { do {
if (!next().ToHandle(&function_)) return false; if (!next().ToHandle(&function_)) return false;
} while (function_->shared()->is_toplevel()); } while (function_->shared().is_toplevel());
return true; return true;
} }
@ -574,8 +573,8 @@ class FrameFunctionIterator {
// unless directly exposed, in which case the native flag is set on them. // unless directly exposed, in which case the native flag is set on them.
// Returns true if one is found, and false if the iterator ends before. // Returns true if one is found, and false if the iterator ends before.
bool FindFirstNativeOrUserJavaScript() { bool FindFirstNativeOrUserJavaScript() {
while (!function_->shared()->native() && while (!function_->shared().native() &&
!function_->shared()->IsUserJavaScript()) { !function_->shared().IsUserJavaScript()) {
if (!next().ToHandle(&function_)) return false; if (!next().ToHandle(&function_)) return false;
} }
return true; return true;
@ -646,7 +645,7 @@ class FrameFunctionIterator {
MaybeHandle<JSFunction> FindCaller(Isolate* isolate, MaybeHandle<JSFunction> FindCaller(Isolate* isolate,
Handle<JSFunction> function) { Handle<JSFunction> function) {
FrameFunctionIterator it(isolate); FrameFunctionIterator it(isolate);
if (function->shared()->native()) { if (function->shared().native()) {
return MaybeHandle<JSFunction>(); return MaybeHandle<JSFunction>();
} }
// Find the function from the frames. Return null in case no frame // Find the function from the frames. Return null in case no frame
@ -673,7 +672,7 @@ MaybeHandle<JSFunction> FindCaller(Isolate* isolate,
// Censor if the caller is not a sloppy mode function. // Censor if the caller is not a sloppy mode function.
// Change from ES5, which used to throw, see: // Change from ES5, which used to throw, see:
// https://bugs.ecmascript.org/show_bug.cgi?id=310 // https://bugs.ecmascript.org/show_bug.cgi?id=310
if (is_strict(caller->shared()->language_mode())) { if (is_strict(caller->shared().language_mode())) {
return MaybeHandle<JSFunction>(); return MaybeHandle<JSFunction>();
} }
// Don't return caller from another security context. // Don't return caller from another security context.

View File

@ -1343,7 +1343,7 @@ static void Generate_InterpreterEnterBytecode(MacroAssembler* masm) {
__ ldr(r2, MemOperand(r2)); __ ldr(r2, MemOperand(r2));
__ bind(&trampoline_loaded); __ bind(&trampoline_loaded);
__ add(lr, r2, Operand(interpreter_entry_return_pc_offset->value())); __ add(lr, r2, Operand(interpreter_entry_return_pc_offset.value()));
// Initialize the dispatch table register. // Initialize the dispatch table register.
__ Move( __ Move(

View File

@ -1482,7 +1482,7 @@ static void Generate_InterpreterEnterBytecode(MacroAssembler* masm) {
__ Ldr(x1, MemOperand(x1)); __ Ldr(x1, MemOperand(x1));
__ Bind(&trampoline_loaded); __ Bind(&trampoline_loaded);
__ Add(lr, x1, Operand(interpreter_entry_return_pc_offset->value())); __ Add(lr, x1, Operand(interpreter_entry_return_pc_offset.value()));
// Initialize the dispatch table register. // Initialize the dispatch table register.
__ Mov( __ Mov(

View File

@ -23,23 +23,23 @@ namespace {
// TODO(dcarney): CallOptimization duplicates this logic, merge. // TODO(dcarney): CallOptimization duplicates this logic, merge.
JSReceiver GetCompatibleReceiver(Isolate* isolate, FunctionTemplateInfo info, JSReceiver GetCompatibleReceiver(Isolate* isolate, FunctionTemplateInfo info,
JSReceiver receiver) { JSReceiver receiver) {
Object recv_type = info->signature(); Object recv_type = info.signature();
// No signature, return holder. // No signature, return holder.
if (!recv_type->IsFunctionTemplateInfo()) return receiver; if (!recv_type.IsFunctionTemplateInfo()) return receiver;
// A Proxy cannot have been created from the signature template. // A Proxy cannot have been created from the signature template.
if (!receiver->IsJSObject()) return JSReceiver(); if (!receiver.IsJSObject()) return JSReceiver();
JSObject js_obj_receiver = JSObject::cast(receiver); JSObject js_obj_receiver = JSObject::cast(receiver);
FunctionTemplateInfo signature = FunctionTemplateInfo::cast(recv_type); FunctionTemplateInfo signature = FunctionTemplateInfo::cast(recv_type);
// Check the receiver. Fast path for receivers with no hidden prototypes. // Check the receiver. Fast path for receivers with no hidden prototypes.
if (signature->IsTemplateFor(js_obj_receiver)) return receiver; if (signature.IsTemplateFor(js_obj_receiver)) return receiver;
if (!js_obj_receiver->map()->has_hidden_prototype()) return JSReceiver(); if (!js_obj_receiver.map().has_hidden_prototype()) return JSReceiver();
for (PrototypeIterator iter(isolate, js_obj_receiver, kStartAtPrototype, for (PrototypeIterator iter(isolate, js_obj_receiver, kStartAtPrototype,
PrototypeIterator::END_AT_NON_HIDDEN); PrototypeIterator::END_AT_NON_HIDDEN);
!iter.IsAtEnd(); iter.Advance()) { !iter.IsAtEnd(); iter.Advance()) {
JSObject current = iter.GetCurrent<JSObject>(); JSObject current = iter.GetCurrent<JSObject>();
if (signature->IsTemplateFor(current)) return current; if (signature.IsTemplateFor(current)) return current;
} }
return JSReceiver(); return JSReceiver();
} }
@ -53,7 +53,7 @@ V8_WARN_UNUSED_RESULT MaybeHandle<Object> HandleApiCallHelper(
JSReceiver raw_holder; JSReceiver raw_holder;
if (is_construct) { if (is_construct) {
DCHECK(args.receiver()->IsTheHole(isolate)); DCHECK(args.receiver()->IsTheHole(isolate));
if (fun_data->GetInstanceTemplate()->IsUndefined(isolate)) { if (fun_data->GetInstanceTemplate().IsUndefined(isolate)) {
v8::Local<ObjectTemplate> templ = v8::Local<ObjectTemplate> templ =
ObjectTemplate::New(reinterpret_cast<v8::Isolate*>(isolate), ObjectTemplate::New(reinterpret_cast<v8::Isolate*>(isolate),
ToApiHandle<v8::FunctionTemplate>(fun_data)); ToApiHandle<v8::FunctionTemplate>(fun_data));
@ -98,10 +98,10 @@ V8_WARN_UNUSED_RESULT MaybeHandle<Object> HandleApiCallHelper(
} }
Object raw_call_data = fun_data->call_code(); Object raw_call_data = fun_data->call_code();
if (!raw_call_data->IsUndefined(isolate)) { if (!raw_call_data.IsUndefined(isolate)) {
DCHECK(raw_call_data->IsCallHandlerInfo()); DCHECK(raw_call_data.IsCallHandlerInfo());
CallHandlerInfo call_data = CallHandlerInfo::cast(raw_call_data); CallHandlerInfo call_data = CallHandlerInfo::cast(raw_call_data);
Object data_obj = call_data->data(); Object data_obj = call_data.data();
FunctionCallbackArguments custom(isolate, data_obj, *function, raw_holder, FunctionCallbackArguments custom(isolate, data_obj, *function, raw_holder,
*new_target, args.address_of_arg_at(1), *new_target, args.address_of_arg_at(1),
@ -129,7 +129,7 @@ BUILTIN(HandleApiCall) {
Handle<JSFunction> function = args.target(); Handle<JSFunction> function = args.target();
Handle<Object> receiver = args.receiver(); Handle<Object> receiver = args.receiver();
Handle<HeapObject> new_target = args.new_target(); Handle<HeapObject> new_target = args.new_target();
Handle<FunctionTemplateInfo> fun_data(function->shared()->get_api_func_data(), Handle<FunctionTemplateInfo> fun_data(function->shared().get_api_func_data(),
isolate); isolate);
if (new_target->IsJSReceiver()) { if (new_target->IsJSReceiver()) {
RETURN_RESULT_OR_FAILURE( RETURN_RESULT_OR_FAILURE(
@ -171,12 +171,12 @@ MaybeHandle<Object> Builtins::InvokeApiFunction(Isolate* isolate,
RuntimeCallCounterId::kInvokeApiFunction); RuntimeCallCounterId::kInvokeApiFunction);
DCHECK(function->IsFunctionTemplateInfo() || DCHECK(function->IsFunctionTemplateInfo() ||
(function->IsJSFunction() && (function->IsJSFunction() &&
JSFunction::cast(*function)->shared()->IsApiFunction())); JSFunction::cast(*function).shared().IsApiFunction()));
// Do proper receiver conversion for non-strict mode api functions. // Do proper receiver conversion for non-strict mode api functions.
if (!is_construct && !receiver->IsJSReceiver()) { if (!is_construct && !receiver->IsJSReceiver()) {
if (function->IsFunctionTemplateInfo() || if (function->IsFunctionTemplateInfo() ||
is_sloppy(JSFunction::cast(*function)->shared()->language_mode())) { is_sloppy(JSFunction::cast(*function).shared().language_mode())) {
ASSIGN_RETURN_ON_EXCEPTION(isolate, receiver, ASSIGN_RETURN_ON_EXCEPTION(isolate, receiver,
Object::ConvertReceiver(isolate, receiver), Object::ConvertReceiver(isolate, receiver),
Object); Object);
@ -191,7 +191,7 @@ MaybeHandle<Object> Builtins::InvokeApiFunction(Isolate* isolate,
Handle<FunctionTemplateInfo> fun_data = Handle<FunctionTemplateInfo> fun_data =
function->IsFunctionTemplateInfo() function->IsFunctionTemplateInfo()
? Handle<FunctionTemplateInfo>::cast(function) ? Handle<FunctionTemplateInfo>::cast(function)
: handle(JSFunction::cast(*function)->shared()->get_api_func_data(), : handle(JSFunction::cast(*function).shared().get_api_func_data(),
isolate); isolate);
// Construct BuiltinArguments object: // Construct BuiltinArguments object:
// new target, function, arguments reversed, receiver. // new target, function, arguments reversed, receiver.
@ -211,8 +211,8 @@ MaybeHandle<Object> Builtins::InvokeApiFunction(Isolate* isolate,
} }
DCHECK_EQ(cursor, BuiltinArguments::kPaddingOffset); DCHECK_EQ(cursor, BuiltinArguments::kPaddingOffset);
argv[BuiltinArguments::kPaddingOffset] = argv[BuiltinArguments::kPaddingOffset] =
ReadOnlyRoots(isolate).the_hole_value()->ptr(); ReadOnlyRoots(isolate).the_hole_value().ptr();
argv[BuiltinArguments::kArgcOffset] = Smi::FromInt(frame_argc)->ptr(); argv[BuiltinArguments::kArgcOffset] = Smi::FromInt(frame_argc).ptr();
argv[BuiltinArguments::kTargetOffset] = function->ptr(); argv[BuiltinArguments::kTargetOffset] = function->ptr();
argv[BuiltinArguments::kNewTargetOffset] = new_target->ptr(); argv[BuiltinArguments::kNewTargetOffset] = new_target->ptr();
MaybeHandle<Object> result; MaybeHandle<Object> result;
@ -254,12 +254,12 @@ V8_WARN_UNUSED_RESULT static Object HandleApiCallAsFunctionOrConstructor(
// Get the invocation callback from the function descriptor that was // Get the invocation callback from the function descriptor that was
// used to create the called object. // used to create the called object.
DCHECK(obj->map()->is_callable()); DCHECK(obj.map().is_callable());
JSFunction constructor = JSFunction::cast(obj->map()->GetConstructor()); JSFunction constructor = JSFunction::cast(obj.map().GetConstructor());
DCHECK(constructor->shared()->IsApiFunction()); DCHECK(constructor.shared().IsApiFunction());
Object handler = Object handler =
constructor->shared()->get_api_func_data()->GetInstanceCallHandler(); constructor.shared().get_api_func_data().GetInstanceCallHandler();
DCHECK(!handler->IsUndefined(isolate)); DCHECK(!handler.IsUndefined(isolate));
CallHandlerInfo call_data = CallHandlerInfo::cast(handler); CallHandlerInfo call_data = CallHandlerInfo::cast(handler);
// Get the data for the call and perform the callback. // Get the data for the call and perform the callback.
@ -267,7 +267,7 @@ V8_WARN_UNUSED_RESULT static Object HandleApiCallAsFunctionOrConstructor(
{ {
HandleScope scope(isolate); HandleScope scope(isolate);
LOG(isolate, ApiObjectAccess("call non-function", obj)); LOG(isolate, ApiObjectAccess("call non-function", obj));
FunctionCallbackArguments custom(isolate, call_data->data(), constructor, FunctionCallbackArguments custom(isolate, call_data.data(), constructor,
obj, new_target, args.address_of_arg_at(1), obj, new_target, args.address_of_arg_at(1),
args.length() - 1); args.length() - 1);
Handle<Object> result_handle = custom.Call(call_data); Handle<Object> result_handle = custom.Call(call_data);

View File

@ -29,8 +29,8 @@ inline bool IsJSArrayFastElementMovingAllowed(Isolate* isolate,
} }
inline bool HasSimpleElements(JSObject current) { inline bool HasSimpleElements(JSObject current) {
return !current->map()->IsCustomElementsReceiverMap() && return !current.map().IsCustomElementsReceiverMap() &&
!current->GetElementsAccessor()->HasAccessors(current); !current.GetElementsAccessor()->HasAccessors(current);
} }
inline bool HasOnlySimpleReceiverElements(Isolate* isolate, JSObject receiver) { inline bool HasOnlySimpleReceiverElements(Isolate* isolate, JSObject receiver) {
@ -43,7 +43,7 @@ inline bool HasOnlySimpleElements(Isolate* isolate, JSReceiver receiver) {
DisallowHeapAllocation no_gc; DisallowHeapAllocation no_gc;
PrototypeIterator iter(isolate, receiver, kStartAtReceiver); PrototypeIterator iter(isolate, receiver, kStartAtReceiver);
for (; !iter.IsAtEnd(); iter.Advance()) { for (; !iter.IsAtEnd(); iter.Advance()) {
if (iter.GetCurrent()->IsJSProxy()) return false; if (iter.GetCurrent().IsJSProxy()) return false;
JSObject current = iter.GetCurrent<JSObject>(); JSObject current = iter.GetCurrent<JSObject>();
if (!HasSimpleElements(current)) return false; if (!HasSimpleElements(current)) return false;
} }
@ -70,8 +70,8 @@ void MatchArrayElementsKindToArguments(Isolate* isolate, Handle<JSArray> array,
int last_arg_index = std::min(first_arg_index + num_arguments, args_length); int last_arg_index = std::min(first_arg_index + num_arguments, args_length);
for (int i = first_arg_index; i < last_arg_index; i++) { for (int i = first_arg_index; i < last_arg_index; i++) {
Object arg = (*args)[i]; Object arg = (*args)[i];
if (arg->IsHeapObject()) { if (arg.IsHeapObject()) {
if (arg->IsHeapNumber()) { if (arg.IsHeapNumber()) {
target_kind = PACKED_DOUBLE_ELEMENTS; target_kind = PACKED_DOUBLE_ELEMENTS;
} else { } else {
target_kind = PACKED_ELEMENTS; target_kind = PACKED_ELEMENTS;
@ -101,7 +101,7 @@ inline bool EnsureJSArrayWithWritableFastElements(Isolate* isolate,
Handle<JSArray> array = Handle<JSArray>::cast(receiver); Handle<JSArray> array = Handle<JSArray>::cast(receiver);
ElementsKind origin_kind = array->GetElementsKind(); ElementsKind origin_kind = array->GetElementsKind();
if (IsDictionaryElementsKind(origin_kind)) return false; if (IsDictionaryElementsKind(origin_kind)) return false;
if (!array->map()->is_extensible()) return false; if (!array->map().is_extensible()) return false;
if (args == nullptr) return true; if (args == nullptr) return true;
// If there may be elements accessors in the prototype chain, the fast path // If there may be elements accessors in the prototype chain, the fast path
@ -148,7 +148,7 @@ V8_WARN_UNUSED_RESULT Maybe<double> GetLengthProperty(
Isolate* isolate, Handle<JSReceiver> receiver) { Isolate* isolate, Handle<JSReceiver> receiver) {
if (receiver->IsJSArray()) { if (receiver->IsJSArray()) {
Handle<JSArray> array = Handle<JSArray>::cast(receiver); Handle<JSArray> array = Handle<JSArray>::cast(receiver);
double length = array->length()->Number(); double length = array->length().Number();
DCHECK(0 <= length && length <= kMaxSafeInteger); DCHECK(0 <= length && length <= kMaxSafeInteger);
return Just(length); return Just(length);
@ -373,7 +373,7 @@ BUILTIN(ArrayPush) {
// Fast Elements Path // Fast Elements Path
int to_add = args.length() - 1; int to_add = args.length() - 1;
Handle<JSArray> array = Handle<JSArray>::cast(receiver); Handle<JSArray> array = Handle<JSArray>::cast(receiver);
uint32_t len = static_cast<uint32_t>(array->length()->Number()); uint32_t len = static_cast<uint32_t>(array->length().Number());
if (to_add == 0) return *isolate->factory()->NewNumberFromUint(len); if (to_add == 0) return *isolate->factory()->NewNumberFromUint(len);
// Currently fixed arrays cannot grow too big, so we should never hit this. // Currently fixed arrays cannot grow too big, so we should never hit this.
@ -457,7 +457,7 @@ BUILTIN(ArrayPop) {
} }
Handle<JSArray> array = Handle<JSArray>::cast(receiver); Handle<JSArray> array = Handle<JSArray>::cast(receiver);
uint32_t len = static_cast<uint32_t>(array->length()->Number()); uint32_t len = static_cast<uint32_t>(array->length().Number());
if (len == 0) return ReadOnlyRoots(isolate).undefined_value(); if (len == 0) return ReadOnlyRoots(isolate).undefined_value();
if (JSArray::HasReadOnlyLength(array)) { if (JSArray::HasReadOnlyLength(array)) {
@ -597,7 +597,7 @@ BUILTIN(ArrayUnshift) {
Handle<JSArray> array = Handle<JSArray>::cast(args.receiver()); Handle<JSArray> array = Handle<JSArray>::cast(args.receiver());
// These are checked in the Torque builtin. // These are checked in the Torque builtin.
DCHECK(array->map()->is_extensible()); DCHECK(array->map().is_extensible());
DCHECK(!IsDictionaryElementsKind(array->GetElementsKind())); DCHECK(!IsDictionaryElementsKind(array->GetElementsKind()));
DCHECK(IsJSArrayFastElementMovingAllowed(isolate, *array)); DCHECK(IsJSArrayFastElementMovingAllowed(isolate, *array));
DCHECK(!isolate->IsAnyInitialArrayPrototype(array)); DCHECK(!isolate->IsAnyInitialArrayPrototype(array));
@ -644,7 +644,7 @@ class ArrayConcatVisitor {
IsFixedArrayField::encode(storage->IsFixedArray()) | IsFixedArrayField::encode(storage->IsFixedArray()) |
HasSimpleElementsField::encode( HasSimpleElementsField::encode(
storage->IsFixedArray() || storage->IsFixedArray() ||
!storage->map()->IsCustomElementsReceiverMap())) { !storage->map().IsCustomElementsReceiverMap())) {
DCHECK(!(this->fast_elements() && !is_fixed_array())); DCHECK(!(this->fast_elements() && !is_fixed_array()));
} }
@ -708,7 +708,7 @@ class ArrayConcatVisitor {
// provided-for index range, go to dictionary mode now. // provided-for index range, go to dictionary mode now.
if (fast_elements() && if (fast_elements() &&
index_offset_ > index_offset_ >
static_cast<uint32_t>(FixedArrayBase::cast(*storage_)->length())) { static_cast<uint32_t>(FixedArrayBase::cast(*storage_).length())) {
SetDictionaryMode(); SetDictionaryMode();
} }
} }
@ -811,7 +811,7 @@ class ArrayConcatVisitor {
uint32_t EstimateElementCount(Isolate* isolate, Handle<JSArray> array) { uint32_t EstimateElementCount(Isolate* isolate, Handle<JSArray> array) {
DisallowHeapAllocation no_gc; DisallowHeapAllocation no_gc;
uint32_t length = static_cast<uint32_t>(array->length()->Number()); uint32_t length = static_cast<uint32_t>(array->length().Number());
int element_count = 0; int element_count = 0;
switch (array->GetElementsKind()) { switch (array->GetElementsKind()) {
case PACKED_SMI_ELEMENTS: case PACKED_SMI_ELEMENTS:
@ -828,7 +828,7 @@ uint32_t EstimateElementCount(Isolate* isolate, Handle<JSArray> array) {
int fast_length = static_cast<int>(length); int fast_length = static_cast<int>(length);
FixedArray elements = FixedArray::cast(array->elements()); FixedArray elements = FixedArray::cast(array->elements());
for (int i = 0; i < fast_length; i++) { for (int i = 0; i < fast_length; i++) {
if (!elements->get(i)->IsTheHole(isolate)) element_count++; if (!elements.get(i).IsTheHole(isolate)) element_count++;
} }
break; break;
} }
@ -838,23 +838,23 @@ uint32_t EstimateElementCount(Isolate* isolate, Handle<JSArray> array) {
// a 32-bit signed integer. // a 32-bit signed integer.
DCHECK_GE(static_cast<int32_t>(FixedDoubleArray::kMaxLength), 0); DCHECK_GE(static_cast<int32_t>(FixedDoubleArray::kMaxLength), 0);
int fast_length = static_cast<int>(length); int fast_length = static_cast<int>(length);
if (array->elements()->IsFixedArray()) { if (array->elements().IsFixedArray()) {
DCHECK_EQ(FixedArray::cast(array->elements())->length(), 0); DCHECK_EQ(FixedArray::cast(array->elements()).length(), 0);
break; break;
} }
FixedDoubleArray elements = FixedDoubleArray::cast(array->elements()); FixedDoubleArray elements = FixedDoubleArray::cast(array->elements());
for (int i = 0; i < fast_length; i++) { for (int i = 0; i < fast_length; i++) {
if (!elements->is_the_hole(i)) element_count++; if (!elements.is_the_hole(i)) element_count++;
} }
break; break;
} }
case DICTIONARY_ELEMENTS: { case DICTIONARY_ELEMENTS: {
NumberDictionary dictionary = NumberDictionary::cast(array->elements()); NumberDictionary dictionary = NumberDictionary::cast(array->elements());
int capacity = dictionary->Capacity(); int capacity = dictionary.Capacity();
ReadOnlyRoots roots(isolate); ReadOnlyRoots roots(isolate);
for (int i = 0; i < capacity; i++) { for (int i = 0; i < capacity; i++) {
Object key = dictionary->KeyAt(i); Object key = dictionary.KeyAt(i);
if (dictionary->IsKey(roots, key)) { if (dictionary.IsKey(roots, key)) {
element_count++; element_count++;
} }
} }
@ -893,10 +893,10 @@ void CollectElementIndices(Isolate* isolate, Handle<JSObject> object,
case HOLEY_ELEMENTS: { case HOLEY_ELEMENTS: {
DisallowHeapAllocation no_gc; DisallowHeapAllocation no_gc;
FixedArray elements = FixedArray::cast(object->elements()); FixedArray elements = FixedArray::cast(object->elements());
uint32_t length = static_cast<uint32_t>(elements->length()); uint32_t length = static_cast<uint32_t>(elements.length());
if (range < length) length = range; if (range < length) length = range;
for (uint32_t i = 0; i < length; i++) { for (uint32_t i = 0; i < length; i++) {
if (!elements->get(i)->IsTheHole(isolate)) { if (!elements.get(i).IsTheHole(isolate)) {
indices->push_back(i); indices->push_back(i);
} }
} }
@ -904,8 +904,8 @@ void CollectElementIndices(Isolate* isolate, Handle<JSObject> object,
} }
case HOLEY_DOUBLE_ELEMENTS: case HOLEY_DOUBLE_ELEMENTS:
case PACKED_DOUBLE_ELEMENTS: { case PACKED_DOUBLE_ELEMENTS: {
if (object->elements()->IsFixedArray()) { if (object->elements().IsFixedArray()) {
DCHECK_EQ(object->elements()->length(), 0); DCHECK_EQ(object->elements().length(), 0);
break; break;
} }
Handle<FixedDoubleArray> elements( Handle<FixedDoubleArray> elements(
@ -922,13 +922,13 @@ void CollectElementIndices(Isolate* isolate, Handle<JSObject> object,
case DICTIONARY_ELEMENTS: { case DICTIONARY_ELEMENTS: {
DisallowHeapAllocation no_gc; DisallowHeapAllocation no_gc;
NumberDictionary dict = NumberDictionary::cast(object->elements()); NumberDictionary dict = NumberDictionary::cast(object->elements());
uint32_t capacity = dict->Capacity(); uint32_t capacity = dict.Capacity();
ReadOnlyRoots roots(isolate); ReadOnlyRoots roots(isolate);
FOR_WITH_HANDLE_SCOPE(isolate, uint32_t, j = 0, j, j < capacity, j++, { FOR_WITH_HANDLE_SCOPE(isolate, uint32_t, j = 0, j, j < capacity, j++, {
Object k = dict->KeyAt(j); Object k = dict.KeyAt(j);
if (!dict->IsKey(roots, k)) continue; if (!dict.IsKey(roots, k)) continue;
DCHECK(k->IsNumber()); DCHECK(k.IsNumber());
uint32_t index = static_cast<uint32_t>(k->Number()); uint32_t index = static_cast<uint32_t>(k.Number());
if (index < range) { if (index < range) {
indices->push_back(index); indices->push_back(index);
} }
@ -972,7 +972,7 @@ void CollectElementIndices(Isolate* isolate, Handle<JSObject> object,
case SLOW_STRING_WRAPPER_ELEMENTS: { case SLOW_STRING_WRAPPER_ELEMENTS: {
DCHECK(object->IsJSValue()); DCHECK(object->IsJSValue());
Handle<JSValue> js_value = Handle<JSValue>::cast(object); Handle<JSValue> js_value = Handle<JSValue>::cast(object);
DCHECK(js_value->value()->IsString()); DCHECK(js_value->value().IsString());
Handle<String> string(String::cast(js_value->value()), isolate); Handle<String> string(String::cast(js_value->value()), isolate);
uint32_t length = static_cast<uint32_t>(string->length()); uint32_t length = static_cast<uint32_t>(string->length());
uint32_t i = 0; uint32_t i = 0;
@ -1033,7 +1033,7 @@ bool IterateElements(Isolate* isolate, Handle<JSReceiver> receiver,
if (receiver->IsJSArray()) { if (receiver->IsJSArray()) {
Handle<JSArray> array = Handle<JSArray>::cast(receiver); Handle<JSArray> array = Handle<JSArray>::cast(receiver);
length = static_cast<uint32_t>(array->length()->Number()); length = static_cast<uint32_t>(array->length().Number());
} else { } else {
Handle<Object> val; Handle<Object> val;
ASSIGN_RETURN_ON_EXCEPTION_VALUE( ASSIGN_RETURN_ON_EXCEPTION_VALUE(
@ -1096,8 +1096,8 @@ bool IterateElements(Isolate* isolate, Handle<JSReceiver> receiver,
if (length == 0) break; if (length == 0) break;
// Run through the elements FixedArray and use HasElement and GetElement // Run through the elements FixedArray and use HasElement and GetElement
// to check the prototype for missing elements. // to check the prototype for missing elements.
if (array->elements()->IsFixedArray()) { if (array->elements().IsFixedArray()) {
DCHECK_EQ(array->elements()->length(), 0); DCHECK_EQ(array->elements().length(), 0);
break; break;
} }
Handle<FixedDoubleArray> elements( Handle<FixedDoubleArray> elements(
@ -1197,7 +1197,7 @@ Object Slow_ArrayConcat(BuiltinArguments* args, Handle<Object> species,
Isolate* isolate) { Isolate* isolate) {
int argument_count = args->length(); int argument_count = args->length();
bool is_array_species = *species == isolate->context()->array_function(); bool is_array_species = *species == isolate->context().array_function();
// Pass 1: estimate the length and number of elements of the result. // Pass 1: estimate the length and number of elements of the result.
// The actual length can be larger if any of the arguments have getters // The actual length can be larger if any of the arguments have getters
@ -1214,7 +1214,7 @@ Object Slow_ArrayConcat(BuiltinArguments* args, Handle<Object> species,
uint32_t element_estimate; uint32_t element_estimate;
if (obj->IsJSArray()) { if (obj->IsJSArray()) {
Handle<JSArray> array(Handle<JSArray>::cast(obj)); Handle<JSArray> array(Handle<JSArray>::cast(obj));
length_estimate = static_cast<uint32_t>(array->length()->Number()); length_estimate = static_cast<uint32_t>(array->length().Number());
if (length_estimate != 0) { if (length_estimate != 0) {
ElementsKind array_kind = ElementsKind array_kind =
GetPackedElementsKind(array->GetElementsKind()); GetPackedElementsKind(array->GetElementsKind());
@ -1271,16 +1271,16 @@ Object Slow_ArrayConcat(BuiltinArguments* args, Handle<Object> species,
} else { } else {
DisallowHeapAllocation no_gc; DisallowHeapAllocation no_gc;
JSArray array = JSArray::cast(*obj); JSArray array = JSArray::cast(*obj);
uint32_t length = static_cast<uint32_t>(array->length()->Number()); uint32_t length = static_cast<uint32_t>(array.length().Number());
switch (array->GetElementsKind()) { switch (array.GetElementsKind()) {
case HOLEY_DOUBLE_ELEMENTS: case HOLEY_DOUBLE_ELEMENTS:
case PACKED_DOUBLE_ELEMENTS: { case PACKED_DOUBLE_ELEMENTS: {
// Empty array is FixedArray but not FixedDoubleArray. // Empty array is FixedArray but not FixedDoubleArray.
if (length == 0) break; if (length == 0) break;
FixedDoubleArray elements = FixedDoubleArray elements =
FixedDoubleArray::cast(array->elements()); FixedDoubleArray::cast(array.elements());
for (uint32_t i = 0; i < length; i++) { for (uint32_t i = 0; i < length; i++) {
if (elements->is_the_hole(i)) { if (elements.is_the_hole(i)) {
// TODO(jkummerow/verwaest): We could be a bit more clever // TODO(jkummerow/verwaest): We could be a bit more clever
// here: Check if there are no elements/getters on the // here: Check if there are no elements/getters on the
// prototype chain, and if so, allow creation of a holey // prototype chain, and if so, allow creation of a holey
@ -1289,7 +1289,7 @@ Object Slow_ArrayConcat(BuiltinArguments* args, Handle<Object> species,
failure = true; failure = true;
break; break;
} }
double double_value = elements->get_scalar(i); double double_value = elements.get_scalar(i);
double_storage->set(j, double_value); double_storage->set(j, double_value);
j++; j++;
} }
@ -1298,9 +1298,9 @@ Object Slow_ArrayConcat(BuiltinArguments* args, Handle<Object> species,
case HOLEY_SMI_ELEMENTS: case HOLEY_SMI_ELEMENTS:
case PACKED_SMI_ELEMENTS: { case PACKED_SMI_ELEMENTS: {
Object the_hole = ReadOnlyRoots(isolate).the_hole_value(); Object the_hole = ReadOnlyRoots(isolate).the_hole_value();
FixedArray elements(FixedArray::cast(array->elements())); FixedArray elements(FixedArray::cast(array.elements()));
for (uint32_t i = 0; i < length; i++) { for (uint32_t i = 0; i < length; i++) {
Object element = elements->get(i); Object element = elements.get(i);
if (element == the_hole) { if (element == the_hole) {
failure = true; failure = true;
break; break;
@ -1385,9 +1385,8 @@ bool IsSimpleArray(Isolate* isolate, Handle<JSArray> obj) {
DisallowHeapAllocation no_gc; DisallowHeapAllocation no_gc;
Map map = obj->map(); Map map = obj->map();
// If there is only the 'length' property we are fine. // If there is only the 'length' property we are fine.
if (map->prototype() == if (map.prototype() == isolate->native_context()->initial_array_prototype() &&
isolate->native_context()->initial_array_prototype() && map.NumberOfOwnDescriptors() == 1) {
map->NumberOfOwnDescriptors() == 1) {
return true; return true;
} }
// TODO(cbruni): slower lookup for array subclasses and support slow // TODO(cbruni): slower lookup for array subclasses and support slow
@ -1414,12 +1413,12 @@ MaybeHandle<JSArray> Fast_ArrayConcat(Isolate* isolate,
// and calculating total length. // and calculating total length.
for (int i = 0; i < n_arguments; i++) { for (int i = 0; i < n_arguments; i++) {
Object arg = (*args)[i]; Object arg = (*args)[i];
if (!arg->IsJSArray()) return MaybeHandle<JSArray>(); if (!arg.IsJSArray()) return MaybeHandle<JSArray>();
if (!HasOnlySimpleReceiverElements(isolate, JSObject::cast(arg))) { if (!HasOnlySimpleReceiverElements(isolate, JSObject::cast(arg))) {
return MaybeHandle<JSArray>(); return MaybeHandle<JSArray>();
} }
// TODO(cbruni): support fast concatenation of DICTIONARY_ELEMENTS. // TODO(cbruni): support fast concatenation of DICTIONARY_ELEMENTS.
if (!JSObject::cast(arg)->HasFastElements()) { if (!JSObject::cast(arg).HasFastElements()) {
return MaybeHandle<JSArray>(); return MaybeHandle<JSArray>();
} }
Handle<JSArray> array(JSArray::cast(arg), isolate); Handle<JSArray> array(JSArray::cast(arg), isolate);

View File

@ -43,7 +43,7 @@ Object ConstructBuffer(Isolate* isolate, Handle<JSFunction> target,
isolate, NewRangeError(MessageTemplate::kInvalidArrayBufferLength)); isolate, NewRangeError(MessageTemplate::kInvalidArrayBufferLength));
} }
SharedFlag shared_flag = SharedFlag shared_flag =
(*target == target->native_context()->array_buffer_fun()) (*target == target->native_context().array_buffer_fun())
? SharedFlag::kNotShared ? SharedFlag::kNotShared
: SharedFlag::kShared; : SharedFlag::kShared;
if (!JSArrayBuffer::SetupAllocatingData(Handle<JSArrayBuffer>::cast(result), if (!JSArrayBuffer::SetupAllocatingData(Handle<JSArrayBuffer>::cast(result),
@ -61,12 +61,12 @@ Object ConstructBuffer(Isolate* isolate, Handle<JSFunction> target,
BUILTIN(ArrayBufferConstructor) { BUILTIN(ArrayBufferConstructor) {
HandleScope scope(isolate); HandleScope scope(isolate);
Handle<JSFunction> target = args.target(); Handle<JSFunction> target = args.target();
DCHECK(*target == target->native_context()->array_buffer_fun() || DCHECK(*target == target->native_context().array_buffer_fun() ||
*target == target->native_context()->shared_array_buffer_fun()); *target == target->native_context().shared_array_buffer_fun());
if (args.new_target()->IsUndefined(isolate)) { // [[Call]] if (args.new_target()->IsUndefined(isolate)) { // [[Call]]
THROW_NEW_ERROR_RETURN_FAILURE( THROW_NEW_ERROR_RETURN_FAILURE(
isolate, NewTypeError(MessageTemplate::kConstructorNotFunction, isolate, NewTypeError(MessageTemplate::kConstructorNotFunction,
handle(target->shared()->Name(), isolate))); handle(target->shared().Name(), isolate)));
} }
// [[Construct]] // [[Construct]]
Handle<JSReceiver> new_target = Handle<JSReceiver>::cast(args.new_target()); Handle<JSReceiver> new_target = Handle<JSReceiver>::cast(args.new_target());
@ -120,7 +120,7 @@ BUILTIN(ArrayBufferIsView) {
SealHandleScope shs(isolate); SealHandleScope shs(isolate);
DCHECK_EQ(2, args.length()); DCHECK_EQ(2, args.length());
Object arg = args[1]; Object arg = args[1];
return isolate->heap()->ToBoolean(arg->IsJSArrayBufferView()); return isolate->heap()->ToBoolean(arg.IsJSArrayBufferView());
} }
static Object SliceHelper(BuiltinArguments args, Isolate* isolate, static Object SliceHelper(BuiltinArguments args, Isolate* isolate,

View File

@ -83,8 +83,8 @@ MaybeHandle<BigInt> ThisBigIntValue(Isolate* isolate, Handle<Object> value,
if (value->IsJSValue()) { if (value->IsJSValue()) {
// 2a. Assert: value.[[BigIntData]] is a BigInt value. // 2a. Assert: value.[[BigIntData]] is a BigInt value.
// 2b. Return value.[[BigIntData]]. // 2b. Return value.[[BigIntData]].
Object data = JSValue::cast(*value)->value(); Object data = JSValue::cast(*value).value();
if (data->IsBigInt()) return handle(BigInt::cast(data), isolate); if (data.IsBigInt()) return handle(BigInt::cast(data), isolate);
} }
// 3. Throw a TypeError exception. // 3. Throw a TypeError exception.
THROW_NEW_ERROR( THROW_NEW_ERROR(

View File

@ -832,7 +832,7 @@ void CollectionsBuiltinsAssembler::SameValueZeroSmi(Node* key_smi,
void CollectionsBuiltinsAssembler::BranchIfMapIteratorProtectorValid( void CollectionsBuiltinsAssembler::BranchIfMapIteratorProtectorValid(
Label* if_true, Label* if_false) { Label* if_true, Label* if_false) {
Node* protector_cell = LoadRoot(RootIndex::kMapIteratorProtector); Node* protector_cell = LoadRoot(RootIndex::kMapIteratorProtector);
DCHECK(isolate()->heap()->map_iterator_protector()->IsPropertyCell()); DCHECK(isolate()->heap()->map_iterator_protector().IsPropertyCell());
Branch(WordEqual(LoadObjectField(protector_cell, PropertyCell::kValueOffset), Branch(WordEqual(LoadObjectField(protector_cell, PropertyCell::kValueOffset),
SmiConstant(Isolate::kProtectorValid)), SmiConstant(Isolate::kProtectorValid)),
if_true, if_false); if_true, if_false);
@ -889,7 +889,7 @@ void BranchIfIterableWithOriginalKeyOrValueMapIterator(
void CollectionsBuiltinsAssembler::BranchIfSetIteratorProtectorValid( void CollectionsBuiltinsAssembler::BranchIfSetIteratorProtectorValid(
Label* if_true, Label* if_false) { Label* if_true, Label* if_false) {
Node* const protector_cell = LoadRoot(RootIndex::kSetIteratorProtector); Node* const protector_cell = LoadRoot(RootIndex::kSetIteratorProtector);
DCHECK(isolate()->heap()->set_iterator_protector()->IsPropertyCell()); DCHECK(isolate()->heap()->set_iterator_protector().IsPropertyCell());
Branch(WordEqual(LoadObjectField(protector_cell, PropertyCell::kValueOffset), Branch(WordEqual(LoadObjectField(protector_cell, PropertyCell::kValueOffset),
SmiConstant(Isolate::kProtectorValid)), SmiConstant(Isolate::kProtectorValid)),
if_true, if_false); if_true, if_false);

View File

@ -67,7 +67,7 @@ void LogTimerEvent(Isolate* isolate, BuiltinArguments args,
HandleScope scope(isolate); HandleScope scope(isolate);
std::unique_ptr<char[]> name; std::unique_ptr<char[]> name;
const char* raw_name = "default"; const char* raw_name = "default";
if (args.length() > 1 && args[1]->IsString()) { if (args.length() > 1 && args[1].IsString()) {
// Try converting the first argument to a string. // Try converting the first argument to a string.
name = args.at<String>(1)->ToCString(); name = args.at<String>(1)->ToCString();
raw_name = name.get(); raw_name = name.get();
@ -119,9 +119,9 @@ void InstallContextFunction(Isolate* isolate, Handle<JSObject> target,
name_string, builtin_id, i::LanguageMode::kSloppy); name_string, builtin_id, i::LanguageMode::kSloppy);
Handle<JSFunction> fun = factory->NewFunction(args); Handle<JSFunction> fun = factory->NewFunction(args);
fun->shared()->set_native(true); fun->shared().set_native(true);
fun->shared()->DontAdaptArguments(); fun->shared().DontAdaptArguments();
fun->shared()->set_length(1); fun->shared().set_length(1);
JSObject::AddProperty(isolate, fun, factory->console_context_id_symbol(), JSObject::AddProperty(isolate, fun, factory->console_context_id_symbol(),
handle(Smi::FromInt(context_id), isolate), NONE); handle(Smi::FromInt(context_id), isolate), NONE);

View File

@ -123,12 +123,12 @@ double ParseDateTimeString(Isolate* isolate, Handle<String> str) {
result = DateParser::Parse(isolate, str_content.ToUC16Vector(), *tmp); result = DateParser::Parse(isolate, str_content.ToUC16Vector(), *tmp);
} }
if (!result) return std::numeric_limits<double>::quiet_NaN(); if (!result) return std::numeric_limits<double>::quiet_NaN();
double const day = MakeDay(tmp->get(0)->Number(), tmp->get(1)->Number(), double const day =
tmp->get(2)->Number()); MakeDay(tmp->get(0).Number(), tmp->get(1).Number(), tmp->get(2).Number());
double const time = MakeTime(tmp->get(3)->Number(), tmp->get(4)->Number(), double const time = MakeTime(tmp->get(3).Number(), tmp->get(4).Number(),
tmp->get(5)->Number(), tmp->get(6)->Number()); tmp->get(5).Number(), tmp->get(6).Number());
double date = MakeDate(day, time); double date = MakeDate(day, time);
if (tmp->get(7)->IsNull(isolate)) { if (tmp->get(7).IsNull(isolate)) {
if (date >= -DateCache::kMaxTimeBeforeUTCInMs && if (date >= -DateCache::kMaxTimeBeforeUTCInMs &&
date <= DateCache::kMaxTimeBeforeUTCInMs) { date <= DateCache::kMaxTimeBeforeUTCInMs) {
date = isolate->date_cache()->ToUTC(static_cast<int64_t>(date)); date = isolate->date_cache()->ToUTC(static_cast<int64_t>(date));
@ -136,7 +136,7 @@ double ParseDateTimeString(Isolate* isolate, Handle<String> str) {
return std::numeric_limits<double>::quiet_NaN(); return std::numeric_limits<double>::quiet_NaN();
} }
} else { } else {
date -= tmp->get(7)->Number() * 1000.0; date -= tmp->get(7).Number() * 1000.0;
} }
return DateCache::TimeClip(date); return DateCache::TimeClip(date);
} }
@ -222,7 +222,7 @@ BUILTIN(DateConstructor) {
} else if (argc == 1) { } else if (argc == 1) {
Handle<Object> value = args.at(1); Handle<Object> value = args.at(1);
if (value->IsJSDate()) { if (value->IsJSDate()) {
time_val = Handle<JSDate>::cast(value)->value()->Number(); time_val = Handle<JSDate>::cast(value)->value().Number();
} else { } else {
ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, value, ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, value,
Object::ToPrimitive(value)); Object::ToPrimitive(value));
@ -374,7 +374,7 @@ BUILTIN(DatePrototypeSetDate) {
Handle<Object> value = args.atOrUndefined(isolate, 1); Handle<Object> value = args.atOrUndefined(isolate, 1);
ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, value, ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, value,
Object::ToNumber(isolate, value)); Object::ToNumber(isolate, value));
double time_val = date->value()->Number(); double time_val = date->value().Number();
if (!std::isnan(time_val)) { if (!std::isnan(time_val)) {
int64_t const time_ms = static_cast<int64_t>(time_val); int64_t const time_ms = static_cast<int64_t>(time_val);
int64_t local_time_ms = isolate->date_cache()->ToLocal(time_ms); int64_t local_time_ms = isolate->date_cache()->ToLocal(time_ms);
@ -397,8 +397,8 @@ BUILTIN(DatePrototypeSetFullYear) {
Object::ToNumber(isolate, year)); Object::ToNumber(isolate, year));
double y = year->Number(), m = 0.0, dt = 1.0; double y = year->Number(), m = 0.0, dt = 1.0;
int time_within_day = 0; int time_within_day = 0;
if (!std::isnan(date->value()->Number())) { if (!std::isnan(date->value().Number())) {
int64_t const time_ms = static_cast<int64_t>(date->value()->Number()); int64_t const time_ms = static_cast<int64_t>(date->value().Number());
int64_t local_time_ms = isolate->date_cache()->ToLocal(time_ms); int64_t local_time_ms = isolate->date_cache()->ToLocal(time_ms);
int const days = isolate->date_cache()->DaysFromTime(local_time_ms); int const days = isolate->date_cache()->DaysFromTime(local_time_ms);
time_within_day = isolate->date_cache()->TimeInDay(local_time_ms, days); time_within_day = isolate->date_cache()->TimeInDay(local_time_ms, days);
@ -432,7 +432,7 @@ BUILTIN(DatePrototypeSetHours) {
ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, hour, ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, hour,
Object::ToNumber(isolate, hour)); Object::ToNumber(isolate, hour));
double h = hour->Number(); double h = hour->Number();
double time_val = date->value()->Number(); double time_val = date->value().Number();
if (!std::isnan(time_val)) { if (!std::isnan(time_val)) {
int64_t const time_ms = static_cast<int64_t>(time_val); int64_t const time_ms = static_cast<int64_t>(time_val);
int64_t local_time_ms = isolate->date_cache()->ToLocal(time_ms); int64_t local_time_ms = isolate->date_cache()->ToLocal(time_ms);
@ -471,7 +471,7 @@ BUILTIN(DatePrototypeSetMilliseconds) {
Handle<Object> ms = args.atOrUndefined(isolate, 1); Handle<Object> ms = args.atOrUndefined(isolate, 1);
ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, ms, ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, ms,
Object::ToNumber(isolate, ms)); Object::ToNumber(isolate, ms));
double time_val = date->value()->Number(); double time_val = date->value().Number();
if (!std::isnan(time_val)) { if (!std::isnan(time_val)) {
int64_t const time_ms = static_cast<int64_t>(time_val); int64_t const time_ms = static_cast<int64_t>(time_val);
int64_t local_time_ms = isolate->date_cache()->ToLocal(time_ms); int64_t local_time_ms = isolate->date_cache()->ToLocal(time_ms);
@ -493,7 +493,7 @@ BUILTIN(DatePrototypeSetMinutes) {
Handle<Object> min = args.atOrUndefined(isolate, 1); Handle<Object> min = args.atOrUndefined(isolate, 1);
ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, min, ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, min,
Object::ToNumber(isolate, min)); Object::ToNumber(isolate, min));
double time_val = date->value()->Number(); double time_val = date->value().Number();
if (!std::isnan(time_val)) { if (!std::isnan(time_val)) {
int64_t const time_ms = static_cast<int64_t>(time_val); int64_t const time_ms = static_cast<int64_t>(time_val);
int64_t local_time_ms = isolate->date_cache()->ToLocal(time_ms); int64_t local_time_ms = isolate->date_cache()->ToLocal(time_ms);
@ -528,7 +528,7 @@ BUILTIN(DatePrototypeSetMonth) {
Handle<Object> month = args.atOrUndefined(isolate, 1); Handle<Object> month = args.atOrUndefined(isolate, 1);
ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, month, ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, month,
Object::ToNumber(isolate, month)); Object::ToNumber(isolate, month));
double time_val = date->value()->Number(); double time_val = date->value().Number();
if (!std::isnan(time_val)) { if (!std::isnan(time_val)) {
int64_t const time_ms = static_cast<int64_t>(time_val); int64_t const time_ms = static_cast<int64_t>(time_val);
int64_t local_time_ms = isolate->date_cache()->ToLocal(time_ms); int64_t local_time_ms = isolate->date_cache()->ToLocal(time_ms);
@ -557,7 +557,7 @@ BUILTIN(DatePrototypeSetSeconds) {
Handle<Object> sec = args.atOrUndefined(isolate, 1); Handle<Object> sec = args.atOrUndefined(isolate, 1);
ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, sec, ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, sec,
Object::ToNumber(isolate, sec)); Object::ToNumber(isolate, sec));
double time_val = date->value()->Number(); double time_val = date->value().Number();
if (!std::isnan(time_val)) { if (!std::isnan(time_val)) {
int64_t const time_ms = static_cast<int64_t>(time_val); int64_t const time_ms = static_cast<int64_t>(time_val);
int64_t local_time_ms = isolate->date_cache()->ToLocal(time_ms); int64_t local_time_ms = isolate->date_cache()->ToLocal(time_ms);
@ -595,8 +595,8 @@ BUILTIN(DatePrototypeSetUTCDate) {
Handle<Object> value = args.atOrUndefined(isolate, 1); Handle<Object> value = args.atOrUndefined(isolate, 1);
ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, value, ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, value,
Object::ToNumber(isolate, value)); Object::ToNumber(isolate, value));
if (std::isnan(date->value()->Number())) return date->value(); if (std::isnan(date->value().Number())) return date->value();
int64_t const time_ms = static_cast<int64_t>(date->value()->Number()); int64_t const time_ms = static_cast<int64_t>(date->value().Number());
int const days = isolate->date_cache()->DaysFromTime(time_ms); int const days = isolate->date_cache()->DaysFromTime(time_ms);
int const time_within_day = isolate->date_cache()->TimeInDay(time_ms, days); int const time_within_day = isolate->date_cache()->TimeInDay(time_ms, days);
int year, month, day; int year, month, day;
@ -616,8 +616,8 @@ BUILTIN(DatePrototypeSetUTCFullYear) {
Object::ToNumber(isolate, year)); Object::ToNumber(isolate, year));
double y = year->Number(), m = 0.0, dt = 1.0; double y = year->Number(), m = 0.0, dt = 1.0;
int time_within_day = 0; int time_within_day = 0;
if (!std::isnan(date->value()->Number())) { if (!std::isnan(date->value().Number())) {
int64_t const time_ms = static_cast<int64_t>(date->value()->Number()); int64_t const time_ms = static_cast<int64_t>(date->value().Number());
int const days = isolate->date_cache()->DaysFromTime(time_ms); int const days = isolate->date_cache()->DaysFromTime(time_ms);
time_within_day = isolate->date_cache()->TimeInDay(time_ms, days); time_within_day = isolate->date_cache()->TimeInDay(time_ms, days);
int year, month, day; int year, month, day;
@ -650,7 +650,7 @@ BUILTIN(DatePrototypeSetUTCHours) {
ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, hour, ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, hour,
Object::ToNumber(isolate, hour)); Object::ToNumber(isolate, hour));
double h = hour->Number(); double h = hour->Number();
double time_val = date->value()->Number(); double time_val = date->value().Number();
if (!std::isnan(time_val)) { if (!std::isnan(time_val)) {
int64_t const time_ms = static_cast<int64_t>(time_val); int64_t const time_ms = static_cast<int64_t>(time_val);
int day = isolate->date_cache()->DaysFromTime(time_ms); int day = isolate->date_cache()->DaysFromTime(time_ms);
@ -688,7 +688,7 @@ BUILTIN(DatePrototypeSetUTCMilliseconds) {
Handle<Object> ms = args.atOrUndefined(isolate, 1); Handle<Object> ms = args.atOrUndefined(isolate, 1);
ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, ms, ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, ms,
Object::ToNumber(isolate, ms)); Object::ToNumber(isolate, ms));
double time_val = date->value()->Number(); double time_val = date->value().Number();
if (!std::isnan(time_val)) { if (!std::isnan(time_val)) {
int64_t const time_ms = static_cast<int64_t>(time_val); int64_t const time_ms = static_cast<int64_t>(time_val);
int day = isolate->date_cache()->DaysFromTime(time_ms); int day = isolate->date_cache()->DaysFromTime(time_ms);
@ -709,7 +709,7 @@ BUILTIN(DatePrototypeSetUTCMinutes) {
Handle<Object> min = args.atOrUndefined(isolate, 1); Handle<Object> min = args.atOrUndefined(isolate, 1);
ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, min, ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, min,
Object::ToNumber(isolate, min)); Object::ToNumber(isolate, min));
double time_val = date->value()->Number(); double time_val = date->value().Number();
if (!std::isnan(time_val)) { if (!std::isnan(time_val)) {
int64_t const time_ms = static_cast<int64_t>(time_val); int64_t const time_ms = static_cast<int64_t>(time_val);
int day = isolate->date_cache()->DaysFromTime(time_ms); int day = isolate->date_cache()->DaysFromTime(time_ms);
@ -743,7 +743,7 @@ BUILTIN(DatePrototypeSetUTCMonth) {
Handle<Object> month = args.atOrUndefined(isolate, 1); Handle<Object> month = args.atOrUndefined(isolate, 1);
ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, month, ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, month,
Object::ToNumber(isolate, month)); Object::ToNumber(isolate, month));
double time_val = date->value()->Number(); double time_val = date->value().Number();
if (!std::isnan(time_val)) { if (!std::isnan(time_val)) {
int64_t const time_ms = static_cast<int64_t>(time_val); int64_t const time_ms = static_cast<int64_t>(time_val);
int days = isolate->date_cache()->DaysFromTime(time_ms); int days = isolate->date_cache()->DaysFromTime(time_ms);
@ -771,7 +771,7 @@ BUILTIN(DatePrototypeSetUTCSeconds) {
Handle<Object> sec = args.atOrUndefined(isolate, 1); Handle<Object> sec = args.atOrUndefined(isolate, 1);
ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, sec, ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, sec,
Object::ToNumber(isolate, sec)); Object::ToNumber(isolate, sec));
double time_val = date->value()->Number(); double time_val = date->value().Number();
if (!std::isnan(time_val)) { if (!std::isnan(time_val)) {
int64_t const time_ms = static_cast<int64_t>(time_val); int64_t const time_ms = static_cast<int64_t>(time_val);
int day = isolate->date_cache()->DaysFromTime(time_ms); int day = isolate->date_cache()->DaysFromTime(time_ms);
@ -796,7 +796,7 @@ BUILTIN(DatePrototypeToDateString) {
HandleScope scope(isolate); HandleScope scope(isolate);
CHECK_RECEIVER(JSDate, date, "Date.prototype.toDateString"); CHECK_RECEIVER(JSDate, date, "Date.prototype.toDateString");
DateBuffer buffer = DateBuffer buffer =
ToDateString(date->value()->Number(), isolate->date_cache(), kDateOnly); ToDateString(date->value().Number(), isolate->date_cache(), kDateOnly);
RETURN_RESULT_OR_FAILURE( RETURN_RESULT_OR_FAILURE(
isolate, isolate->factory()->NewStringFromUtf8(VectorOf(buffer))); isolate, isolate->factory()->NewStringFromUtf8(VectorOf(buffer)));
} }
@ -805,7 +805,7 @@ BUILTIN(DatePrototypeToDateString) {
BUILTIN(DatePrototypeToISOString) { BUILTIN(DatePrototypeToISOString) {
HandleScope scope(isolate); HandleScope scope(isolate);
CHECK_RECEIVER(JSDate, date, "Date.prototype.toISOString"); CHECK_RECEIVER(JSDate, date, "Date.prototype.toISOString");
double const time_val = date->value()->Number(); double const time_val = date->value().Number();
if (std::isnan(time_val)) { if (std::isnan(time_val)) {
THROW_NEW_ERROR_RETURN_FAILURE( THROW_NEW_ERROR_RETURN_FAILURE(
isolate, NewRangeError(MessageTemplate::kInvalidTimeValue)); isolate, NewRangeError(MessageTemplate::kInvalidTimeValue));
@ -833,7 +833,7 @@ BUILTIN(DatePrototypeToString) {
HandleScope scope(isolate); HandleScope scope(isolate);
CHECK_RECEIVER(JSDate, date, "Date.prototype.toString"); CHECK_RECEIVER(JSDate, date, "Date.prototype.toString");
DateBuffer buffer = DateBuffer buffer =
ToDateString(date->value()->Number(), isolate->date_cache()); ToDateString(date->value().Number(), isolate->date_cache());
RETURN_RESULT_OR_FAILURE( RETURN_RESULT_OR_FAILURE(
isolate, isolate->factory()->NewStringFromUtf8(VectorOf(buffer))); isolate, isolate->factory()->NewStringFromUtf8(VectorOf(buffer)));
} }
@ -843,7 +843,7 @@ BUILTIN(DatePrototypeToTimeString) {
HandleScope scope(isolate); HandleScope scope(isolate);
CHECK_RECEIVER(JSDate, date, "Date.prototype.toTimeString"); CHECK_RECEIVER(JSDate, date, "Date.prototype.toTimeString");
DateBuffer buffer = DateBuffer buffer =
ToDateString(date->value()->Number(), isolate->date_cache(), kTimeOnly); ToDateString(date->value().Number(), isolate->date_cache(), kTimeOnly);
RETURN_RESULT_OR_FAILURE( RETURN_RESULT_OR_FAILURE(
isolate, isolate->factory()->NewStringFromUtf8(VectorOf(buffer))); isolate, isolate->factory()->NewStringFromUtf8(VectorOf(buffer)));
} }
@ -908,7 +908,7 @@ BUILTIN(DatePrototypeToLocaleTimeString) {
BUILTIN(DatePrototypeToUTCString) { BUILTIN(DatePrototypeToUTCString) {
HandleScope scope(isolate); HandleScope scope(isolate);
CHECK_RECEIVER(JSDate, date, "Date.prototype.toUTCString"); CHECK_RECEIVER(JSDate, date, "Date.prototype.toUTCString");
double const time_val = date->value()->Number(); double const time_val = date->value().Number();
if (std::isnan(time_val)) { if (std::isnan(time_val)) {
return *isolate->factory()->NewStringFromAsciiChecked("Invalid Date"); return *isolate->factory()->NewStringFromAsciiChecked("Invalid Date");
} }
@ -929,7 +929,7 @@ BUILTIN(DatePrototypeToUTCString) {
BUILTIN(DatePrototypeGetYear) { BUILTIN(DatePrototypeGetYear) {
HandleScope scope(isolate); HandleScope scope(isolate);
CHECK_RECEIVER(JSDate, date, "Date.prototype.getYear"); CHECK_RECEIVER(JSDate, date, "Date.prototype.getYear");
double time_val = date->value()->Number(); double time_val = date->value().Number();
if (std::isnan(time_val)) return date->value(); if (std::isnan(time_val)) return date->value();
int64_t time_ms = static_cast<int64_t>(time_val); int64_t time_ms = static_cast<int64_t>(time_val);
int64_t local_time_ms = isolate->date_cache()->ToLocal(time_ms); int64_t local_time_ms = isolate->date_cache()->ToLocal(time_ms);
@ -954,8 +954,8 @@ BUILTIN(DatePrototypeSetYear) {
} }
} }
int time_within_day = 0; int time_within_day = 0;
if (!std::isnan(date->value()->Number())) { if (!std::isnan(date->value().Number())) {
int64_t const time_ms = static_cast<int64_t>(date->value()->Number()); int64_t const time_ms = static_cast<int64_t>(date->value().Number());
int64_t local_time_ms = isolate->date_cache()->ToLocal(time_ms); int64_t local_time_ms = isolate->date_cache()->ToLocal(time_ms);
int const days = isolate->date_cache()->DaysFromTime(local_time_ms); int const days = isolate->date_cache()->DaysFromTime(local_time_ms);
time_within_day = isolate->date_cache()->TimeInDay(local_time_ms, days); time_within_day = isolate->date_cache()->TimeInDay(local_time_ms, days);

View File

@ -39,7 +39,7 @@ BUILTIN(ExtrasUtilsUncurryThis) {
DCHECK_EQ(2, args.length()); DCHECK_EQ(2, args.length());
Handle<JSFunction> function = args.at<JSFunction>(1); Handle<JSFunction> function = args.at<JSFunction>(1);
Handle<NativeContext> native_context(isolate->context()->native_context(), Handle<NativeContext> native_context(isolate->context().native_context(),
isolate); isolate);
Handle<Context> context = isolate->factory()->NewBuiltinContext( Handle<Context> context = isolate->factory()->NewBuiltinContext(
native_context, native_context,
@ -64,7 +64,7 @@ BUILTIN(ExtrasUtilsUncurryThis) {
BUILTIN(ExtrasUtilsCallReflectApply) { BUILTIN(ExtrasUtilsCallReflectApply) {
HandleScope scope(isolate); HandleScope scope(isolate);
Handle<Context> context(isolate->context(), isolate); Handle<Context> context(isolate->context(), isolate);
Handle<NativeContext> native_context(isolate->context()->native_context(), Handle<NativeContext> native_context(isolate->context().native_context(),
isolate); isolate);
Handle<JSFunction> function( Handle<JSFunction> function(
JSFunction::cast(context->get( JSFunction::cast(context->get(

View File

@ -90,7 +90,7 @@ MaybeHandle<Object> CreateDynamicFunction(Isolate* isolate,
Execution::Call(isolate, function, target_global_proxy, 0, nullptr), Execution::Call(isolate, function, target_global_proxy, 0, nullptr),
Object); Object);
function = Handle<JSFunction>::cast(result); function = Handle<JSFunction>::cast(result);
function->shared()->set_name_should_print_as_anonymous(true); function->shared().set_name_should_print_as_anonymous(true);
} }
// If new.target is equal to target then the function created // If new.target is equal to target then the function created
@ -149,7 +149,7 @@ BUILTIN(AsyncFunctionConstructor) {
// determined after the function is resumed. // determined after the function is resumed.
Handle<JSFunction> func = Handle<JSFunction>::cast(maybe_func); Handle<JSFunction> func = Handle<JSFunction>::cast(maybe_func);
Handle<Script> script = Handle<Script> script =
handle(Script::cast(func->shared()->script()), isolate); handle(Script::cast(func->shared().script()), isolate);
int position = Script::GetEvalPosition(isolate, script); int position = Script::GetEvalPosition(isolate, script);
USE(position); USE(position);
@ -168,7 +168,7 @@ BUILTIN(AsyncGeneratorFunctionConstructor) {
// determined after the function is resumed. // determined after the function is resumed.
Handle<JSFunction> func = Handle<JSFunction>::cast(maybe_func); Handle<JSFunction> func = Handle<JSFunction>::cast(maybe_func);
Handle<Script> script = Handle<Script> script =
handle(Script::cast(func->shared()->script()), isolate); handle(Script::cast(func->shared().script()), isolate);
int position = Script::GetEvalPosition(isolate, script); int position = Script::GetEvalPosition(isolate, script);
USE(position); USE(position);
@ -279,7 +279,7 @@ BUILTIN(FunctionPrototypeToString) {
// With the revised toString behavior, all callable objects are valid // With the revised toString behavior, all callable objects are valid
// receivers for this method. // receivers for this method.
if (receiver->IsJSReceiver() && if (receiver->IsJSReceiver() &&
JSReceiver::cast(*receiver)->map()->is_callable()) { JSReceiver::cast(*receiver).map().is_callable()) {
return ReadOnlyRoots(isolate).function_native_code_string(); return ReadOnlyRoots(isolate).function_native_code_string();
} }
THROW_NEW_ERROR_RETURN_FAILURE( THROW_NEW_ERROR_RETURN_FAILURE(

View File

@ -227,7 +227,7 @@ namespace {
Handle<JSFunction> CreateBoundFunction(Isolate* isolate, Handle<JSFunction> CreateBoundFunction(Isolate* isolate,
Handle<JSObject> object, Handle<JSObject> object,
Builtins::Name builtin_id, int len) { Builtins::Name builtin_id, int len) {
Handle<NativeContext> native_context(isolate->context()->native_context(), Handle<NativeContext> native_context(isolate->context().native_context(),
isolate); isolate);
Handle<Context> context = isolate->factory()->NewBuiltinContext( Handle<Context> context = isolate->factory()->NewBuiltinContext(
native_context, native_context,
@ -483,7 +483,7 @@ BUILTIN(NumberFormatInternalFormatNumber) {
} }
icu::number::LocalizedNumberFormatter* icu_localized_number_formatter = icu::number::LocalizedNumberFormatter* icu_localized_number_formatter =
number_format->icu_number_formatter()->raw(); number_format->icu_number_formatter().raw();
CHECK_NOT_NULL(icu_localized_number_formatter); CHECK_NOT_NULL(icu_localized_number_formatter);
// Return FormatNumber(nf, x). // Return FormatNumber(nf, x).
@ -970,7 +970,7 @@ BUILTIN(CollatorInternalCompare) {
Object::ToString(isolate, y)); Object::ToString(isolate, y));
// 7. Return CompareStrings(collator, X, Y). // 7. Return CompareStrings(collator, X, Y).
icu::Collator* icu_collator = collator->icu_collator()->raw(); icu::Collator* icu_collator = collator->icu_collator().raw();
CHECK_NOT_NULL(icu_collator); CHECK_NOT_NULL(icu_collator);
return *Intl::CompareStrings(isolate, *icu_collator, string_x, string_y); return *Intl::CompareStrings(isolate, *icu_collator, string_x, string_y);
} }
@ -1072,7 +1072,7 @@ BUILTIN(SegmenterPrototypeSegment) {
RETURN_RESULT_OR_FAILURE( RETURN_RESULT_OR_FAILURE(
isolate, isolate,
JSSegmentIterator::Create( JSSegmentIterator::Create(
isolate, segmenter_holder->icu_break_iterator()->raw()->clone(), isolate, segmenter_holder->icu_break_iterator().raw()->clone(),
segmenter_holder->granularity(), text)); segmenter_holder->granularity(), text));
} }

View File

@ -163,13 +163,13 @@ BUILTIN(AtomicsWait) {
double timeout_number; double timeout_number;
if (timeout->IsUndefined(isolate)) { if (timeout->IsUndefined(isolate)) {
timeout_number = ReadOnlyRoots(isolate).infinity_value()->Number(); timeout_number = ReadOnlyRoots(isolate).infinity_value().Number();
} else { } else {
ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, timeout, ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, timeout,
Object::ToNumber(isolate, timeout)); Object::ToNumber(isolate, timeout));
timeout_number = timeout->Number(); timeout_number = timeout->Number();
if (std::isnan(timeout_number)) if (std::isnan(timeout_number))
timeout_number = ReadOnlyRoots(isolate).infinity_value()->Number(); timeout_number = ReadOnlyRoots(isolate).infinity_value().Number();
else if (timeout_number < 0) else if (timeout_number < 0)
timeout_number = 0; timeout_number = 0;
} }

View File

@ -2023,7 +2023,7 @@ void StringBuiltinsAssembler::BranchIfStringPrimitiveWithNoCustomIteration(
// Check that the String iterator hasn't been modified in a way that would // Check that the String iterator hasn't been modified in a way that would
// affect iteration. // affect iteration.
Node* protector_cell = LoadRoot(RootIndex::kStringIteratorProtector); Node* protector_cell = LoadRoot(RootIndex::kStringIteratorProtector);
DCHECK(isolate()->heap()->string_iterator_protector()->IsPropertyCell()); DCHECK(isolate()->heap()->string_iterator_protector().IsPropertyCell());
Branch(WordEqual(LoadObjectField(protector_cell, PropertyCell::kValueOffset), Branch(WordEqual(LoadObjectField(protector_cell, PropertyCell::kValueOffset),
SmiConstant(Isolate::kProtectorValid)), SmiConstant(Isolate::kProtectorValid)),
if_true, if_false); if_true, if_false);

View File

@ -56,11 +56,11 @@ BUILTIN(SymbolKeyFor) {
Object result; Object result;
if (symbol->is_public()) { if (symbol->is_public()) {
result = symbol->name(); result = symbol->name();
DCHECK(result->IsString()); DCHECK(result.IsString());
} else { } else {
result = ReadOnlyRoots(isolate).undefined_value(); result = ReadOnlyRoots(isolate).undefined_value();
} }
DCHECK_EQ(isolate->heap()->public_symbol_table()->SlowReverseLookup(*symbol), DCHECK_EQ(isolate->heap()->public_symbol_table().SlowReverseLookup(*symbol),
result); result);
return result; return result;
} }

View File

@ -33,7 +33,7 @@ int64_t CapRelativeIndex(Handle<Object> num, int64_t minimum, int64_t maximum) {
: std::min<int64_t>(relative, maximum); : std::min<int64_t>(relative, maximum);
} else { } else {
DCHECK(num->IsHeapNumber()); DCHECK(num->IsHeapNumber());
double relative = HeapNumber::cast(*num)->value(); double relative = HeapNumber::cast(*num).value();
DCHECK(!std::isnan(relative)); DCHECK(!std::isnan(relative));
return static_cast<int64_t>( return static_cast<int64_t>(
relative < 0 ? std::max<double>(relative + maximum, minimum) relative < 0 ? std::max<double>(relative + maximum, minimum)

View File

@ -66,31 +66,31 @@ class BuiltinArguments : public Arguments {
// through the BuiltinArguments object args. // through the BuiltinArguments object args.
// TODO(cbruni): add global flag to check whether any tracing events have been // TODO(cbruni): add global flag to check whether any tracing events have been
// enabled. // enabled.
#define BUILTIN(name) \ #define BUILTIN(name) \
V8_WARN_UNUSED_RESULT static Object Builtin_Impl_##name( \ V8_WARN_UNUSED_RESULT static Object Builtin_Impl_##name( \
BuiltinArguments args, Isolate* isolate); \ BuiltinArguments args, Isolate* isolate); \
\ \
V8_NOINLINE static Address Builtin_Impl_Stats_##name( \ V8_NOINLINE static Address Builtin_Impl_Stats_##name( \
int args_length, Address* args_object, Isolate* isolate) { \ int args_length, Address* args_object, Isolate* isolate) { \
BuiltinArguments args(args_length, args_object); \ BuiltinArguments args(args_length, args_object); \
RuntimeCallTimerScope timer(isolate, \ RuntimeCallTimerScope timer(isolate, \
RuntimeCallCounterId::kBuiltin_##name); \ RuntimeCallCounterId::kBuiltin_##name); \
TRACE_EVENT0(TRACE_DISABLED_BY_DEFAULT("v8.runtime"), \ TRACE_EVENT0(TRACE_DISABLED_BY_DEFAULT("v8.runtime"), \
"V8.Builtin_" #name); \ "V8.Builtin_" #name); \
return Builtin_Impl_##name(args, isolate)->ptr(); \ return Builtin_Impl_##name(args, isolate).ptr(); \
} \ } \
\ \
V8_WARN_UNUSED_RESULT Address Builtin_##name( \ V8_WARN_UNUSED_RESULT Address Builtin_##name( \
int args_length, Address* args_object, Isolate* isolate) { \ int args_length, Address* args_object, Isolate* isolate) { \
DCHECK(isolate->context().is_null() || isolate->context()->IsContext()); \ DCHECK(isolate->context().is_null() || isolate->context().IsContext()); \
if (V8_UNLIKELY(TracingFlags::is_runtime_stats_enabled())) { \ if (V8_UNLIKELY(TracingFlags::is_runtime_stats_enabled())) { \
return Builtin_Impl_Stats_##name(args_length, args_object, isolate); \ return Builtin_Impl_Stats_##name(args_length, args_object, isolate); \
} \ } \
BuiltinArguments args(args_length, args_object); \ BuiltinArguments args(args_length, args_object); \
return Builtin_Impl_##name(args, isolate)->ptr(); \ return Builtin_Impl_##name(args, isolate).ptr(); \
} \ } \
\ \
V8_WARN_UNUSED_RESULT static Object Builtin_Impl_##name( \ V8_WARN_UNUSED_RESULT static Object Builtin_Impl_##name( \
BuiltinArguments args, Isolate* isolate) BuiltinArguments args, Isolate* isolate)
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------

View File

@ -15,7 +15,7 @@ BUILTIN(FinalizationGroupConstructor) {
if (args.new_target()->IsUndefined(isolate)) { // [[Call]] if (args.new_target()->IsUndefined(isolate)) { // [[Call]]
THROW_NEW_ERROR_RETURN_FAILURE( THROW_NEW_ERROR_RETURN_FAILURE(
isolate, NewTypeError(MessageTemplate::kConstructorNotFunction, isolate, NewTypeError(MessageTemplate::kConstructorNotFunction,
handle(target->shared()->Name(), isolate))); handle(target->shared().Name(), isolate)));
} }
// [[Construct]] // [[Construct]]
Handle<JSReceiver> new_target = Handle<JSReceiver>::cast(args.new_target()); Handle<JSReceiver> new_target = Handle<JSReceiver>::cast(args.new_target());
@ -38,9 +38,9 @@ BUILTIN(FinalizationGroupConstructor) {
finalization_group->set_flags( finalization_group->set_flags(
JSFinalizationGroup::ScheduledForCleanupField::encode(false)); JSFinalizationGroup::ScheduledForCleanupField::encode(false));
DCHECK(finalization_group->active_cells()->IsUndefined(isolate)); DCHECK(finalization_group->active_cells().IsUndefined(isolate));
DCHECK(finalization_group->cleared_cells()->IsUndefined(isolate)); DCHECK(finalization_group->cleared_cells().IsUndefined(isolate));
DCHECK(finalization_group->key_map()->IsUndefined(isolate)); DCHECK(finalization_group->key_map().IsUndefined(isolate));
return *finalization_group; return *finalization_group;
} }
@ -125,7 +125,7 @@ BUILTIN(WeakRefConstructor) {
if (args.new_target()->IsUndefined(isolate)) { // [[Call]] if (args.new_target()->IsUndefined(isolate)) { // [[Call]]
THROW_NEW_ERROR_RETURN_FAILURE( THROW_NEW_ERROR_RETURN_FAILURE(
isolate, NewTypeError(MessageTemplate::kConstructorNotFunction, isolate, NewTypeError(MessageTemplate::kConstructorNotFunction,
handle(target->shared()->Name(), isolate))); handle(target->shared().Name(), isolate)));
} }
// [[Construct]] // [[Construct]]
Handle<JSReceiver> new_target = Handle<JSReceiver>::cast(args.new_target()); Handle<JSReceiver> new_target = Handle<JSReceiver>::cast(args.new_target());
@ -155,14 +155,14 @@ BUILTIN(WeakRefConstructor) {
BUILTIN(WeakRefDeref) { BUILTIN(WeakRefDeref) {
HandleScope scope(isolate); HandleScope scope(isolate);
CHECK_RECEIVER(JSWeakRef, weak_ref, "WeakRef.prototype.deref"); CHECK_RECEIVER(JSWeakRef, weak_ref, "WeakRef.prototype.deref");
if (weak_ref->target()->IsJSReceiver()) { if (weak_ref->target().IsJSReceiver()) {
Handle<JSReceiver> target = Handle<JSReceiver> target =
handle(JSReceiver::cast(weak_ref->target()), isolate); handle(JSReceiver::cast(weak_ref->target()), isolate);
// AddKeepDuringJobTarget might allocate and cause a GC, but it won't clear // AddKeepDuringJobTarget might allocate and cause a GC, but it won't clear
// weak_ref since we hold a Handle to its target. // weak_ref since we hold a Handle to its target.
isolate->heap()->AddKeepDuringJobTarget(target); isolate->heap()->AddKeepDuringJobTarget(target);
} else { } else {
DCHECK(weak_ref->target()->IsUndefined(isolate)); DCHECK(weak_ref->target().IsUndefined(isolate));
} }
return weak_ref->target(); return weak_ref->target();
} }

View File

@ -76,13 +76,13 @@ const char* Builtins::Lookup(Address pc) {
// Off-heap pc's can be looked up through binary search. // Off-heap pc's can be looked up through binary search.
if (FLAG_embedded_builtins) { if (FLAG_embedded_builtins) {
Code maybe_builtin = InstructionStream::TryLookupCode(isolate_, pc); Code maybe_builtin = InstructionStream::TryLookupCode(isolate_, pc);
if (!maybe_builtin.is_null()) return name(maybe_builtin->builtin_index()); if (!maybe_builtin.is_null()) return name(maybe_builtin.builtin_index());
} }
// May be called during initialization (disassembler). // May be called during initialization (disassembler).
if (initialized_) { if (initialized_) {
for (int i = 0; i < builtin_count; i++) { for (int i = 0; i < builtin_count; i++) {
if (isolate_->heap()->builtin(i)->contains(pc)) return name(i); if (isolate_->heap()->builtin(i).contains(pc)) return name(i);
} }
} }
return nullptr; return nullptr;
@ -185,7 +185,7 @@ void Builtins::PrintBuiltinSize() {
const char* kind = KindNameOf(i); const char* kind = KindNameOf(i);
Code code = builtin(i); Code code = builtin(i);
PrintF(stdout, "%s Builtin, %s, %d\n", kind, builtin_name, PrintF(stdout, "%s Builtin, %s, %d\n", kind, builtin_name,
code->InstructionSize()); code.InstructionSize());
} }
} }
@ -197,7 +197,7 @@ Address Builtins::CppEntryOf(int index) {
// static // static
bool Builtins::IsBuiltin(const Code code) { bool Builtins::IsBuiltin(const Code code) {
return Builtins::IsBuiltinId(code->builtin_index()); return Builtins::IsBuiltinId(code.builtin_index());
} }
bool Builtins::IsBuiltinHandle(Handle<HeapObject> maybe_code, bool Builtins::IsBuiltinHandle(Handle<HeapObject> maybe_code,
@ -216,7 +216,7 @@ bool Builtins::IsBuiltinHandle(Handle<HeapObject> maybe_code,
// static // static
bool Builtins::IsIsolateIndependentBuiltin(const Code code) { bool Builtins::IsIsolateIndependentBuiltin(const Code code) {
if (FLAG_embedded_builtins) { if (FLAG_embedded_builtins) {
const int builtin_index = code->builtin_index(); const int builtin_index = code.builtin_index();
return Builtins::IsBuiltinId(builtin_index) && return Builtins::IsBuiltinId(builtin_index) &&
Builtins::IsIsolateIndependent(builtin_index); Builtins::IsIsolateIndependent(builtin_index);
} else { } else {
@ -245,7 +245,7 @@ void Builtins::UpdateBuiltinEntryTable(Isolate* isolate) {
Heap* heap = isolate->heap(); Heap* heap = isolate->heap();
Address* builtin_entry_table = isolate->builtin_entry_table(); Address* builtin_entry_table = isolate->builtin_entry_table();
for (int i = 0; i < builtin_count; i++) { for (int i = 0; i < builtin_count; i++) {
builtin_entry_table[i] = heap->builtin(i)->InstructionStart(); builtin_entry_table[i] = heap->builtin(i).InstructionStart();
} }
} }

View File

@ -72,7 +72,7 @@ void BuiltinsConstantsTableBuilder::PatchSelfReference(
DCHECK(isolate_->IsGeneratingEmbeddedBuiltins()); DCHECK(isolate_->IsGeneratingEmbeddedBuiltins());
DCHECK(self_reference->IsOddball()); DCHECK(self_reference->IsOddball());
DCHECK(Oddball::cast(*self_reference)->kind() == DCHECK(Oddball::cast(*self_reference).kind() ==
Oddball::kSelfReferenceMarker); Oddball::kSelfReferenceMarker);
#endif #endif
@ -101,20 +101,20 @@ void BuiltinsConstantsTableBuilder::Finalize() {
for (auto it = it_scope.begin(); it != it_scope.end(); ++it) { for (auto it = it_scope.begin(); it != it_scope.end(); ++it) {
uint32_t index = *it.entry(); uint32_t index = *it.entry();
Object value = it.key(); Object value = it.key();
if (value->IsCode() && Code::cast(value)->kind() == Code::BUILTIN) { if (value.IsCode() && Code::cast(value).kind() == Code::BUILTIN) {
// Replace placeholder code objects with the real builtin. // Replace placeholder code objects with the real builtin.
// See also: SetupIsolateDelegate::PopulateWithPlaceholders. // See also: SetupIsolateDelegate::PopulateWithPlaceholders.
// TODO(jgruber): Deduplicate placeholders and their corresponding // TODO(jgruber): Deduplicate placeholders and their corresponding
// builtin. // builtin.
value = builtins->builtin(Code::cast(value)->builtin_index()); value = builtins->builtin(Code::cast(value).builtin_index());
} }
DCHECK(value->IsHeapObject()); DCHECK(value.IsHeapObject());
table->set(index, value); table->set(index, value);
} }
#ifdef DEBUG #ifdef DEBUG
for (int i = 0; i < map_.size(); i++) { for (int i = 0; i < map_.size(); i++) {
DCHECK(table->get(i)->IsHeapObject()); DCHECK(table->get(i).IsHeapObject());
DCHECK_NE(ReadOnlyRoots(isolate_).undefined_value(), table->get(i)); DCHECK_NE(ReadOnlyRoots(isolate_).undefined_value(), table->get(i));
DCHECK_NE(ReadOnlyRoots(isolate_).self_reference_marker(), table->get(i)); DCHECK_NE(ReadOnlyRoots(isolate_).self_reference_marker(), table->get(i));
} }

View File

@ -1382,7 +1382,7 @@ static void Generate_InterpreterEnterBytecode(MacroAssembler* masm) {
__ bind(&trampoline_loaded); __ bind(&trampoline_loaded);
__ Pop(eax); __ Pop(eax);
__ add(scratch, Immediate(interpreter_entry_return_pc_offset->value())); __ add(scratch, Immediate(interpreter_entry_return_pc_offset.value()));
__ push(scratch); __ push(scratch);
// Initialize the dispatch table register. // Initialize the dispatch table register.

View File

@ -1304,7 +1304,7 @@ static void Generate_InterpreterEnterBytecode(MacroAssembler* masm) {
__ lw(t0, MemOperand(t0)); __ lw(t0, MemOperand(t0));
__ bind(&trampoline_loaded); __ bind(&trampoline_loaded);
__ Addu(ra, t0, Operand(interpreter_entry_return_pc_offset->value())); __ Addu(ra, t0, Operand(interpreter_entry_return_pc_offset.value()));
// Initialize the dispatch table register. // Initialize the dispatch table register.
__ li(kInterpreterDispatchTableRegister, __ li(kInterpreterDispatchTableRegister,

View File

@ -1321,7 +1321,7 @@ static void Generate_InterpreterEnterBytecode(MacroAssembler* masm) {
__ Ld(t0, MemOperand(t0)); __ Ld(t0, MemOperand(t0));
__ bind(&trampoline_loaded); __ bind(&trampoline_loaded);
__ Daddu(ra, t0, Operand(interpreter_entry_return_pc_offset->value())); __ Daddu(ra, t0, Operand(interpreter_entry_return_pc_offset.value()));
// Initialize the dispatch table register. // Initialize the dispatch table register.
__ li(kInterpreterDispatchTableRegister, __ li(kInterpreterDispatchTableRegister,

View File

@ -1365,7 +1365,7 @@ static void Generate_InterpreterEnterBytecode(MacroAssembler* masm) {
__ LoadP(r5, MemOperand(r5)); __ LoadP(r5, MemOperand(r5));
__ bind(&trampoline_loaded); __ bind(&trampoline_loaded);
__ addi(r0, r5, Operand(interpreter_entry_return_pc_offset->value())); __ addi(r0, r5, Operand(interpreter_entry_return_pc_offset.value()));
__ mtlr(r0); __ mtlr(r0);
// Initialize the dispatch table register. // Initialize the dispatch table register.

View File

@ -214,7 +214,7 @@ Code BuildWithCodeStubAssemblerCS(Isolate* isolate, int32_t builtin_index,
// static // static
void SetupIsolateDelegate::AddBuiltin(Builtins* builtins, int index, void SetupIsolateDelegate::AddBuiltin(Builtins* builtins, int index,
Code code) { Code code) {
DCHECK_EQ(index, code->builtin_index()); DCHECK_EQ(index, code.builtin_index());
builtins->set_builtin(index, code); builtins->set_builtin(index, code);
} }
@ -245,7 +245,7 @@ void SetupIsolateDelegate::ReplacePlaceholders(Isolate* isolate) {
HeapIterator iterator(isolate->heap()); HeapIterator iterator(isolate->heap());
for (HeapObject obj = iterator.next(); !obj.is_null(); for (HeapObject obj = iterator.next(); !obj.is_null();
obj = iterator.next()) { obj = iterator.next()) {
if (!obj->IsCode()) continue; if (!obj.IsCode()) continue;
Code code = Code::cast(obj); Code code = Code::cast(obj);
bool flush_icache = false; bool flush_icache = false;
for (RelocIterator it(code, kRelocMask); !it.done(); it.next()) { for (RelocIterator it(code, kRelocMask); !it.done(); it.next()) {
@ -253,26 +253,26 @@ void SetupIsolateDelegate::ReplacePlaceholders(Isolate* isolate) {
if (RelocInfo::IsCodeTargetMode(rinfo->rmode())) { if (RelocInfo::IsCodeTargetMode(rinfo->rmode())) {
Code target = Code::GetCodeFromTargetAddress(rinfo->target_address()); Code target = Code::GetCodeFromTargetAddress(rinfo->target_address());
DCHECK_IMPLIES(RelocInfo::IsRelativeCodeTarget(rinfo->rmode()), DCHECK_IMPLIES(RelocInfo::IsRelativeCodeTarget(rinfo->rmode()),
Builtins::IsIsolateIndependent(target->builtin_index())); Builtins::IsIsolateIndependent(target.builtin_index()));
if (!target->is_builtin()) continue; if (!target.is_builtin()) continue;
Code new_target = builtins->builtin(target->builtin_index()); Code new_target = builtins->builtin(target.builtin_index());
rinfo->set_target_address(new_target->raw_instruction_start(), rinfo->set_target_address(new_target.raw_instruction_start(),
UPDATE_WRITE_BARRIER, SKIP_ICACHE_FLUSH); UPDATE_WRITE_BARRIER, SKIP_ICACHE_FLUSH);
} else { } else {
DCHECK(RelocInfo::IsEmbeddedObjectMode(rinfo->rmode())); DCHECK(RelocInfo::IsEmbeddedObjectMode(rinfo->rmode()));
Object object = rinfo->target_object(); Object object = rinfo->target_object();
if (!object->IsCode()) continue; if (!object.IsCode()) continue;
Code target = Code::cast(object); Code target = Code::cast(object);
if (!target->is_builtin()) continue; if (!target.is_builtin()) continue;
Code new_target = builtins->builtin(target->builtin_index()); Code new_target = builtins->builtin(target.builtin_index());
rinfo->set_target_object(isolate->heap(), new_target, rinfo->set_target_object(isolate->heap(), new_target,
UPDATE_WRITE_BARRIER, SKIP_ICACHE_FLUSH); UPDATE_WRITE_BARRIER, SKIP_ICACHE_FLUSH);
} }
flush_icache = true; flush_icache = true;
} }
if (flush_icache) { if (flush_icache) {
FlushInstructionCache(code->raw_instruction_start(), FlushInstructionCache(code.raw_instruction_start(),
code->raw_instruction_size()); code.raw_instruction_size());
} }
} }
} }
@ -359,13 +359,13 @@ void SetupIsolateDelegate::SetupBuiltinsInternal(Isolate* isolate) {
ReplacePlaceholders(isolate); ReplacePlaceholders(isolate);
#define SET_PROMISE_REJECTION_PREDICTION(Name) \ #define SET_PROMISE_REJECTION_PREDICTION(Name) \
builtins->builtin(Builtins::k##Name)->set_is_promise_rejection(true); builtins->builtin(Builtins::k##Name).set_is_promise_rejection(true);
BUILTIN_PROMISE_REJECTION_PREDICTION_LIST(SET_PROMISE_REJECTION_PREDICTION) BUILTIN_PROMISE_REJECTION_PREDICTION_LIST(SET_PROMISE_REJECTION_PREDICTION)
#undef SET_PROMISE_REJECTION_PREDICTION #undef SET_PROMISE_REJECTION_PREDICTION
#define SET_EXCEPTION_CAUGHT_PREDICTION(Name) \ #define SET_EXCEPTION_CAUGHT_PREDICTION(Name) \
builtins->builtin(Builtins::k##Name)->set_is_exception_caught(true); builtins->builtin(Builtins::k##Name).set_is_exception_caught(true);
BUILTIN_EXCEPTION_CAUGHT_PREDICTION_LIST(SET_EXCEPTION_CAUGHT_PREDICTION) BUILTIN_EXCEPTION_CAUGHT_PREDICTION_LIST(SET_EXCEPTION_CAUGHT_PREDICTION)
#undef SET_EXCEPTION_CAUGHT_PREDICTION #undef SET_EXCEPTION_CAUGHT_PREDICTION

View File

@ -1390,7 +1390,7 @@ static void Generate_InterpreterEnterBytecode(MacroAssembler* masm) {
kScratchRegister)); kScratchRegister));
__ bind(&trampoline_loaded); __ bind(&trampoline_loaded);
__ addq(rbx, Immediate(interpreter_entry_return_pc_offset->value())); __ addq(rbx, Immediate(interpreter_entry_return_pc_offset.value()));
__ Push(rbx); __ Push(rbx);
// Initialize dispatch table register. // Initialize dispatch table register.

View File

@ -294,7 +294,7 @@ bool CodeStubAssembler::IsIntPtrOrSmiConstantZero(Node* test,
} }
} else { } else {
DCHECK_EQ(mode, SMI_PARAMETERS); DCHECK_EQ(mode, SMI_PARAMETERS);
if (ToSmiConstant(test, &smi_test) && smi_test->value() == 0) { if (ToSmiConstant(test, &smi_test) && smi_test.value() == 0) {
return true; return true;
} }
} }
@ -10007,7 +10007,7 @@ TNode<IntPtrT> CodeStubAssembler::ElementOffsetFromIndex(Node* index_node,
element_size_shift -= kSmiShiftBits; element_size_shift -= kSmiShiftBits;
Smi smi_index; Smi smi_index;
constant_index = ToSmiConstant(index_node, &smi_index); constant_index = ToSmiConstant(index_node, &smi_index);
if (constant_index) index = smi_index->value(); if (constant_index) index = smi_index.value();
index_node = BitcastTaggedToWord(index_node); index_node = BitcastTaggedToWord(index_node);
} else { } else {
DCHECK(mode == INTPTR_PARAMETERS); DCHECK(mode == INTPTR_PARAMETERS);

View File

@ -278,7 +278,7 @@ class V8_EXPORT_PRIVATE CodeStubAssembler
if (mode == ParameterMode::SMI_PARAMETERS) { if (mode == ParameterMode::SMI_PARAMETERS) {
Smi constant; Smi constant;
if (ToSmiConstant(node, &constant)) { if (ToSmiConstant(node, &constant)) {
*out = static_cast<intptr_t>(constant->value()); *out = static_cast<intptr_t>(constant.value());
return true; return true;
} }
} else { } else {

View File

@ -39,7 +39,7 @@ CompilationCache::CompilationCache(Isolate* isolate)
Handle<CompilationCacheTable> CompilationSubCache::GetTable(int generation) { Handle<CompilationCacheTable> CompilationSubCache::GetTable(int generation) {
DCHECK(generation < generations_); DCHECK(generation < generations_);
Handle<CompilationCacheTable> result; Handle<CompilationCacheTable> result;
if (tables_[generation]->IsUndefined(isolate())) { if (tables_[generation].IsUndefined(isolate())) {
result = CompilationCacheTable::New(isolate(), kInitialCacheSize); result = CompilationCacheTable::New(isolate(), kInitialCacheSize);
tables_[generation] = *result; tables_[generation] = *result;
} else { } else {
@ -53,8 +53,8 @@ Handle<CompilationCacheTable> CompilationSubCache::GetTable(int generation) {
void CompilationSubCache::Age() { void CompilationSubCache::Age() {
// Don't directly age single-generation caches. // Don't directly age single-generation caches.
if (generations_ == 1) { if (generations_ == 1) {
if (!tables_[0]->IsUndefined(isolate())) { if (!tables_[0].IsUndefined(isolate())) {
CompilationCacheTable::cast(tables_[0])->Age(); CompilationCacheTable::cast(tables_[0]).Age();
} }
return; return;
} }
@ -76,8 +76,7 @@ void CompilationSubCache::Iterate(RootVisitor* v) {
void CompilationSubCache::Clear() { void CompilationSubCache::Clear() {
MemsetPointer(reinterpret_cast<Address*>(tables_), MemsetPointer(reinterpret_cast<Address*>(tables_),
ReadOnlyRoots(isolate()).undefined_value()->ptr(), ReadOnlyRoots(isolate()).undefined_value().ptr(), generations_);
generations_);
} }
void CompilationSubCache::Remove(Handle<SharedFunctionInfo> function_info) { void CompilationSubCache::Remove(Handle<SharedFunctionInfo> function_info) {
@ -108,13 +107,13 @@ bool CompilationCacheScript::HasOrigin(Handle<SharedFunctionInfo> function_info,
// an undefined name to have the same origin. // an undefined name to have the same origin.
Handle<Object> name; Handle<Object> name;
if (!maybe_name.ToHandle(&name)) { if (!maybe_name.ToHandle(&name)) {
return script->name()->IsUndefined(isolate()); return script->name().IsUndefined(isolate());
} }
// Do the fast bailout checks first. // Do the fast bailout checks first.
if (line_offset != script->line_offset()) return false; if (line_offset != script->line_offset()) return false;
if (column_offset != script->column_offset()) return false; if (column_offset != script->column_offset()) return false;
// Check that both names are strings. If not, no match. // Check that both names are strings. If not, no match.
if (!name->IsString() || !script->name()->IsString()) return false; if (!name->IsString() || !script->name().IsString()) return false;
// Are the origin_options same? // Are the origin_options same?
if (resource_options.Flags() != script->origin_options().Flags()) if (resource_options.Flags() != script->origin_options().Flags())
return false; return false;

View File

@ -94,7 +94,7 @@ void LogFunctionCompilation(CodeEventListener::LogEventsAndTags tag,
int line_num = Script::GetLineNumber(script, shared->StartPosition()) + 1; int line_num = Script::GetLineNumber(script, shared->StartPosition()) + 1;
int column_num = Script::GetColumnNumber(script, shared->StartPosition()) + 1; int column_num = Script::GetColumnNumber(script, shared->StartPosition()) + 1;
String script_name = script->name()->IsString() String script_name = script->name().IsString()
? String::cast(script->name()) ? String::cast(script->name())
: ReadOnlyRoots(isolate).empty_string(); : ReadOnlyRoots(isolate).empty_string();
CodeEventListener::LogEventsAndTags log_tag = CodeEventListener::LogEventsAndTags log_tag =
@ -127,9 +127,9 @@ void LogFunctionCompilation(CodeEventListener::LogEventsAndTags tag,
} }
ScriptOriginOptions OriginOptionsForEval(Object script) { ScriptOriginOptions OriginOptionsForEval(Object script) {
if (!script->IsScript()) return ScriptOriginOptions(); if (!script.IsScript()) return ScriptOriginOptions();
const auto outer_origin_options = Script::cast(script)->origin_options(); const auto outer_origin_options = Script::cast(script).origin_options();
return ScriptOriginOptions(outer_origin_options.IsSharedCrossOrigin(), return ScriptOriginOptions(outer_origin_options.IsSharedCrossOrigin(),
outer_origin_options.IsOpaque()); outer_origin_options.IsOpaque());
} }
@ -270,7 +270,7 @@ void OptimizedCompilationJob::RecordCompilationStats(CompilationMode mode,
compilation_time += (ms_creategraph + ms_optimize + ms_codegen); compilation_time += (ms_creategraph + ms_optimize + ms_codegen);
compiled_functions++; compiled_functions++;
code_size += function->shared()->SourceSize(); code_size += function->shared().SourceSize();
PrintF("Compiled: %d functions with %d byte source size in %fms.\n", PrintF("Compiled: %d functions with %d byte source size in %fms.\n",
compiled_functions, code_size, compilation_time); compiled_functions, code_size, compilation_time);
} }
@ -383,7 +383,7 @@ void InstallBytecodeArray(Handle<BytecodeArray> bytecode_array,
Script::GetLineNumber(script, shared_info->StartPosition()) + 1; Script::GetLineNumber(script, shared_info->StartPosition()) + 1;
int column_num = int column_num =
Script::GetColumnNumber(script, shared_info->StartPosition()) + 1; Script::GetColumnNumber(script, shared_info->StartPosition()) + 1;
String script_name = script->name()->IsString() String script_name = script->name().IsString()
? String::cast(script->name()) ? String::cast(script->name())
: ReadOnlyRoots(isolate).empty_string(); : ReadOnlyRoots(isolate).empty_string();
CodeEventListener::LogEventsAndTags log_tag = Logger::ToNativeByScript( CodeEventListener::LogEventsAndTags log_tag = Logger::ToNativeByScript(
@ -433,8 +433,8 @@ void EnsureSharedFunctionInfosArrayOnScript(ParseInfo* parse_info,
Isolate* isolate) { Isolate* isolate) {
DCHECK(parse_info->is_toplevel()); DCHECK(parse_info->is_toplevel());
DCHECK(!parse_info->script().is_null()); DCHECK(!parse_info->script().is_null());
if (parse_info->script()->shared_function_infos()->length() > 0) { if (parse_info->script()->shared_function_infos().length() > 0) {
DCHECK_EQ(parse_info->script()->shared_function_infos()->length(), DCHECK_EQ(parse_info->script()->shared_function_infos().length(),
parse_info->max_function_literal_id() + 1); parse_info->max_function_literal_id() + 1);
return; return;
} }
@ -659,15 +659,15 @@ V8_WARN_UNUSED_RESULT MaybeHandle<Code> GetCodeFromOptimizedCodeCache(
if (osr_offset.IsNone()) { if (osr_offset.IsNone()) {
if (function->has_feedback_vector()) { if (function->has_feedback_vector()) {
FeedbackVector feedback_vector = function->feedback_vector(); FeedbackVector feedback_vector = function->feedback_vector();
feedback_vector->EvictOptimizedCodeMarkedForDeoptimization( feedback_vector.EvictOptimizedCodeMarkedForDeoptimization(
function->shared(), "GetCodeFromOptimizedCodeCache"); function->shared(), "GetCodeFromOptimizedCodeCache");
Code code = feedback_vector->optimized_code(); Code code = feedback_vector.optimized_code();
if (!code.is_null()) { if (!code.is_null()) {
// Caching of optimized code enabled and optimized code found. // Caching of optimized code enabled and optimized code found.
DCHECK(!code->marked_for_deoptimization()); DCHECK(!code.marked_for_deoptimization());
DCHECK(function->shared()->is_compiled()); DCHECK(function->shared().is_compiled());
return Handle<Code>(code, feedback_vector->GetIsolate()); return Handle<Code>(code, feedback_vector.GetIsolate());
} }
} }
} }
@ -700,7 +700,7 @@ void InsertCodeIntoOptimizedCodeCache(
// Cache optimized context-specific code. // Cache optimized context-specific code.
Handle<JSFunction> function = compilation_info->closure(); Handle<JSFunction> function = compilation_info->closure();
Handle<SharedFunctionInfo> shared(function->shared(), function->GetIsolate()); Handle<SharedFunctionInfo> shared(function->shared(), function->GetIsolate());
Handle<Context> native_context(function->context()->native_context(), Handle<Context> native_context(function->context().native_context(),
function->GetIsolate()); function->GetIsolate());
if (compilation_info->osr_offset().IsNone()) { if (compilation_info->osr_offset().IsNone()) {
Handle<FeedbackVector> vector = Handle<FeedbackVector> vector =
@ -800,7 +800,7 @@ MaybeHandle<Code> GetOptimizedCode(Handle<JSFunction> function,
// If code was pending optimization for testing, delete remove the strong root // If code was pending optimization for testing, delete remove the strong root
// that was preventing the bytecode from being flushed between marking and // that was preventing the bytecode from being flushed between marking and
// optimization. // optimization.
if (!isolate->heap()->pending_optimize_for_test_bytecode()->IsUndefined()) { if (!isolate->heap()->pending_optimize_for_test_bytecode().IsUndefined()) {
Handle<ObjectHashTable> table = Handle<ObjectHashTable> table =
handle(ObjectHashTable::cast( handle(ObjectHashTable::cast(
isolate->heap()->pending_optimize_for_test_bytecode()), isolate->heap()->pending_optimize_for_test_bytecode()),
@ -827,7 +827,7 @@ MaybeHandle<Code> GetOptimizedCode(Handle<JSFunction> function,
// Reset profiler ticks, function is no longer considered hot. // Reset profiler ticks, function is no longer considered hot.
DCHECK(shared->is_compiled()); DCHECK(shared->is_compiled());
function->feedback_vector()->set_profiler_ticks(0); function->feedback_vector().set_profiler_ticks(0);
VMState<COMPILER> state(isolate); VMState<COMPILER> state(isolate);
TimerEventScope<TimerEventOptimizeCode> optimize_code_timer(isolate); TimerEventScope<TimerEventOptimizeCode> optimize_code_timer(isolate);
@ -837,7 +837,7 @@ MaybeHandle<Code> GetOptimizedCode(Handle<JSFunction> function,
DCHECK(!isolate->has_pending_exception()); DCHECK(!isolate->has_pending_exception());
PostponeInterruptsScope postpone(isolate); PostponeInterruptsScope postpone(isolate);
bool has_script = shared->script()->IsScript(); bool has_script = shared->script().IsScript();
// BUG(5946): This DCHECK is necessary to make certain that we won't // BUG(5946): This DCHECK is necessary to make certain that we won't
// tolerate the lack of a script without bytecode. // tolerate the lack of a script without bytecode.
DCHECK_IMPLIES(!has_script, shared->HasBytecodeArray()); DCHECK_IMPLIES(!has_script, shared->HasBytecodeArray());
@ -881,8 +881,8 @@ MaybeHandle<Code> GetOptimizedCode(Handle<JSFunction> function,
// Set the optimization marker and return a code object which checks it. // Set the optimization marker and return a code object which checks it.
function->SetOptimizationMarker(OptimizationMarker::kInOptimizationQueue); function->SetOptimizationMarker(OptimizationMarker::kInOptimizationQueue);
DCHECK(function->IsInterpreted() || DCHECK(function->IsInterpreted() ||
(!function->is_compiled() && function->shared()->IsInterpreted())); (!function->is_compiled() && function->shared().IsInterpreted()));
DCHECK(function->shared()->HasBytecodeArray()); DCHECK(function->shared().HasBytecodeArray());
return BUILTIN_CODE(isolate, InterpreterEntryTrampoline); return BUILTIN_CODE(isolate, InterpreterEntryTrampoline);
} }
} else { } else {
@ -1178,7 +1178,7 @@ bool Compiler::CollectSourcePositions(Isolate* isolate,
Handle<SharedFunctionInfo> shared_info) { Handle<SharedFunctionInfo> shared_info) {
DCHECK(shared_info->is_compiled()); DCHECK(shared_info->is_compiled());
DCHECK(shared_info->HasBytecodeArray()); DCHECK(shared_info->HasBytecodeArray());
DCHECK(!shared_info->GetBytecodeArray()->HasSourcePositionTable()); DCHECK(!shared_info->GetBytecodeArray().HasSourcePositionTable());
// Collecting source positions requires allocating a new source position // Collecting source positions requires allocating a new source position
// table. // table.
@ -1266,8 +1266,8 @@ bool Compiler::CollectSourcePositions(Isolate* isolate,
// If debugging, make sure that instrumented bytecode has the source position // If debugging, make sure that instrumented bytecode has the source position
// table set on it as well. // table set on it as well.
if (shared_info->HasDebugInfo() && if (shared_info->HasDebugInfo() &&
shared_info->GetDebugInfo()->HasInstrumentedBytecodeArray()) { shared_info->GetDebugInfo().HasInstrumentedBytecodeArray()) {
shared_info->GetDebugBytecodeArray()->set_source_position_table( shared_info->GetDebugBytecodeArray().set_source_position_table(
source_position_table); source_position_table);
} }
@ -1315,7 +1315,7 @@ bool Compiler::Compile(Handle<SharedFunctionInfo> shared_info,
parse_info.set_consumed_preparse_data(ConsumedPreparseData::For( parse_info.set_consumed_preparse_data(ConsumedPreparseData::For(
isolate, isolate,
handle( handle(
shared_info->uncompiled_data_with_preparse_data()->preparse_data(), shared_info->uncompiled_data_with_preparse_data().preparse_data(),
isolate))); isolate)));
} }
@ -1377,7 +1377,7 @@ bool Compiler::Compile(Handle<JSFunction> function, ClearExceptionFlag flag,
JSFunction::InitializeFeedbackCell(function); JSFunction::InitializeFeedbackCell(function);
// Optimize now if --always-opt is enabled. // Optimize now if --always-opt is enabled.
if (FLAG_always_opt && !function->shared()->HasAsmWasmData()) { if (FLAG_always_opt && !function->shared().HasAsmWasmData()) {
if (FLAG_trace_opt) { if (FLAG_trace_opt) {
PrintF("[optimizing "); PrintF("[optimizing ");
function->ShortPrint(); function->ShortPrint();
@ -1395,7 +1395,7 @@ bool Compiler::Compile(Handle<JSFunction> function, ClearExceptionFlag flag,
// Check postconditions on success. // Check postconditions on success.
DCHECK(!isolate->has_pending_exception()); DCHECK(!isolate->has_pending_exception());
DCHECK(function->shared()->is_compiled()); DCHECK(function->shared().is_compiled());
DCHECK(function->is_compiled()); DCHECK(function->is_compiled());
return true; return true;
} }
@ -1449,8 +1449,8 @@ bool Compiler::CompileOptimized(Handle<JSFunction> function,
// Optimization failed, get unoptimized code. Unoptimized code must exist // Optimization failed, get unoptimized code. Unoptimized code must exist
// already if we are optimizing. // already if we are optimizing.
DCHECK(!isolate->has_pending_exception()); DCHECK(!isolate->has_pending_exception());
DCHECK(function->shared()->is_compiled()); DCHECK(function->shared().is_compiled());
DCHECK(function->shared()->IsInterpreted()); DCHECK(function->shared().IsInterpreted());
code = BUILTIN_CODE(isolate, InterpreterEntryTrampoline); code = BUILTIN_CODE(isolate, InterpreterEntryTrampoline);
} }
@ -1459,7 +1459,7 @@ bool Compiler::CompileOptimized(Handle<JSFunction> function,
// Check postconditions on success. // Check postconditions on success.
DCHECK(!isolate->has_pending_exception()); DCHECK(!isolate->has_pending_exception());
DCHECK(function->shared()->is_compiled()); DCHECK(function->shared().is_compiled());
DCHECK(function->is_compiled()); DCHECK(function->is_compiled());
DCHECK_IMPLIES(function->HasOptimizationMarker(), DCHECK_IMPLIES(function->HasOptimizationMarker(),
function->IsInOptimizationQueue()); function->IsInOptimizationQueue());
@ -1602,7 +1602,7 @@ MaybeHandle<JSFunction> Compiler::GetFunctionFromEval(
bool Compiler::CodeGenerationFromStringsAllowed(Isolate* isolate, bool Compiler::CodeGenerationFromStringsAllowed(Isolate* isolate,
Handle<Context> context, Handle<Context> context,
Handle<String> source) { Handle<String> source) {
DCHECK(context->allow_code_gen_from_strings()->IsFalse(isolate)); DCHECK(context->allow_code_gen_from_strings().IsFalse(isolate));
// Check with callback if set. // Check with callback if set.
AllowCodeGenerationFromStringsCallback callback = AllowCodeGenerationFromStringsCallback callback =
isolate->allow_code_gen_callback(); isolate->allow_code_gen_callback();
@ -1624,7 +1624,7 @@ MaybeHandle<JSFunction> Compiler::GetFunctionFromString(
// Check if native context allows code generation from // Check if native context allows code generation from
// strings. Throw an exception if it doesn't. // strings. Throw an exception if it doesn't.
if (native_context->allow_code_gen_from_strings()->IsFalse(isolate) && if (native_context->allow_code_gen_from_strings().IsFalse(isolate) &&
!CodeGenerationFromStringsAllowed(isolate, native_context, source)) { !CodeGenerationFromStringsAllowed(isolate, native_context, source)) {
Handle<Object> error_message = Handle<Object> error_message =
native_context->ErrorMessageForCodeGenerationFromStrings(); native_context->ErrorMessageForCodeGenerationFromStrings();
@ -1638,7 +1638,7 @@ MaybeHandle<JSFunction> Compiler::GetFunctionFromString(
int eval_scope_position = 0; int eval_scope_position = 0;
int eval_position = kNoSourcePosition; int eval_position = kNoSourcePosition;
Handle<SharedFunctionInfo> outer_info( Handle<SharedFunctionInfo> outer_info(
native_context->empty_function()->shared(), isolate); native_context->empty_function().shared(), isolate);
return Compiler::GetFunctionFromEval( return Compiler::GetFunctionFromEval(
source, outer_info, native_context, LanguageMode::kSloppy, restriction, source, outer_info, native_context, LanguageMode::kSloppy, restriction,
parameters_end_pos, eval_scope_position, eval_position); parameters_end_pos, eval_scope_position, eval_position);
@ -2037,7 +2037,7 @@ MaybeHandle<JSFunction> Compiler::GetWrappedFunction(
SharedFunctionInfo::ScriptIterator infos(isolate, *script); SharedFunctionInfo::ScriptIterator infos(isolate, *script);
for (SharedFunctionInfo info = infos.Next(); !info.is_null(); for (SharedFunctionInfo info = infos.Next(); !info.is_null();
info = infos.Next()) { info = infos.Next()) {
if (info->is_wrapped()) { if (info.is_wrapped()) {
wrapped = Handle<SharedFunctionInfo>(info, isolate); wrapped = Handle<SharedFunctionInfo>(info, isolate);
break; break;
} }
@ -2162,7 +2162,7 @@ bool Compiler::FinalizeOptimizedCompilationJob(OptimizedCompilationJob* job,
Handle<SharedFunctionInfo> shared = compilation_info->shared_info(); Handle<SharedFunctionInfo> shared = compilation_info->shared_info();
// Reset profiler ticks, function is no longer considered hot. // Reset profiler ticks, function is no longer considered hot.
compilation_info->closure()->feedback_vector()->set_profiler_ticks(0); compilation_info->closure()->feedback_vector().set_profiler_ticks(0);
DCHECK(!shared->HasBreakInfo()); DCHECK(!shared->HasBreakInfo());
@ -2217,12 +2217,12 @@ void Compiler::PostInstantiation(Handle<JSFunction> function,
JSFunction::InitializeFeedbackCell(function); JSFunction::InitializeFeedbackCell(function);
Code code = function->has_feedback_vector() Code code = function->has_feedback_vector()
? function->feedback_vector()->optimized_code() ? function->feedback_vector().optimized_code()
: Code(); : Code();
if (!code.is_null()) { if (!code.is_null()) {
// Caching of optimized code enabled and optimized code found. // Caching of optimized code enabled and optimized code found.
DCHECK(!code->marked_for_deoptimization()); DCHECK(!code.marked_for_deoptimization());
DCHECK(function->shared()->is_compiled()); DCHECK(function->shared().is_compiled());
function->set_code(code); function->set_code(code);
} }

View File

@ -14,21 +14,21 @@ namespace v8 {
namespace internal { namespace internal {
HandlerTable::HandlerTable(Code code) HandlerTable::HandlerTable(Code code)
: HandlerTable(code->InstructionStart() + code->handler_table_offset(), : HandlerTable(code.InstructionStart() + code.handler_table_offset(),
code->handler_table_size()) {} code.handler_table_size()) {}
HandlerTable::HandlerTable(BytecodeArray bytecode_array) HandlerTable::HandlerTable(BytecodeArray bytecode_array)
: HandlerTable(bytecode_array->handler_table()) {} : HandlerTable(bytecode_array.handler_table()) {}
HandlerTable::HandlerTable(ByteArray byte_array) HandlerTable::HandlerTable(ByteArray byte_array)
: number_of_entries_(byte_array->length() / kRangeEntrySize / : number_of_entries_(byte_array.length() / kRangeEntrySize /
sizeof(int32_t)), sizeof(int32_t)),
#ifdef DEBUG #ifdef DEBUG
mode_(kRangeBasedEncoding), mode_(kRangeBasedEncoding),
#endif #endif
raw_encoded_data_( raw_encoded_data_(
reinterpret_cast<Address>(byte_array->GetDataStartAddress())) { reinterpret_cast<Address>(byte_array.GetDataStartAddress())) {
DCHECK_EQ(0, byte_array->length() % (kRangeEntrySize * sizeof(int32_t))); DCHECK_EQ(0, byte_array.length() % (kRangeEntrySize * sizeof(int32_t)));
} }
HandlerTable::HandlerTable(Address handler_table, int handler_table_size) HandlerTable::HandlerTable(Address handler_table, int handler_table_size)

View File

@ -151,7 +151,7 @@ void OptimizedCompilationInfo::RetryOptimization(BailoutReason reason) {
std::unique_ptr<char[]> OptimizedCompilationInfo::GetDebugName() const { std::unique_ptr<char[]> OptimizedCompilationInfo::GetDebugName() const {
if (!shared_info().is_null()) { if (!shared_info().is_null()) {
return shared_info()->DebugName()->ToCString(); return shared_info()->DebugName().ToCString();
} }
Vector<const char> name_vec = debug_name_; Vector<const char> name_vec = debug_name_;
if (name_vec.empty()) name_vec = ArrayVector("unknown"); if (name_vec.empty()) name_vec = ArrayVector("unknown");
@ -216,7 +216,7 @@ bool OptimizedCompilationInfo::has_global_object() const {
JSGlobalObject OptimizedCompilationInfo::global_object() const { JSGlobalObject OptimizedCompilationInfo::global_object() const {
DCHECK(has_global_object()); DCHECK(has_global_object());
return native_context()->global_object(); return native_context().global_object();
} }
int OptimizedCompilationInfo::AddInlinedFunction( int OptimizedCompilationInfo::AddInlinedFunction(

View File

@ -272,13 +272,13 @@ void RelocIterator::next() {
} }
RelocIterator::RelocIterator(Code code, int mode_mask) RelocIterator::RelocIterator(Code code, int mode_mask)
: RelocIterator(code, code->unchecked_relocation_info(), mode_mask) {} : RelocIterator(code, code.unchecked_relocation_info(), mode_mask) {}
RelocIterator::RelocIterator(Code code, ByteArray relocation_info, RelocIterator::RelocIterator(Code code, ByteArray relocation_info,
int mode_mask) int mode_mask)
: RelocIterator(code, code->raw_instruction_start(), code->constant_pool(), : RelocIterator(code, code.raw_instruction_start(), code.constant_pool(),
relocation_info->GetDataEndAddress(), relocation_info.GetDataEndAddress(),
relocation_info->GetDataStartAddress(), mode_mask) {} relocation_info.GetDataStartAddress(), mode_mask) {}
RelocIterator::RelocIterator(const CodeReference code_reference, int mode_mask) RelocIterator::RelocIterator(const CodeReference code_reference, int mode_mask)
: RelocIterator(Code(), code_reference.instruction_start(), : RelocIterator(Code(), code_reference.instruction_start(),
@ -289,10 +289,10 @@ RelocIterator::RelocIterator(const CodeReference code_reference, int mode_mask)
RelocIterator::RelocIterator(EmbeddedData* embedded_data, Code code, RelocIterator::RelocIterator(EmbeddedData* embedded_data, Code code,
int mode_mask) int mode_mask)
: RelocIterator( : RelocIterator(
code, embedded_data->InstructionStartOfBuiltin(code->builtin_index()), code, embedded_data->InstructionStartOfBuiltin(code.builtin_index()),
code->constant_pool(), code.constant_pool(),
code->relocation_start() + code->relocation_size(), code.relocation_start() + code.relocation_size(),
code->relocation_start(), mode_mask) {} code.relocation_start(), mode_mask) {}
RelocIterator::RelocIterator(const CodeDesc& desc, int mode_mask) RelocIterator::RelocIterator(const CodeDesc& desc, int mode_mask)
: RelocIterator(Code(), reinterpret_cast<Address>(desc.buffer), 0, : RelocIterator(Code(), reinterpret_cast<Address>(desc.buffer), 0,
@ -469,10 +469,10 @@ void RelocInfo::Print(Isolate* isolate, std::ostream& os) { // NOLINT
} else if (IsCodeTargetMode(rmode_)) { } else if (IsCodeTargetMode(rmode_)) {
const Address code_target = target_address(); const Address code_target = target_address();
Code code = Code::GetCodeFromTargetAddress(code_target); Code code = Code::GetCodeFromTargetAddress(code_target);
DCHECK(code->IsCode()); DCHECK(code.IsCode());
os << " (" << Code::Kind2String(code->kind()); os << " (" << Code::Kind2String(code.kind());
if (Builtins::IsBuiltin(code)) { if (Builtins::IsBuiltin(code)) {
os << " " << Builtins::name(code->builtin_index()); os << " " << Builtins::name(code.builtin_index());
} }
os << ") (" << reinterpret_cast<const void*>(target_address()) << ")"; os << ") (" << reinterpret_cast<const void*>(target_address()) << ")";
} else if (IsRuntimeEntry(rmode_) && isolate->deoptimizer_data() != nullptr) { } else if (IsRuntimeEntry(rmode_) && isolate->deoptimizer_data() != nullptr) {
@ -505,8 +505,8 @@ void RelocInfo::Verify(Isolate* isolate) {
// Check that we can find the right code object. // Check that we can find the right code object.
Code code = Code::GetCodeFromTargetAddress(addr); Code code = Code::GetCodeFromTargetAddress(addr);
Object found = isolate->FindCodeObject(addr); Object found = isolate->FindCodeObject(addr);
CHECK(found->IsCode()); CHECK(found.IsCode());
CHECK(code->address() == HeapObject::cast(found)->address()); CHECK(code.address() == HeapObject::cast(found).address());
break; break;
} }
case INTERNAL_REFERENCE: case INTERNAL_REFERENCE:
@ -514,8 +514,8 @@ void RelocInfo::Verify(Isolate* isolate) {
Address target = target_internal_reference(); Address target = target_internal_reference();
Address pc = target_internal_reference_address(); Address pc = target_internal_reference_address();
Code code = Code::cast(isolate->FindCodeObject(pc)); Code code = Code::cast(isolate->FindCodeObject(pc));
CHECK(target >= code->InstructionStart()); CHECK(target >= code.InstructionStart());
CHECK(target <= code->InstructionEnd()); CHECK(target <= code.InstructionEnd());
break; break;
} }
case OFF_HEAP_TARGET: { case OFF_HEAP_TARGET: {

View File

@ -49,8 +49,8 @@ SafepointTable::SafepointTable(Address instruction_start,
} }
SafepointTable::SafepointTable(Code code) SafepointTable::SafepointTable(Code code)
: SafepointTable(code->InstructionStart(), code->safepoint_table_offset(), : SafepointTable(code.InstructionStart(), code.safepoint_table_offset(),
code->stack_slots(), true) {} code.stack_slots(), true) {}
unsigned SafepointTable::find_return_pc(unsigned pc_offset) { unsigned SafepointTable::find_return_pc(unsigned pc_offset) {
for (unsigned i = 0; i < length(); i++) { for (unsigned i = 0; i < length(); i++) {

View File

@ -108,8 +108,8 @@ void DecodeEntry(Vector<const byte> bytes, int* index,
} }
Vector<const byte> VectorFromByteArray(ByteArray byte_array) { Vector<const byte> VectorFromByteArray(ByteArray byte_array) {
return Vector<const byte>(byte_array->GetDataStartAddress(), return Vector<const byte>(byte_array.GetDataStartAddress(),
byte_array->length()); byte_array.length());
} }
#ifdef ENABLE_SLOW_DCHECKS #ifdef ENABLE_SLOW_DCHECKS

View File

@ -11,8 +11,8 @@ namespace internal {
std::ostream& operator<<(std::ostream& out, const SourcePositionInfo& pos) { std::ostream& operator<<(std::ostream& out, const SourcePositionInfo& pos) {
out << "<"; out << "<";
if (!pos.script.is_null() && pos.script->name()->IsString()) { if (!pos.script.is_null() && pos.script->name().IsString()) {
out << String::cast(pos.script->name())->ToCString(DISALLOW_NULLS).get(); out << String::cast(pos.script->name()).ToCString(DISALLOW_NULLS).get();
} else { } else {
out << "unknown"; out << "unknown";
} }
@ -68,7 +68,7 @@ std::vector<SourcePositionInfo> SourcePosition::InliningStack(
std::vector<SourcePositionInfo> stack; std::vector<SourcePositionInfo> stack;
while (pos.isInlined()) { while (pos.isInlined()) {
InliningPosition inl = InliningPosition inl =
deopt_data->InliningPositions()->get(pos.InliningId()); deopt_data->InliningPositions().get(pos.InliningId());
Handle<SharedFunctionInfo> function( Handle<SharedFunctionInfo> function(
deopt_data->GetInlinedFunction(inl.inlined_function_id), isolate); deopt_data->GetInlinedFunction(inl.inlined_function_id), isolate);
stack.push_back(SourcePositionInfo(pos, function)); stack.push_back(SourcePositionInfo(pos, function));
@ -84,15 +84,15 @@ void SourcePosition::Print(std::ostream& out,
SharedFunctionInfo function) const { SharedFunctionInfo function) const {
Script::PositionInfo pos; Script::PositionInfo pos;
Object source_name; Object source_name;
if (function->script()->IsScript()) { if (function.script().IsScript()) {
Script script = Script::cast(function->script()); Script script = Script::cast(function.script());
source_name = script->name(); source_name = script.name();
script->GetPositionInfo(ScriptOffset(), &pos, Script::WITH_OFFSET); script.GetPositionInfo(ScriptOffset(), &pos, Script::WITH_OFFSET);
} }
out << "<"; out << "<";
if (source_name->IsString()) { if (source_name.IsString()) {
out << String::cast(source_name) out << String::cast(source_name)
->ToCString(DISALLOW_NULLS, ROBUST_STRING_TRAVERSAL) .ToCString(DISALLOW_NULLS, ROBUST_STRING_TRAVERSAL)
.get(); .get();
} else { } else {
out << "unknown"; out << "unknown";
@ -113,18 +113,18 @@ void SourcePosition::PrintJson(std::ostream& out) const {
void SourcePosition::Print(std::ostream& out, Code code) const { void SourcePosition::Print(std::ostream& out, Code code) const {
DeoptimizationData deopt_data = DeoptimizationData deopt_data =
DeoptimizationData::cast(code->deoptimization_data()); DeoptimizationData::cast(code.deoptimization_data());
if (!isInlined()) { if (!isInlined()) {
SharedFunctionInfo function( SharedFunctionInfo function(
SharedFunctionInfo::cast(deopt_data->SharedFunctionInfo())); SharedFunctionInfo::cast(deopt_data.SharedFunctionInfo()));
Print(out, function); Print(out, function);
} else { } else {
InliningPosition inl = deopt_data->InliningPositions()->get(InliningId()); InliningPosition inl = deopt_data.InliningPositions().get(InliningId());
if (inl.inlined_function_id == -1) { if (inl.inlined_function_id == -1) {
out << *this; out << *this;
} else { } else {
SharedFunctionInfo function = SharedFunctionInfo function =
deopt_data->GetInlinedFunction(inl.inlined_function_id); deopt_data.GetInlinedFunction(inl.inlined_function_id);
Print(out, function); Print(out, function);
} }
out << " inlined at "; out << " inlined at ";
@ -136,7 +136,7 @@ SourcePositionInfo::SourcePositionInfo(SourcePosition pos,
Handle<SharedFunctionInfo> f) Handle<SharedFunctionInfo> f)
: position(pos), : position(pos),
shared(f), shared(f),
script(f.is_null() || !f->script()->IsScript() script(f.is_null() || !f->script().IsScript()
? Handle<Script>::null() ? Handle<Script>::null()
: handle(Script::cast(f->script()), f->GetIsolate())) { : handle(Script::cast(f->script()), f->GetIsolate())) {
if (!script.is_null()) { if (!script.is_null()) {

View File

@ -104,7 +104,7 @@ void CompilerDispatcher::RegisterSharedFunctionInfo(
if (trace_compiler_dispatcher_) { if (trace_compiler_dispatcher_) {
PrintF("CompilerDispatcher: registering "); PrintF("CompilerDispatcher: registering ");
function->ShortPrint(); function.ShortPrint();
PrintF(" with job id %zu\n", job_id); PrintF(" with job id %zu\n", job_id);
} }

View File

@ -25,7 +25,7 @@ void DisposeCompilationJob(OptimizedCompilationJob* job,
bool restore_function_code) { bool restore_function_code) {
if (restore_function_code) { if (restore_function_code) {
Handle<JSFunction> function = job->compilation_info()->closure(); Handle<JSFunction> function = job->compilation_info()->closure();
function->set_code(function->shared()->GetCode()); function->set_code(function->shared().GetCode());
if (function->IsInOptimizationQueue()) { if (function->IsInOptimizationQueue()) {
function->ClearOptimizationMarker(); function->ClearOptimizationMarker();
} }

View File

@ -407,10 +407,10 @@ PropertyAccessInfo AccessInfoFactory::ComputeAccessorDescriptorAccessInfo(
Handle<JSModuleNamespace> module_namespace( Handle<JSModuleNamespace> module_namespace(
JSModuleNamespace::cast(proto_info->module_namespace()), isolate()); JSModuleNamespace::cast(proto_info->module_namespace()), isolate());
Handle<Cell> cell( Handle<Cell> cell(
Cell::cast(module_namespace->module()->exports()->Lookup( Cell::cast(module_namespace->module().exports().Lookup(
ReadOnlyRoots(isolate()), name, Smi::ToInt(name->GetHash()))), ReadOnlyRoots(isolate()), name, Smi::ToInt(name->GetHash()))),
isolate()); isolate());
if (cell->value()->IsTheHole(isolate())) { if (cell->value().IsTheHole(isolate())) {
// This module has not been fully initialized yet. // This module has not been fully initialized yet.
return PropertyAccessInfo::Invalid(zone()); return PropertyAccessInfo::Invalid(zone());
} }
@ -542,15 +542,15 @@ PropertyAccessInfo AccessInfoFactory::ComputePropertyAccessInfo(
} }
// Walk up the prototype chain. // Walk up the prototype chain.
if (!map->prototype()->IsJSObject()) { if (!map->prototype().IsJSObject()) {
// Perform the implicit ToObject for primitives here. // Perform the implicit ToObject for primitives here.
// Implemented according to ES6 section 7.3.2 GetV (V, P). // Implemented according to ES6 section 7.3.2 GetV (V, P).
Handle<JSFunction> constructor; Handle<JSFunction> constructor;
if (Map::GetConstructorFunction(map, broker()->native_context().object()) if (Map::GetConstructorFunction(map, broker()->native_context().object())
.ToHandle(&constructor)) { .ToHandle(&constructor)) {
map = handle(constructor->initial_map(), isolate()); map = handle(constructor->initial_map(), isolate());
DCHECK(map->prototype()->IsJSObject()); DCHECK(map->prototype().IsJSObject());
} else if (map->prototype()->IsNull(isolate())) { } else if (map->prototype().IsNull(isolate())) {
// Store to property not found on the receiver or any prototype, we need // Store to property not found on the receiver or any prototype, we need
// to transition to a new data property. // to transition to a new data property.
// Implemented according to ES6 section 9.1.9 [[Set]] (P, V, Receiver) // Implemented according to ES6 section 9.1.9 [[Set]] (P, V, Receiver)
@ -566,7 +566,7 @@ PropertyAccessInfo AccessInfoFactory::ComputePropertyAccessInfo(
} }
} }
Handle<JSObject> map_prototype(JSObject::cast(map->prototype()), isolate()); Handle<JSObject> map_prototype(JSObject::cast(map->prototype()), isolate());
if (map_prototype->map()->is_deprecated()) { if (map_prototype->map().is_deprecated()) {
// Try to migrate the prototype object so we don't embed the deprecated // Try to migrate the prototype object so we don't embed the deprecated
// map into the optimized code. // map into the optimized code.
JSObject::TryMigrateInstance(map_prototype); JSObject::TryMigrateInstance(map_prototype);
@ -744,7 +744,7 @@ PropertyAccessInfo AccessInfoFactory::LookupTransition(
Handle<Map> transition_map(transition, isolate()); Handle<Map> transition_map(transition, isolate());
int const number = transition_map->LastAdded(); int const number = transition_map->LastAdded();
PropertyDetails const details = PropertyDetails const details =
transition_map->instance_descriptors()->GetDetails(number); transition_map->instance_descriptors().GetDetails(number);
// Don't bother optimizing stores to read-only properties. // Don't bother optimizing stores to read-only properties.
if (details.IsReadOnly()) { if (details.IsReadOnly()) {
return PropertyAccessInfo::Invalid(zone()); return PropertyAccessInfo::Invalid(zone());
@ -774,8 +774,7 @@ PropertyAccessInfo AccessInfoFactory::LookupTransition(
// Extract the field type from the property details (make sure its // Extract the field type from the property details (make sure its
// representation is TaggedPointer to reflect the heap object case). // representation is TaggedPointer to reflect the heap object case).
Handle<FieldType> descriptors_field_type( Handle<FieldType> descriptors_field_type(
transition_map->instance_descriptors()->GetFieldType(number), transition_map->instance_descriptors().GetFieldType(number), isolate());
isolate());
if (descriptors_field_type->IsNone()) { if (descriptors_field_type->IsNone()) {
// Store is not safe if the field type was cleared. // Store is not safe if the field type was cleared.
return PropertyAccessInfo::Invalid(zone()); return PropertyAccessInfo::Invalid(zone());

View File

@ -1161,8 +1161,8 @@ void CodeGenerator::AddTranslationForOperand(Translation* translation,
// Smis. // Smis.
DCHECK_EQ(4, kSystemPointerSize); DCHECK_EQ(4, kSystemPointerSize);
Smi smi(static_cast<Address>(constant.ToInt32())); Smi smi(static_cast<Address>(constant.ToInt32()));
DCHECK(smi->IsSmi()); DCHECK(smi.IsSmi());
literal = DeoptimizationLiteral(smi->value()); literal = DeoptimizationLiteral(smi.value());
} else if (type.representation() == MachineRepresentation::kBit) { } else if (type.representation() == MachineRepresentation::kBit) {
if (constant.ToInt32() == 0) { if (constant.ToInt32() == 0) {
literal = literal =
@ -1196,8 +1196,8 @@ void CodeGenerator::AddTranslationForOperand(Translation* translation,
// Smis. // Smis.
DCHECK_EQ(MachineRepresentation::kTagged, type.representation()); DCHECK_EQ(MachineRepresentation::kTagged, type.representation());
Smi smi(static_cast<Address>(constant.ToInt64())); Smi smi(static_cast<Address>(constant.ToInt64()));
DCHECK(smi->IsSmi()); DCHECK(smi.IsSmi());
literal = DeoptimizationLiteral(smi->value()); literal = DeoptimizationLiteral(smi.value());
} }
break; break;
case Constant::kFloat32: case Constant::kFloat32:

View File

@ -2028,7 +2028,7 @@ void BytecodeGraphBuilder::VisitCreateArrayLiteral() {
// TODO(mstarzinger): Thread through number of elements. The below number is // TODO(mstarzinger): Thread through number of elements. The below number is
// only an estimate and does not match {ArrayLiteral::values::length}. // only an estimate and does not match {ArrayLiteral::values::length}.
int number_of_elements = int number_of_elements =
array_boilerplate_description->constant_elements()->length(); array_boilerplate_description->constant_elements().length();
Node* literal = NewNode(javascript()->CreateLiteralArray( Node* literal = NewNode(javascript()->CreateLiteralArray(
array_boilerplate_description, pair, literal_flags, number_of_elements)); array_boilerplate_description, pair, literal_flags, number_of_elements));
environment()->BindAccumulator(literal, Environment::kAttachFrameState); environment()->BindAccumulator(literal, Environment::kAttachFrameState);
@ -2098,7 +2098,7 @@ void BytecodeGraphBuilder::VisitGetTemplateObject() {
// the JSArray constant here. // the JSArray constant here.
cached_value = TemplateObjectDescription::GetTemplateObject( cached_value = TemplateObjectDescription::GetTemplateObject(
isolate(), native_context(), description, shared_info(), slot.ToInt()); isolate(), native_context(), description, shared_info(), slot.ToInt());
nexus.vector()->Set(slot, *cached_value); nexus.vector().Set(slot, *cached_value);
} else { } else {
cached_value = cached_value =
handle(JSArray::cast(nexus.GetFeedback()->GetHeapObjectAssumeStrong()), handle(JSArray::cast(nexus.GetFeedback()->GetHeapObjectAssumeStrong()),

View File

@ -1923,16 +1923,16 @@ Address CheckObjectType(Address raw_value, Address raw_type,
Smi type(raw_type); Smi type(raw_type);
String location = String::cast(Object(raw_location)); String location = String::cast(Object(raw_location));
const char* expected; const char* expected;
switch (static_cast<ObjectType>(type->value())) { switch (static_cast<ObjectType>(type.value())) {
#define TYPE_CASE(Name) \ #define TYPE_CASE(Name) \
case ObjectType::k##Name: \ case ObjectType::k##Name: \
if (value->Is##Name()) return Smi::FromInt(0).ptr(); \ if (value.Is##Name()) return Smi::FromInt(0).ptr(); \
expected = #Name; \ expected = #Name; \
break; break;
#define TYPE_STRUCT_CASE(NAME, Name, name) \ #define TYPE_STRUCT_CASE(NAME, Name, name) \
case ObjectType::k##Name: \ case ObjectType::k##Name: \
if (value->Is##Name()) return Smi::FromInt(0).ptr(); \ if (value.Is##Name()) return Smi::FromInt(0).ptr(); \
expected = #Name; \ expected = #Name; \
break; break;
TYPE_CASE(Object) TYPE_CASE(Object)
@ -1945,11 +1945,11 @@ Address CheckObjectType(Address raw_value, Address raw_type,
#undef TYPE_STRUCT_CASE #undef TYPE_STRUCT_CASE
} }
std::stringstream value_description; std::stringstream value_description;
value->Print(value_description); value.Print(value_description);
FATAL( FATAL(
"Type cast failed in %s\n" "Type cast failed in %s\n"
" Expected %s but found %s", " Expected %s but found %s",
location->ToAsciiArray(), expected, value_description.str().c_str()); location.ToAsciiArray(), expected, value_description.str().c_str());
#else #else
UNREACHABLE(); UNREACHABLE();
#endif #endif

View File

@ -181,9 +181,8 @@ class FieldRepresentationDependency final
bool IsValid() const override { bool IsValid() const override {
DisallowHeapAllocation no_heap_allocation; DisallowHeapAllocation no_heap_allocation;
Handle<Map> owner = owner_.object(); Handle<Map> owner = owner_.object();
return representation_.Equals(owner->instance_descriptors() return representation_.Equals(
->GetDetails(descriptor_) owner->instance_descriptors().GetDetails(descriptor_).representation());
.representation());
} }
void Install(const MaybeObjectHandle& code) const override { void Install(const MaybeObjectHandle& code) const override {
@ -213,7 +212,7 @@ class FieldTypeDependency final : public CompilationDependencies::Dependency {
DisallowHeapAllocation no_heap_allocation; DisallowHeapAllocation no_heap_allocation;
Handle<Map> owner = owner_.object(); Handle<Map> owner = owner_.object();
Handle<Object> type = type_.object(); Handle<Object> type = type_.object();
return *type == owner->instance_descriptors()->GetFieldType(descriptor_); return *type == owner->instance_descriptors().GetFieldType(descriptor_);
} }
void Install(const MaybeObjectHandle& code) const override { void Install(const MaybeObjectHandle& code) const override {
@ -242,7 +241,7 @@ class FieldConstnessDependency final
DisallowHeapAllocation no_heap_allocation; DisallowHeapAllocation no_heap_allocation;
Handle<Map> owner = owner_.object(); Handle<Map> owner = owner_.object();
return PropertyConstness::kConst == return PropertyConstness::kConst ==
owner->instance_descriptors()->GetDetails(descriptor_).constness(); owner->instance_descriptors().GetDetails(descriptor_).constness();
} }
void Install(const MaybeObjectHandle& code) const override { void Install(const MaybeObjectHandle& code) const override {
@ -332,7 +331,7 @@ class ElementsKindDependency final
bool IsValid() const override { bool IsValid() const override {
Handle<AllocationSite> site = site_.object(); Handle<AllocationSite> site = site_.object();
ElementsKind kind = site->PointsToLiteral() ElementsKind kind = site->PointsToLiteral()
? site->boilerplate()->GetElementsKind() ? site->boilerplate().GetElementsKind()
: site->GetElementsKind(); : site->GetElementsKind();
return kind_ == kind; return kind_ == kind;
} }
@ -372,9 +371,8 @@ class InitialMapInstanceSizePredictionDependency final
void Install(const MaybeObjectHandle& code) const override { void Install(const MaybeObjectHandle& code) const override {
SLOW_DCHECK(IsValid()); SLOW_DCHECK(IsValid());
DCHECK(!function_.object() DCHECK(
->initial_map() !function_.object()->initial_map().IsInobjectSlackTrackingInProgress());
->IsInobjectSlackTrackingInProgress());
} }
private: private:

View File

@ -102,9 +102,9 @@ void JsonPrintFunctionSource(std::ostream& os, int source_id,
if (!script.is_null() && !script->IsUndefined(isolate) && !shared.is_null()) { if (!script.is_null() && !script->IsUndefined(isolate) && !shared.is_null()) {
Object source_name = script->name(); Object source_name = script->name();
os << ", \"sourceName\": \""; os << ", \"sourceName\": \"";
if (source_name->IsString()) { if (source_name.IsString()) {
std::ostringstream escaped_name; std::ostringstream escaped_name;
escaped_name << String::cast(source_name)->ToCString().get(); escaped_name << String::cast(source_name).ToCString().get();
os << JSONEscaped(escaped_name); os << JSONEscaped(escaped_name);
} }
os << "\""; os << "\"";
@ -173,7 +173,7 @@ void JsonPrintAllSourceWithPositions(std::ostream& os,
JsonPrintFunctionSource(os, -1, JsonPrintFunctionSource(os, -1,
info->shared_info().is_null() info->shared_info().is_null()
? std::unique_ptr<char[]>(new char[1]{0}) ? std::unique_ptr<char[]>(new char[1]{0})
: info->shared_info()->DebugName()->ToCString(), : info->shared_info()->DebugName().ToCString(),
script, isolate, info->shared_info(), true); script, isolate, info->shared_info(), true);
const auto& inlined = info->inlined_functions(); const auto& inlined = info->inlined_functions();
SourceIdAssigner id_assigner(info->inlined_functions().size()); SourceIdAssigner id_assigner(info->inlined_functions().size());
@ -181,7 +181,7 @@ void JsonPrintAllSourceWithPositions(std::ostream& os,
os << ", "; os << ", ";
Handle<SharedFunctionInfo> shared = inlined[id].shared_info; Handle<SharedFunctionInfo> shared = inlined[id].shared_info;
const int source_id = id_assigner.GetIdFor(shared); const int source_id = id_assigner.GetIdFor(shared);
JsonPrintFunctionSource(os, source_id, shared->DebugName()->ToCString(), JsonPrintFunctionSource(os, source_id, shared->DebugName().ToCString(),
handle(Script::cast(shared->script()), isolate), handle(Script::cast(shared->script()), isolate),
isolate, shared, true); isolate, shared, true);
} }
@ -216,12 +216,12 @@ std::unique_ptr<char[]> GetVisualizerLogFileName(OptimizedCompilationInfo* info,
EmbeddedVector<char, 256> source_file(0); EmbeddedVector<char, 256> source_file(0);
bool source_available = false; bool source_available = false;
if (FLAG_trace_file_names && info->has_shared_info() && if (FLAG_trace_file_names && info->has_shared_info() &&
info->shared_info()->script()->IsScript()) { info->shared_info()->script().IsScript()) {
Object source_name = Script::cast(info->shared_info()->script())->name(); Object source_name = Script::cast(info->shared_info()->script()).name();
if (source_name->IsString()) { if (source_name.IsString()) {
String str = String::cast(source_name); String str = String::cast(source_name);
if (str->length() > 0) { if (str.length() > 0) {
SNPrintF(source_file, "%s", str->ToCString().get()); SNPrintF(source_file, "%s", str.ToCString().get());
std::replace(source_file.begin(), std::replace(source_file.begin(),
source_file.begin() + source_file.length(), '/', '_'); source_file.begin() + source_file.length(), '/', '_');
source_available = true; source_available = true;

View File

@ -452,7 +452,7 @@ Reduction JSCallReducer::ReduceFunctionPrototypeBind(Node* node) {
return inference.NoChange(); return inference.NoChange();
} }
if (!descriptors->GetStrongValue(JSFunction::kLengthDescriptorIndex) if (!descriptors->GetStrongValue(JSFunction::kLengthDescriptorIndex)
->IsAccessorInfo()) { .IsAccessorInfo()) {
return inference.NoChange(); return inference.NoChange();
} }
if (descriptors->GetKey(JSFunction::kNameDescriptorIndex) != if (descriptors->GetKey(JSFunction::kNameDescriptorIndex) !=
@ -460,7 +460,7 @@ Reduction JSCallReducer::ReduceFunctionPrototypeBind(Node* node) {
return inference.NoChange(); return inference.NoChange();
} }
if (!descriptors->GetStrongValue(JSFunction::kNameDescriptorIndex) if (!descriptors->GetStrongValue(JSFunction::kNameDescriptorIndex)
->IsAccessorInfo()) { .IsAccessorInfo()) {
return inference.NoChange(); return inference.NoChange();
} }
} }
@ -2820,7 +2820,7 @@ Reduction JSCallReducer::ReduceCallApiFunction(
? jsgraph()->HeapConstant(api_holder) ? jsgraph()->HeapConstant(api_holder)
: receiver; : receiver;
} else if (function_template_info->accept_any_receiver() && } else if (function_template_info->accept_any_receiver() &&
function_template_info->signature()->IsUndefined(isolate())) { function_template_info->signature().IsUndefined(isolate())) {
// We haven't found any {receiver_maps}, but we might still be able to // We haven't found any {receiver_maps}, but we might still be able to
// optimize the API call depending on the {function_template_info}. // optimize the API call depending on the {function_template_info}.
// If the API function accepts any kind of {receiver}, we only need to // If the API function accepts any kind of {receiver}, we only need to
@ -2846,7 +2846,7 @@ Reduction JSCallReducer::ReduceCallApiFunction(
// faster than the generic call sequence. // faster than the generic call sequence.
Builtins::Name builtin_name = Builtins::Name builtin_name =
!function_template_info->accept_any_receiver() !function_template_info->accept_any_receiver()
? (function_template_info->signature()->IsUndefined(isolate()) ? (function_template_info->signature().IsUndefined(isolate())
? Builtins::kCallFunctionTemplate_CheckAccess ? Builtins::kCallFunctionTemplate_CheckAccess
: Builtins:: : Builtins::
kCallFunctionTemplate_CheckAccessAndCompatibleReceiver) kCallFunctionTemplate_CheckAccessAndCompatibleReceiver)

View File

@ -282,8 +282,8 @@ void JSObjectData::SerializeObjectCreateMap(JSHeapBroker* broker) {
TraceScope tracer(broker, this, "JSObjectData::SerializeObjectCreateMap"); TraceScope tracer(broker, this, "JSObjectData::SerializeObjectCreateMap");
Handle<JSObject> jsobject = Handle<JSObject>::cast(object()); Handle<JSObject> jsobject = Handle<JSObject>::cast(object());
if (jsobject->map()->is_prototype_map()) { if (jsobject->map().is_prototype_map()) {
Handle<Object> maybe_proto_info(jsobject->map()->prototype_info(), Handle<Object> maybe_proto_info(jsobject->map().prototype_info(),
broker->isolate()); broker->isolate());
if (maybe_proto_info->IsPrototypeInfo()) { if (maybe_proto_info->IsPrototypeInfo()) {
auto proto_info = Handle<PrototypeInfo>::cast(maybe_proto_info); auto proto_info = Handle<PrototypeInfo>::cast(maybe_proto_info);
@ -358,7 +358,7 @@ JSTypedArrayData::JSTypedArrayData(JSHeapBroker* broker, ObjectData** storage,
is_on_heap_(object->is_on_heap()), is_on_heap_(object->is_on_heap()),
length_(object->length()), length_(object->length()),
elements_external_pointer_( elements_external_pointer_(
FixedTypedArrayBase::cast(object->elements())->external_pointer()) {} FixedTypedArrayBase::cast(object->elements()).external_pointer()) {}
void JSTypedArrayData::Serialize(JSHeapBroker* broker) { void JSTypedArrayData::Serialize(JSHeapBroker* broker) {
if (serialized_) return; if (serialized_) return;
@ -705,14 +705,14 @@ bool IsFastLiteralHelper(Handle<JSObject> boilerplate, int max_depth,
// TODO(turbofan): Do we want to support out-of-object properties? // TODO(turbofan): Do we want to support out-of-object properties?
if (!(boilerplate->HasFastProperties() && if (!(boilerplate->HasFastProperties() &&
boilerplate->property_array()->length() == 0)) { boilerplate->property_array().length() == 0)) {
return false; return false;
} }
// Check the in-object properties. // Check the in-object properties.
Handle<DescriptorArray> descriptors( Handle<DescriptorArray> descriptors(boilerplate->map().instance_descriptors(),
boilerplate->map()->instance_descriptors(), isolate); isolate);
int limit = boilerplate->map()->NumberOfOwnDescriptors(); int limit = boilerplate->map().NumberOfOwnDescriptors();
for (int i = 0; i < limit; i++) { for (int i = 0; i < limit; i++) {
PropertyDetails details = descriptors->GetDetails(i); PropertyDetails details = descriptors->GetDetails(i);
if (details.location() != kField) continue; if (details.location() != kField) continue;
@ -954,15 +954,15 @@ bool IsReadOnlyLengthDescriptor(Isolate* isolate, Handle<Map> jsarray_map) {
DCHECK(!jsarray_map->is_dictionary_map()); DCHECK(!jsarray_map->is_dictionary_map());
Handle<Name> length_string = isolate->factory()->length_string(); Handle<Name> length_string = isolate->factory()->length_string();
DescriptorArray descriptors = jsarray_map->instance_descriptors(); DescriptorArray descriptors = jsarray_map->instance_descriptors();
int number = descriptors->Search(*length_string, *jsarray_map); int number = descriptors.Search(*length_string, *jsarray_map);
DCHECK_NE(DescriptorArray::kNotFound, number); DCHECK_NE(DescriptorArray::kNotFound, number);
return descriptors->GetDetails(number).IsReadOnly(); return descriptors.GetDetails(number).IsReadOnly();
} }
bool SupportsFastArrayIteration(Isolate* isolate, Handle<Map> map) { bool SupportsFastArrayIteration(Isolate* isolate, Handle<Map> map) {
return map->instance_type() == JS_ARRAY_TYPE && return map->instance_type() == JS_ARRAY_TYPE &&
IsFastElementsKind(map->elements_kind()) && IsFastElementsKind(map->elements_kind()) &&
map->prototype()->IsJSArray() && map->prototype().IsJSArray() &&
isolate->IsAnyInitialArrayPrototype( isolate->IsAnyInitialArrayPrototype(
handle(JSArray::cast(map->prototype()), isolate)) && handle(JSArray::cast(map->prototype()), isolate)) &&
isolate->IsNoElementsProtectorIntact(); isolate->IsNoElementsProtectorIntact();
@ -1724,7 +1724,7 @@ void JSObjectData::SerializeRecursive(JSHeapBroker* broker, int depth) {
// We only serialize boilerplates that pass the IsInlinableFastLiteral // We only serialize boilerplates that pass the IsInlinableFastLiteral
// check, so we only do a sanity check on the depth here. // check, so we only do a sanity check on the depth here.
CHECK_GT(depth, 0); CHECK_GT(depth, 0);
CHECK(!boilerplate->map()->is_deprecated()); CHECK(!boilerplate->map().is_deprecated());
// Serialize the elements. // Serialize the elements.
Isolate* const isolate = broker->isolate(); Isolate* const isolate = broker->isolate();
@ -1775,13 +1775,13 @@ void JSObjectData::SerializeRecursive(JSHeapBroker* broker, int depth) {
// TODO(turbofan): Do we want to support out-of-object properties? // TODO(turbofan): Do we want to support out-of-object properties?
CHECK(boilerplate->HasFastProperties() && CHECK(boilerplate->HasFastProperties() &&
boilerplate->property_array()->length() == 0); boilerplate->property_array().length() == 0);
CHECK_EQ(inobject_fields_.size(), 0u); CHECK_EQ(inobject_fields_.size(), 0u);
// Check the in-object properties. // Check the in-object properties.
Handle<DescriptorArray> descriptors( Handle<DescriptorArray> descriptors(boilerplate->map().instance_descriptors(),
boilerplate->map()->instance_descriptors(), isolate); isolate);
int const limit = boilerplate->map()->NumberOfOwnDescriptors(); int const limit = boilerplate->map().NumberOfOwnDescriptors();
for (int i = 0; i < limit; i++) { for (int i = 0; i < limit; i++) {
PropertyDetails details = descriptors->GetDetails(i); PropertyDetails details = descriptors->GetDetails(i);
if (details.location() != kField) continue; if (details.location() != kField) continue;
@ -1978,14 +1978,14 @@ void JSHeapBroker::CollectArrayAndObjectPrototypes() {
CHECK(array_and_object_prototypes_.empty()); CHECK(array_and_object_prototypes_.empty());
Object maybe_context = isolate()->heap()->native_contexts_list(); Object maybe_context = isolate()->heap()->native_contexts_list();
while (!maybe_context->IsUndefined(isolate())) { while (!maybe_context.IsUndefined(isolate())) {
Context context = Context::cast(maybe_context); Context context = Context::cast(maybe_context);
Object array_prot = context->get(Context::INITIAL_ARRAY_PROTOTYPE_INDEX); Object array_prot = context.get(Context::INITIAL_ARRAY_PROTOTYPE_INDEX);
Object object_prot = context->get(Context::INITIAL_OBJECT_PROTOTYPE_INDEX); Object object_prot = context.get(Context::INITIAL_OBJECT_PROTOTYPE_INDEX);
array_and_object_prototypes_.emplace(JSObject::cast(array_prot), isolate()); array_and_object_prototypes_.emplace(JSObject::cast(array_prot), isolate());
array_and_object_prototypes_.emplace(JSObject::cast(object_prot), array_and_object_prototypes_.emplace(JSObject::cast(object_prot),
isolate()); isolate());
maybe_context = context->next_context_link(); maybe_context = context.next_context_link();
} }
CHECK(!array_and_object_prototypes_.empty()); CHECK(!array_and_object_prototypes_.empty());
@ -2427,7 +2427,7 @@ int MapRef::GetInObjectPropertyOffset(int i) const {
PropertyDetails MapRef::GetPropertyDetails(int descriptor_index) const { PropertyDetails MapRef::GetPropertyDetails(int descriptor_index) const {
if (broker()->mode() == JSHeapBroker::kDisabled) { if (broker()->mode() == JSHeapBroker::kDisabled) {
AllowHandleDereference allow_handle_dereference; AllowHandleDereference allow_handle_dereference;
return object()->instance_descriptors()->GetDetails(descriptor_index); return object()->instance_descriptors().GetDetails(descriptor_index);
} }
DescriptorArrayData* descriptors = data()->AsMap()->instance_descriptors(); DescriptorArrayData* descriptors = data()->AsMap()->instance_descriptors();
return descriptors->contents().at(descriptor_index).details; return descriptors->contents().at(descriptor_index).details;
@ -2439,7 +2439,7 @@ NameRef MapRef::GetPropertyKey(int descriptor_index) const {
AllowHandleDereference allow_handle_dereference; AllowHandleDereference allow_handle_dereference;
return NameRef( return NameRef(
broker(), broker(),
handle(object()->instance_descriptors()->GetKey(descriptor_index), handle(object()->instance_descriptors().GetKey(descriptor_index),
broker()->isolate())); broker()->isolate()));
} }
DescriptorArrayData* descriptors = data()->AsMap()->instance_descriptors(); DescriptorArrayData* descriptors = data()->AsMap()->instance_descriptors();
@ -2475,7 +2475,7 @@ ObjectRef MapRef::GetFieldType(int descriptor_index) const {
AllowHandleAllocation handle_allocation; AllowHandleAllocation handle_allocation;
AllowHandleDereference allow_handle_dereference; AllowHandleDereference allow_handle_dereference;
Handle<FieldType> field_type( Handle<FieldType> field_type(
object()->instance_descriptors()->GetFieldType(descriptor_index), object()->instance_descriptors().GetFieldType(descriptor_index),
broker()->isolate()); broker()->isolate());
return ObjectRef(broker(), field_type); return ObjectRef(broker(), field_type);
} }
@ -2667,7 +2667,7 @@ BIMODAL_ACCESSOR(FeedbackCell, HeapObject, value)
void* JSTypedArrayRef::elements_external_pointer() const { void* JSTypedArrayRef::elements_external_pointer() const {
if (broker()->mode() == JSHeapBroker::kDisabled) { if (broker()->mode() == JSHeapBroker::kDisabled) {
AllowHandleDereference allow_handle_dereference; AllowHandleDereference allow_handle_dereference;
return FixedTypedArrayBase::cast(object()->elements())->external_pointer(); return FixedTypedArrayBase::cast(object()->elements()).external_pointer();
} }
return data()->AsJSTypedArray()->elements_external_pointer(); return data()->AsJSTypedArray()->elements_external_pointer();
} }
@ -2842,7 +2842,7 @@ base::Optional<ObjectRef> ObjectRef::GetOwnConstantElement(
base::Optional<ObjectRef> JSArrayRef::GetOwnCowElement(uint32_t index, base::Optional<ObjectRef> JSArrayRef::GetOwnCowElement(uint32_t index,
bool serialize) const { bool serialize) const {
if (broker()->mode() == JSHeapBroker::kDisabled) { if (broker()->mode() == JSHeapBroker::kDisabled) {
if (!object()->elements()->IsCowArray()) return base::nullopt; if (!object()->elements().IsCowArray()) return base::nullopt;
return GetOwnElementFromHeap(broker(), object(), index, false); return GetOwnElementFromHeap(broker(), object(), index, false);
} }
@ -2910,7 +2910,7 @@ ObjectRef::ObjectRef(JSHeapBroker* broker, Handle<Object> object)
namespace { namespace {
OddballType GetOddballType(Isolate* isolate, Map map) { OddballType GetOddballType(Isolate* isolate, Map map) {
if (map->instance_type() != ODDBALL_TYPE) { if (map.instance_type() != ODDBALL_TYPE) {
return OddballType::kNone; return OddballType::kNone;
} }
ReadOnlyRoots roots(isolate); ReadOnlyRoots roots(isolate);
@ -2941,9 +2941,9 @@ HeapObjectType HeapObjectRef::GetHeapObjectType() const {
AllowHandleDereference handle_dereference; AllowHandleDereference handle_dereference;
Map map = Handle<HeapObject>::cast(object())->map(); Map map = Handle<HeapObject>::cast(object())->map();
HeapObjectType::Flags flags(0); HeapObjectType::Flags flags(0);
if (map->is_undetectable()) flags |= HeapObjectType::kUndetectable; if (map.is_undetectable()) flags |= HeapObjectType::kUndetectable;
if (map->is_callable()) flags |= HeapObjectType::kCallable; if (map.is_callable()) flags |= HeapObjectType::kCallable;
return HeapObjectType(map->instance_type(), flags, return HeapObjectType(map.instance_type(), flags,
GetOddballType(broker()->isolate(), map)); GetOddballType(broker()->isolate(), map));
} }
HeapObjectType::Flags flags(0); HeapObjectType::Flags flags(0);

View File

@ -744,7 +744,7 @@ void JSInliningHeuristic::PrintCandidates() {
? candidate.functions[i].value().shared() ? candidate.functions[i].value().shared()
: candidate.shared_info.value(); : candidate.shared_info.value();
PrintF(" - size:%d, name: %s\n", candidate.bytecode[i].value().length(), PrintF(" - size:%d, name: %s\n", candidate.bytecode[i].value().length(),
shared.object()->DebugName()->ToCString().get()); shared.object()->DebugName().ToCString().get());
} }
} }
} }

View File

@ -246,7 +246,7 @@ Reduction JSNativeContextSpecialization::ReduceJSAsyncFunctionEnter(
FrameStateInfoOf(frame_state->op()).shared_info().ToHandleChecked(); FrameStateInfoOf(frame_state->op()).shared_info().ToHandleChecked();
DCHECK(shared->is_compiled()); DCHECK(shared->is_compiled());
int register_count = shared->internal_formal_parameter_count() + int register_count = shared->internal_formal_parameter_count() +
shared->GetBytecodeArray()->register_count(); shared->GetBytecodeArray().register_count();
Node* value = effect = Node* value = effect =
graph()->NewNode(javascript()->CreateAsyncFunctionObject(register_count), graph()->NewNode(javascript()->CreateAsyncFunctionObject(register_count),
closure, receiver, promise, context, effect, control); closure, receiver, promise, context, effect, control);
@ -542,8 +542,8 @@ JSNativeContextSpecialization::InferHasInPrototypeChain(
none = false; none = false;
break; break;
} }
if (!current->map()->is_stable() || if (!current->map().is_stable() ||
current->map()->instance_type() <= LAST_SPECIAL_RECEIVER_TYPE) { current->map().instance_type() <= LAST_SPECIAL_RECEIVER_TYPE) {
return kMayBeInPrototypeChain; return kMayBeInPrototypeChain;
} }
} }
@ -560,7 +560,7 @@ JSNativeContextSpecialization::InferHasInPrototypeChain(
// might be a different object each time, so it's much simpler to include // might be a different object each time, so it's much simpler to include
// {prototype}. That does, however, mean that we must check {prototype}'s // {prototype}. That does, however, mean that we must check {prototype}'s
// map stability. // map stability.
if (!prototype->map()->is_stable()) return kMayBeInPrototypeChain; if (!prototype->map().is_stable()) return kMayBeInPrototypeChain;
last_prototype.emplace(broker(), Handle<JSObject>::cast(prototype)); last_prototype.emplace(broker(), Handle<JSObject>::cast(prototype));
} }
WhereToStart start = result == NodeProperties::kUnreliableReceiverMaps WhereToStart start = result == NodeProperties::kUnreliableReceiverMaps
@ -3305,7 +3305,7 @@ MaybeHandle<Map> JSNativeContextSpecialization::InferReceiverRootMap(
Node* receiver) { Node* receiver) {
HeapObjectMatcher m(receiver); HeapObjectMatcher m(receiver);
if (m.HasValue()) { if (m.HasValue()) {
return handle(m.Value()->map()->FindRootMap(isolate()), isolate()); return handle(m.Value()->map().FindRootMap(isolate()), isolate());
} else if (m.IsJSCreate()) { } else if (m.IsJSCreate()) {
base::Optional<MapRef> initial_map = base::Optional<MapRef> initial_map =
NodeProperties::GetJSCreateMap(broker(), receiver); NodeProperties::GetJSCreateMap(broker(), receiver);

View File

@ -161,7 +161,7 @@ CallDescriptor* Linkage::ComputeIncoming(Zone* zone,
// plus the receiver. // plus the receiver.
SharedFunctionInfo shared = info->closure()->shared(); SharedFunctionInfo shared = info->closure()->shared();
return GetJSCallDescriptor(zone, info->is_osr(), return GetJSCallDescriptor(zone, info->is_osr(),
1 + shared->internal_formal_parameter_count(), 1 + shared.internal_formal_parameter_count(),
CallDescriptor::kCanUseRoots); CallDescriptor::kCanUseRoots);
} }
return nullptr; // TODO(titzer): ? return nullptr; // TODO(titzer): ?

View File

@ -66,8 +66,7 @@ PipelineStatistics::PipelineStatistics(OptimizedCompilationInfo* info,
phase_name_(nullptr) { phase_name_(nullptr) {
if (info->has_shared_info()) { if (info->has_shared_info()) {
source_size_ = static_cast<size_t>(info->shared_info()->SourceSize()); source_size_ = static_cast<size_t>(info->shared_info()->SourceSize());
std::unique_ptr<char[]> name = std::unique_ptr<char[]> name = info->shared_info()->DebugName().ToCString();
info->shared_info()->DebugName()->ToCString();
function_name_ = name.get(); function_name_ = name.get();
} }
total_stats_.Begin(this); total_stats_.Begin(this);

View File

@ -567,18 +567,18 @@ namespace {
void PrintFunctionSource(OptimizedCompilationInfo* info, Isolate* isolate, void PrintFunctionSource(OptimizedCompilationInfo* info, Isolate* isolate,
int source_id, Handle<SharedFunctionInfo> shared) { int source_id, Handle<SharedFunctionInfo> shared) {
if (!shared->script()->IsUndefined(isolate)) { if (!shared->script().IsUndefined(isolate)) {
Handle<Script> script(Script::cast(shared->script()), isolate); Handle<Script> script(Script::cast(shared->script()), isolate);
if (!script->source()->IsUndefined(isolate)) { if (!script->source().IsUndefined(isolate)) {
CodeTracer::Scope tracing_scope(isolate->GetCodeTracer()); CodeTracer::Scope tracing_scope(isolate->GetCodeTracer());
Object source_name = script->name(); Object source_name = script->name();
OFStream os(tracing_scope.file()); OFStream os(tracing_scope.file());
os << "--- FUNCTION SOURCE ("; os << "--- FUNCTION SOURCE (";
if (source_name->IsString()) { if (source_name.IsString()) {
os << String::cast(source_name)->ToCString().get() << ":"; os << String::cast(source_name).ToCString().get() << ":";
} }
os << shared->DebugName()->ToCString().get() << ") id{"; os << shared->DebugName().ToCString().get() << ") id{";
os << info->optimization_id() << "," << source_id << "} start{"; os << info->optimization_id() << "," << source_id << "} start{";
os << shared->StartPosition() << "} ---\n"; os << shared->StartPosition() << "} ---\n";
{ {
@ -604,7 +604,7 @@ void PrintInlinedFunctionInfo(
int inlining_id, const OptimizedCompilationInfo::InlinedFunctionHolder& h) { int inlining_id, const OptimizedCompilationInfo::InlinedFunctionHolder& h) {
CodeTracer::Scope tracing_scope(isolate->GetCodeTracer()); CodeTracer::Scope tracing_scope(isolate->GetCodeTracer());
OFStream os(tracing_scope.file()); OFStream os(tracing_scope.file());
os << "INLINE (" << h.shared_info->DebugName()->ToCString().get() << ") id{" os << "INLINE (" << h.shared_info->DebugName().ToCString().get() << ") id{"
<< info->optimization_id() << "," << source_id << "} AS " << inlining_id << info->optimization_id() << "," << source_id << "} AS " << inlining_id
<< " AT "; << " AT ";
const SourcePosition position = h.position.position; const SourcePosition position = h.position.position;
@ -654,11 +654,11 @@ void PrintCode(Isolate* isolate, Handle<Code> code,
bool print_source = code->kind() == Code::OPTIMIZED_FUNCTION; bool print_source = code->kind() == Code::OPTIMIZED_FUNCTION;
if (print_source) { if (print_source) {
Handle<SharedFunctionInfo> shared = info->shared_info(); Handle<SharedFunctionInfo> shared = info->shared_info();
if (shared->script()->IsScript() && if (shared->script().IsScript() &&
!Script::cast(shared->script())->source()->IsUndefined(isolate)) { !Script::cast(shared->script()).source().IsUndefined(isolate)) {
os << "--- Raw source ---\n"; os << "--- Raw source ---\n";
StringCharacterStream stream( StringCharacterStream stream(
String::cast(Script::cast(shared->script())->source()), String::cast(Script::cast(shared->script()).source()),
shared->StartPosition()); shared->StartPosition());
// fun->end_position() points to the last character in the stream. We // fun->end_position() points to the last character in the stream. We
// need to compensate by adding one to calculate the length. // need to compensate by adding one to calculate the length.
@ -956,7 +956,7 @@ PipelineCompilationJob::Status PipelineCompilationJob::PrepareJobImpl(
compilation_info()->MarkAsAllocationFoldingEnabled(); compilation_info()->MarkAsAllocationFoldingEnabled();
} }
if (compilation_info()->closure()->raw_feedback_cell()->map() == if (compilation_info()->closure()->raw_feedback_cell().map() ==
ReadOnlyRoots(isolate).one_closure_cell_map()) { ReadOnlyRoots(isolate).one_closure_cell_map()) {
compilation_info()->MarkAsFunctionContextSpecializing(); compilation_info()->MarkAsFunctionContextSpecializing();
} }
@ -1016,7 +1016,7 @@ PipelineCompilationJob::Status PipelineCompilationJob::FinalizeJobImpl(
} }
compilation_info()->SetCode(code); compilation_info()->SetCode(code);
compilation_info()->native_context()->AddOptimizedCode(*code); compilation_info()->native_context().AddOptimizedCode(*code);
RegisterWeakObjectsInOptimizedCode(code, isolate); RegisterWeakObjectsInOptimizedCode(code, isolate);
return SUCCEEDED; return SUCCEEDED;
} }
@ -1088,12 +1088,12 @@ namespace {
Maybe<OuterContext> GetModuleContext(Handle<JSFunction> closure) { Maybe<OuterContext> GetModuleContext(Handle<JSFunction> closure) {
Context current = closure->context(); Context current = closure->context();
size_t distance = 0; size_t distance = 0;
while (!current->IsNativeContext()) { while (!current.IsNativeContext()) {
if (current->IsModuleContext()) { if (current.IsModuleContext()) {
return Just( return Just(
OuterContext(handle(current, current->GetIsolate()), distance)); OuterContext(handle(current, current.GetIsolate()), distance));
} }
current = current->previous(); current = current.previous();
distance++; distance++;
} }
return Nothing<OuterContext>(); return Nothing<OuterContext>();

View File

@ -153,8 +153,8 @@ SerializerForBackgroundCompilation::Environment::Environment(
Zone* zone, CompilationSubject function) Zone* zone, CompilationSubject function)
: zone_(zone), : zone_(zone),
function_(function.blueprint()), function_(function.blueprint()),
parameter_count_(function_.shared->GetBytecodeArray()->parameter_count()), parameter_count_(function_.shared->GetBytecodeArray().parameter_count()),
register_count_(function_.shared->GetBytecodeArray()->register_count()), register_count_(function_.shared->GetBytecodeArray().register_count()),
environment_hints_(environment_hints_size(), Hints(zone), zone), environment_hints_(environment_hints_size(), Hints(zone), zone),
return_value_hints_(zone) { return_value_hints_(zone) {
Handle<JSFunction> closure; Handle<JSFunction> closure;
@ -186,7 +186,7 @@ SerializerForBackgroundCompilation::Environment::Environment(
interpreter::Register new_target_reg = interpreter::Register new_target_reg =
function_.shared->GetBytecodeArray() function_.shared->GetBytecodeArray()
->incoming_new_target_or_generator_register(); .incoming_new_target_or_generator_register();
if (new_target_reg.is_valid()) { if (new_target_reg.is_valid()) {
DCHECK(register_hints(new_target_reg).IsEmpty()); DCHECK(register_hints(new_target_reg).IsEmpty());
if (new_target.has_value()) { if (new_target.has_value()) {
@ -379,7 +379,7 @@ void SerializerForBackgroundCompilation::VisitGetSuperConstructor(
// For JSNativeContextSpecialization::ReduceJSGetSuperConstructor. // For JSNativeContextSpecialization::ReduceJSGetSuperConstructor.
if (!constant->IsJSFunction()) continue; if (!constant->IsJSFunction()) continue;
MapRef map(broker(), MapRef map(broker(),
handle(HeapObject::cast(*constant)->map(), broker()->isolate())); handle(HeapObject::cast(*constant).map(), broker()->isolate()));
map.SerializePrototype(); map.SerializePrototype();
ObjectRef proto = map.prototype(); ObjectRef proto = map.prototype();
if (proto.IsHeapObject() && proto.AsHeapObject().map().is_constructor()) { if (proto.IsHeapObject() && proto.AsHeapObject().map().is_constructor()) {
@ -608,7 +608,7 @@ Hints SerializerForBackgroundCompilation::RunChildSerializer(
padded.pop_back(); // Remove the spread element. padded.pop_back(); // Remove the spread element.
// Fill the rest with empty hints. // Fill the rest with empty hints.
padded.resize( padded.resize(
function.blueprint().shared->GetBytecodeArray()->parameter_count(), function.blueprint().shared->GetBytecodeArray().parameter_count(),
Hints(zone())); Hints(zone()));
return RunChildSerializer(function, new_target, padded, false); return RunChildSerializer(function, new_target, padded, false);
} }
@ -657,7 +657,7 @@ void SerializerForBackgroundCompilation::ProcessCallOrConstruct(
if (!hint->IsJSFunction()) continue; if (!hint->IsJSFunction()) continue;
Handle<JSFunction> function = Handle<JSFunction>::cast(hint); Handle<JSFunction> function = Handle<JSFunction>::cast(hint);
if (!function->shared()->IsInlineable() || !function->has_feedback_vector()) if (!function->shared().IsInlineable() || !function->has_feedback_vector())
continue; continue;
environment()->accumulator_hints().Add(RunChildSerializer( environment()->accumulator_hints().Add(RunChildSerializer(

View File

@ -5963,8 +5963,8 @@ WasmImportCallKind GetWasmImportCallKind(Handle<JSReceiver> target,
bool has_bigint_feature) { bool has_bigint_feature) {
if (WasmExportedFunction::IsWasmExportedFunction(*target)) { if (WasmExportedFunction::IsWasmExportedFunction(*target)) {
auto imported_function = WasmExportedFunction::cast(*target); auto imported_function = WasmExportedFunction::cast(*target);
auto func_index = imported_function->function_index(); auto func_index = imported_function.function_index();
auto module = imported_function->instance()->module(); auto module = imported_function.instance().module();
wasm::FunctionSig* imported_sig = module->functions[func_index].sig; wasm::FunctionSig* imported_sig = module->functions[func_index].sig;
if (*imported_sig != *expected_sig) { if (*imported_sig != *expected_sig) {
return WasmImportCallKind::kLinkError; return WasmImportCallKind::kLinkError;
@ -5978,7 +5978,7 @@ WasmImportCallKind GetWasmImportCallKind(Handle<JSReceiver> target,
} }
if (WasmCapiFunction::IsWasmCapiFunction(*target)) { if (WasmCapiFunction::IsWasmCapiFunction(*target)) {
WasmCapiFunction capi_function = WasmCapiFunction::cast(*target); WasmCapiFunction capi_function = WasmCapiFunction::cast(*target);
if (!capi_function->IsSignatureEqual(expected_sig)) { if (!capi_function.IsSignatureEqual(expected_sig)) {
return WasmImportCallKind::kLinkError; return WasmImportCallKind::kLinkError;
} }
return WasmImportCallKind::kWasmToCapi; return WasmImportCallKind::kWasmToCapi;
@ -6011,8 +6011,8 @@ WasmImportCallKind GetWasmImportCallKind(Handle<JSReceiver> target,
COMPARE_SIG_FOR_BUILTIN(F32##name); \ COMPARE_SIG_FOR_BUILTIN(F32##name); \
break; break;
if (FLAG_wasm_math_intrinsics && shared->HasBuiltinId()) { if (FLAG_wasm_math_intrinsics && shared.HasBuiltinId()) {
switch (shared->builtin_id()) { switch (shared.builtin_id()) {
COMPARE_SIG_FOR_BUILTIN_F64(Acos); COMPARE_SIG_FOR_BUILTIN_F64(Acos);
COMPARE_SIG_FOR_BUILTIN_F64(Asin); COMPARE_SIG_FOR_BUILTIN_F64(Asin);
COMPARE_SIG_FOR_BUILTIN_F64(Atan); COMPARE_SIG_FOR_BUILTIN_F64(Atan);
@ -6044,12 +6044,12 @@ WasmImportCallKind GetWasmImportCallKind(Handle<JSReceiver> target,
#undef COMPARE_SIG_FOR_BUILTIN_F64 #undef COMPARE_SIG_FOR_BUILTIN_F64
#undef COMPARE_SIG_FOR_BUILTIN_F32_F64 #undef COMPARE_SIG_FOR_BUILTIN_F32_F64
if (IsClassConstructor(shared->kind())) { if (IsClassConstructor(shared.kind())) {
// Class constructor will throw anyway. // Class constructor will throw anyway.
return WasmImportCallKind::kUseCallBuiltin; return WasmImportCallKind::kUseCallBuiltin;
} }
bool sloppy = is_sloppy(shared->language_mode()) && !shared->native(); bool sloppy = is_sloppy(shared.language_mode()) && !shared.native();
if (shared->internal_formal_parameter_count() == if (shared.internal_formal_parameter_count() ==
expected_sig->parameter_count()) { expected_sig->parameter_count()) {
return sloppy ? WasmImportCallKind::kJSFunctionArityMatchSloppy return sloppy ? WasmImportCallKind::kJSFunctionArityMatchSloppy
: WasmImportCallKind::kJSFunctionArityMatch; : WasmImportCallKind::kJSFunctionArityMatch;

View File

@ -88,7 +88,7 @@ void Context::set_previous(Context context) { set(PREVIOUS_INDEX, context); }
Object Context::next_context_link() { return get(Context::NEXT_CONTEXT_LINK); } Object Context::next_context_link() { return get(Context::NEXT_CONTEXT_LINK); }
bool Context::has_extension() { return !extension()->IsTheHole(); } bool Context::has_extension() { return !extension().IsTheHole(); }
HeapObject Context::extension() { HeapObject Context::extension() {
return HeapObject::cast(get(EXTENSION_INDEX)); return HeapObject::cast(get(EXTENSION_INDEX));
} }
@ -105,44 +105,44 @@ void Context::set_native_context(NativeContext context) {
} }
bool Context::IsFunctionContext() const { bool Context::IsFunctionContext() const {
return map()->instance_type() == FUNCTION_CONTEXT_TYPE; return map().instance_type() == FUNCTION_CONTEXT_TYPE;
} }
bool Context::IsCatchContext() const { bool Context::IsCatchContext() const {
return map()->instance_type() == CATCH_CONTEXT_TYPE; return map().instance_type() == CATCH_CONTEXT_TYPE;
} }
bool Context::IsWithContext() const { bool Context::IsWithContext() const {
return map()->instance_type() == WITH_CONTEXT_TYPE; return map().instance_type() == WITH_CONTEXT_TYPE;
} }
bool Context::IsDebugEvaluateContext() const { bool Context::IsDebugEvaluateContext() const {
return map()->instance_type() == DEBUG_EVALUATE_CONTEXT_TYPE; return map().instance_type() == DEBUG_EVALUATE_CONTEXT_TYPE;
} }
bool Context::IsAwaitContext() const { bool Context::IsAwaitContext() const {
return map()->instance_type() == AWAIT_CONTEXT_TYPE; return map().instance_type() == AWAIT_CONTEXT_TYPE;
} }
bool Context::IsBlockContext() const { bool Context::IsBlockContext() const {
return map()->instance_type() == BLOCK_CONTEXT_TYPE; return map().instance_type() == BLOCK_CONTEXT_TYPE;
} }
bool Context::IsModuleContext() const { bool Context::IsModuleContext() const {
return map()->instance_type() == MODULE_CONTEXT_TYPE; return map().instance_type() == MODULE_CONTEXT_TYPE;
} }
bool Context::IsEvalContext() const { bool Context::IsEvalContext() const {
return map()->instance_type() == EVAL_CONTEXT_TYPE; return map().instance_type() == EVAL_CONTEXT_TYPE;
} }
bool Context::IsScriptContext() const { bool Context::IsScriptContext() const {
return map()->instance_type() == SCRIPT_CONTEXT_TYPE; return map().instance_type() == SCRIPT_CONTEXT_TYPE;
} }
bool Context::HasSameSecurityTokenAs(Context that) const { bool Context::HasSameSecurityTokenAs(Context that) const {
return this->native_context()->security_token() == return this->native_context().security_token() ==
that->native_context()->security_token(); that.native_context().security_token();
} }
#define NATIVE_CONTEXT_FIELD_ACCESSORS(index, type, name) \ #define NATIVE_CONTEXT_FIELD_ACCESSORS(index, type, name) \
@ -232,7 +232,7 @@ Map Context::GetInitialJSArrayMap(ElementsKind kind) const {
if (!IsFastElementsKind(kind)) return Map(); if (!IsFastElementsKind(kind)) return Map();
DisallowHeapAllocation no_gc; DisallowHeapAllocation no_gc;
Object const initial_js_array_map = get(Context::ArrayMapIndex(kind)); Object const initial_js_array_map = get(Context::ArrayMapIndex(kind));
DCHECK(!initial_js_array_map->IsUndefined()); DCHECK(!initial_js_array_map.IsUndefined());
return Map::cast(initial_js_array_map); return Map::cast(initial_js_array_map);
} }

View File

@ -40,11 +40,11 @@ Handle<ScriptContextTable> ScriptContextTable::Extend(
bool ScriptContextTable::Lookup(Isolate* isolate, ScriptContextTable table, bool ScriptContextTable::Lookup(Isolate* isolate, ScriptContextTable table,
String name, LookupResult* result) { String name, LookupResult* result) {
DisallowHeapAllocation no_gc; DisallowHeapAllocation no_gc;
for (int i = 0; i < table->used(); i++) { for (int i = 0; i < table.used(); i++) {
Context context = table->get_context(i); Context context = table.get_context(i);
DCHECK(context->IsScriptContext()); DCHECK(context.IsScriptContext());
int slot_index = ScopeInfo::ContextSlotIndex( int slot_index = ScopeInfo::ContextSlotIndex(
context->scope_info(), name, &result->mode, &result->init_flag, context.scope_info(), name, &result->mode, &result->init_flag,
&result->maybe_assigned_flag); &result->maybe_assigned_flag);
if (slot_index >= 0) { if (slot_index >= 0) {
@ -62,26 +62,26 @@ bool Context::is_declaration_context() {
return true; return true;
} }
if (IsEvalContext()) { if (IsEvalContext()) {
return scope_info()->language_mode() == LanguageMode::kStrict; return scope_info().language_mode() == LanguageMode::kStrict;
} }
if (!IsBlockContext()) return false; if (!IsBlockContext()) return false;
return scope_info()->is_declaration_scope(); return scope_info().is_declaration_scope();
} }
Context Context::declaration_context() { Context Context::declaration_context() {
Context current = *this; Context current = *this;
while (!current->is_declaration_context()) { while (!current.is_declaration_context()) {
current = current->previous(); current = current.previous();
} }
return current; return current;
} }
Context Context::closure_context() { Context Context::closure_context() {
Context current = *this; Context current = *this;
while (!current->IsFunctionContext() && !current->IsScriptContext() && while (!current.IsFunctionContext() && !current.IsScriptContext() &&
!current->IsModuleContext() && !current->IsNativeContext() && !current.IsModuleContext() && !current.IsNativeContext() &&
!current->IsEvalContext()) { !current.IsEvalContext()) {
current = current->previous(); current = current.previous();
} }
return current; return current;
} }
@ -90,9 +90,9 @@ JSObject Context::extension_object() {
DCHECK(IsNativeContext() || IsFunctionContext() || IsBlockContext() || DCHECK(IsNativeContext() || IsFunctionContext() || IsBlockContext() ||
IsEvalContext() || IsCatchContext()); IsEvalContext() || IsCatchContext());
HeapObject object = extension(); HeapObject object = extension();
if (object->IsTheHole()) return JSObject(); if (object.IsTheHole()) return JSObject();
DCHECK(object->IsJSContextExtensionObject() || DCHECK(object.IsJSContextExtensionObject() ||
(IsNativeContext() && object->IsJSGlobalObject())); (IsNativeContext() && object.IsJSGlobalObject()));
return JSObject::cast(object); return JSObject::cast(object);
} }
@ -108,30 +108,30 @@ ScopeInfo Context::scope_info() {
Module Context::module() { Module Context::module() {
Context current = *this; Context current = *this;
while (!current->IsModuleContext()) { while (!current.IsModuleContext()) {
current = current->previous(); current = current.previous();
} }
return Module::cast(current->extension()); return Module::cast(current.extension());
} }
JSGlobalObject Context::global_object() { JSGlobalObject Context::global_object() {
return JSGlobalObject::cast(native_context()->extension()); return JSGlobalObject::cast(native_context().extension());
} }
Context Context::script_context() { Context Context::script_context() {
Context current = *this; Context current = *this;
while (!current->IsScriptContext()) { while (!current.IsScriptContext()) {
current = current->previous(); current = current.previous();
} }
return current; return current;
} }
JSGlobalProxy Context::global_proxy() { JSGlobalProxy Context::global_proxy() {
return native_context()->global_proxy_object(); return native_context().global_proxy_object();
} }
void Context::set_global_proxy(JSGlobalProxy object) { void Context::set_global_proxy(JSGlobalProxy object) {
native_context()->set_global_proxy_object(object); native_context().set_global_proxy_object(object);
} }
/** /**
@ -202,7 +202,7 @@ Handle<Object> Context::Lookup(Handle<Context> context, Handle<String> name,
// 1. Check global objects, subjects of with, and extension objects. // 1. Check global objects, subjects of with, and extension objects.
DCHECK_IMPLIES(context->IsEvalContext(), DCHECK_IMPLIES(context->IsEvalContext(),
context->extension()->IsTheHole(isolate)); context->extension().IsTheHole(isolate));
if ((context->IsNativeContext() || context->IsWithContext() || if ((context->IsNativeContext() || context->IsWithContext() ||
context->IsFunctionContext() || context->IsBlockContext()) && context->IsFunctionContext() || context->IsBlockContext()) &&
!context->extension_receiver().is_null()) { !context->extension_receiver().is_null()) {
@ -215,13 +215,13 @@ Handle<Object> Context::Lookup(Handle<Context> context, Handle<String> name,
} }
// Try other script contexts. // Try other script contexts.
ScriptContextTable script_contexts = ScriptContextTable script_contexts =
context->global_object()->native_context()->script_context_table(); context->global_object().native_context().script_context_table();
ScriptContextTable::LookupResult r; ScriptContextTable::LookupResult r;
if (ScriptContextTable::Lookup(isolate, script_contexts, *name, &r)) { if (ScriptContextTable::Lookup(isolate, script_contexts, *name, &r)) {
Context context = script_contexts->get_context(r.context_index); Context context = script_contexts.get_context(r.context_index);
if (FLAG_trace_contexts) { if (FLAG_trace_contexts) {
PrintF("=> found property in script context %d: %p\n", PrintF("=> found property in script context %d: %p\n",
r.context_index, reinterpret_cast<void*>(context->ptr())); r.context_index, reinterpret_cast<void*>(context.ptr()));
} }
*index = r.slot_index; *index = r.slot_index;
*variable_mode = r.mode; *variable_mode = r.mode;
@ -307,7 +307,7 @@ Handle<Object> Context::Lookup(Handle<Context> context, Handle<String> name,
// only the function name variable. It's conceptually (and spec-wise) // only the function name variable. It's conceptually (and spec-wise)
// in an outer scope of the function's declaration scope. // in an outer scope of the function's declaration scope.
if (follow_context_chain && context->IsFunctionContext()) { if (follow_context_chain && context->IsFunctionContext()) {
int function_index = scope_info->FunctionContextSlotIndex(*name); int function_index = scope_info.FunctionContextSlotIndex(*name);
if (function_index >= 0) { if (function_index >= 0) {
if (FLAG_trace_contexts) { if (FLAG_trace_contexts) {
PrintF("=> found intermediate function in context slot %d\n", PrintF("=> found intermediate function in context slot %d\n",
@ -318,7 +318,7 @@ Handle<Object> Context::Lookup(Handle<Context> context, Handle<String> name,
*init_flag = kCreatedInitialized; *init_flag = kCreatedInitialized;
*variable_mode = VariableMode::kConst; *variable_mode = VariableMode::kConst;
if (is_sloppy_function_name != nullptr && if (is_sloppy_function_name != nullptr &&
is_sloppy(scope_info->language_mode())) { is_sloppy(scope_info.language_mode())) {
*is_sloppy_function_name = true; *is_sloppy_function_name = true;
} }
return context; return context;
@ -331,7 +331,7 @@ Handle<Object> Context::Lookup(Handle<Context> context, Handle<String> name,
InitializationFlag flag; InitializationFlag flag;
MaybeAssignedFlag maybe_assigned_flag; MaybeAssignedFlag maybe_assigned_flag;
int cell_index = int cell_index =
scope_info->ModuleIndex(*name, &mode, &flag, &maybe_assigned_flag); scope_info.ModuleIndex(*name, &mode, &flag, &maybe_assigned_flag);
if (cell_index != 0) { if (cell_index != 0) {
if (FLAG_trace_contexts) { if (FLAG_trace_contexts) {
PrintF("=> found in module imports or exports\n"); PrintF("=> found in module imports or exports\n");
@ -349,7 +349,7 @@ Handle<Object> Context::Lookup(Handle<Context> context, Handle<String> name,
} else if (context->IsDebugEvaluateContext()) { } else if (context->IsDebugEvaluateContext()) {
// Check materialized locals. // Check materialized locals.
Object ext = context->get(EXTENSION_INDEX); Object ext = context->get(EXTENSION_INDEX);
if (ext->IsJSReceiver()) { if (ext.IsJSReceiver()) {
Handle<JSReceiver> extension(JSReceiver::cast(ext), isolate); Handle<JSReceiver> extension(JSReceiver::cast(ext), isolate);
LookupIterator it(extension, name, extension); LookupIterator it(extension, name, extension);
Maybe<bool> found = JSReceiver::HasProperty(&it); Maybe<bool> found = JSReceiver::HasProperty(&it);
@ -360,7 +360,7 @@ Handle<Object> Context::Lookup(Handle<Context> context, Handle<String> name,
} }
// Check the original context, but do not follow its context chain. // Check the original context, but do not follow its context chain.
Object obj = context->get(WRAPPED_CONTEXT_INDEX); Object obj = context->get(WRAPPED_CONTEXT_INDEX);
if (obj->IsContext()) { if (obj.IsContext()) {
Handle<Context> context(Context::cast(obj), isolate); Handle<Context> context(Context::cast(obj), isolate);
Handle<Object> result = Handle<Object> result =
Context::Lookup(context, name, DONT_FOLLOW_CHAINS, index, Context::Lookup(context, name, DONT_FOLLOW_CHAINS, index,
@ -370,9 +370,9 @@ Handle<Object> Context::Lookup(Handle<Context> context, Handle<String> name,
// Check whitelist. Names that do not pass whitelist shall only resolve // Check whitelist. Names that do not pass whitelist shall only resolve
// to with, script or native contexts up the context chain. // to with, script or native contexts up the context chain.
obj = context->get(WHITE_LIST_INDEX); obj = context->get(WHITE_LIST_INDEX);
if (obj->IsStringSet()) { if (obj.IsStringSet()) {
failed_whitelist = failed_whitelist =
failed_whitelist || !StringSet::cast(obj)->Has(isolate, name); failed_whitelist || !StringSet::cast(obj).Has(isolate, name);
} }
} }
@ -397,9 +397,9 @@ Handle<Object> Context::Lookup(Handle<Context> context, Handle<String> name,
void Context::AddOptimizedCode(Code code) { void Context::AddOptimizedCode(Code code) {
DCHECK(IsNativeContext()); DCHECK(IsNativeContext());
DCHECK(code->kind() == Code::OPTIMIZED_FUNCTION); DCHECK(code.kind() == Code::OPTIMIZED_FUNCTION);
DCHECK(code->next_code_link()->IsUndefined()); DCHECK(code.next_code_link().IsUndefined());
code->set_next_code_link(get(OPTIMIZED_CODE_LIST)); code.set_next_code_link(get(OPTIMIZED_CODE_LIST));
set(OPTIMIZED_CODE_LIST, code, UPDATE_WEAK_WRITE_BARRIER); set(OPTIMIZED_CODE_LIST, code, UPDATE_WEAK_WRITE_BARRIER);
} }
@ -459,18 +459,18 @@ bool Context::IsBootstrappingOrNativeContext(Isolate* isolate, Object object) {
// During bootstrapping we allow all objects to pass as global // During bootstrapping we allow all objects to pass as global
// objects. This is necessary to fix circular dependencies. // objects. This is necessary to fix circular dependencies.
return isolate->heap()->gc_state() != Heap::NOT_IN_GC || return isolate->heap()->gc_state() != Heap::NOT_IN_GC ||
isolate->bootstrapper()->IsActive() || object->IsNativeContext(); isolate->bootstrapper()->IsActive() || object.IsNativeContext();
} }
bool Context::IsBootstrappingOrValidParentContext(Object object, bool Context::IsBootstrappingOrValidParentContext(Object object,
Context child) { Context child) {
// During bootstrapping we allow all objects to pass as // During bootstrapping we allow all objects to pass as
// contexts. This is necessary to fix circular dependencies. // contexts. This is necessary to fix circular dependencies.
if (child->GetIsolate()->bootstrapper()->IsActive()) return true; if (child.GetIsolate()->bootstrapper()->IsActive()) return true;
if (!object->IsContext()) return false; if (!object.IsContext()) return false;
Context context = Context::cast(object); Context context = Context::cast(object);
return context->IsNativeContext() || context->IsScriptContext() || return context.IsNativeContext() || context.IsScriptContext() ||
context->IsModuleContext() || !child->IsModuleContext(); context.IsModuleContext() || !child.IsModuleContext();
} }
#endif #endif
@ -483,11 +483,11 @@ void Context::ResetErrorsThrown() {
void Context::IncrementErrorsThrown() { void Context::IncrementErrorsThrown() {
DCHECK(IsNativeContext()); DCHECK(IsNativeContext());
int previous_value = errors_thrown()->value(); int previous_value = errors_thrown().value();
set_errors_thrown(Smi::FromInt(previous_value + 1)); set_errors_thrown(Smi::FromInt(previous_value + 1));
} }
int Context::GetErrorsThrown() { return errors_thrown()->value(); } int Context::GetErrorsThrown() { return errors_thrown().value(); }
STATIC_ASSERT(Context::MIN_CONTEXT_SLOTS == 4); STATIC_ASSERT(Context::MIN_CONTEXT_SLOTS == 4);
STATIC_ASSERT(NativeContext::kScopeInfoOffset == STATIC_ASSERT(NativeContext::kScopeInfoOffset ==

View File

@ -38,10 +38,10 @@ DateCache::DateCache()
void DateCache::ResetDateCache( void DateCache::ResetDateCache(
base::TimezoneCache::TimeZoneDetection time_zone_detection) { base::TimezoneCache::TimeZoneDetection time_zone_detection) {
if (stamp_->value() >= Smi::kMaxValue) { if (stamp_.value() >= Smi::kMaxValue) {
stamp_ = Smi::zero(); stamp_ = Smi::zero();
} else { } else {
stamp_ = Smi::FromInt(stamp_->value() + 1); stamp_ = Smi::FromInt(stamp_.value() + 1);
} }
DCHECK(stamp_ != Smi::FromInt(kInvalidStamp)); DCHECK(stamp_ != Smi::FromInt(kInvalidStamp));
for (int i = 0; i < kDSTSize; ++i) { for (int i = 0; i < kDSTSize; ++i) {

View File

@ -14,7 +14,7 @@ namespace internal {
template <typename Char> template <typename Char>
bool DateParser::Parse(Isolate* isolate, Vector<Char> str, FixedArray out) { bool DateParser::Parse(Isolate* isolate, Vector<Char> str, FixedArray out) {
DCHECK(out->length() >= OUTPUT_SIZE); DCHECK(out.length() >= OUTPUT_SIZE);
InputReader<Char> in(str); InputReader<Char> in(str);
DateStringTokenizer<Char> scanner(&in); DateStringTokenizer<Char> scanner(&in);
TimeZoneComposer tz; TimeZoneComposer tz;

View File

@ -58,9 +58,9 @@ bool DateParser::DayComposer::Write(FixedArray output) {
if (!Smi::IsValid(year) || !IsMonth(month) || !IsDay(day)) return false; if (!Smi::IsValid(year) || !IsMonth(month) || !IsDay(day)) return false;
output->set(YEAR, Smi::FromInt(year)); output.set(YEAR, Smi::FromInt(year));
output->set(MONTH, Smi::FromInt(month - 1)); // 0-based output.set(MONTH, Smi::FromInt(month - 1)); // 0-based
output->set(DAY, Smi::FromInt(day)); output.set(DAY, Smi::FromInt(day));
return true; return true;
} }
@ -89,10 +89,10 @@ bool DateParser::TimeComposer::Write(FixedArray output) {
} }
} }
output->set(HOUR, Smi::FromInt(hour)); output.set(HOUR, Smi::FromInt(hour));
output->set(MINUTE, Smi::FromInt(minute)); output.set(MINUTE, Smi::FromInt(minute));
output->set(SECOND, Smi::FromInt(second)); output.set(SECOND, Smi::FromInt(second));
output->set(MILLISECOND, Smi::FromInt(millisecond)); output.set(MILLISECOND, Smi::FromInt(millisecond));
return true; return true;
} }
@ -109,9 +109,9 @@ bool DateParser::TimeZoneComposer::Write(FixedArray output) {
total_seconds = -total_seconds; total_seconds = -total_seconds;
} }
DCHECK(Smi::IsValid(total_seconds)); DCHECK(Smi::IsValid(total_seconds));
output->set(UTC_OFFSET, Smi::FromInt(total_seconds)); output.set(UTC_OFFSET, Smi::FromInt(total_seconds));
} else { } else {
output->set_null(UTC_OFFSET); output.set_null(UTC_OFFSET);
} }
return true; return true;
} }

View File

@ -49,15 +49,15 @@ class SharedToCounterMap
namespace { namespace {
int StartPosition(SharedFunctionInfo info) { int StartPosition(SharedFunctionInfo info) {
int start = info->function_token_position(); int start = info.function_token_position();
if (start == kNoSourcePosition) start = info->StartPosition(); if (start == kNoSourcePosition) start = info.StartPosition();
return start; return start;
} }
bool CompareSharedFunctionInfo(SharedFunctionInfo a, SharedFunctionInfo b) { bool CompareSharedFunctionInfo(SharedFunctionInfo a, SharedFunctionInfo b) {
int a_start = StartPosition(a); int a_start = StartPosition(a);
int b_start = StartPosition(b); int b_start = StartPosition(b);
if (a_start == b_start) return a->EndPosition() > b->EndPosition(); if (a_start == b_start) return a.EndPosition() > b.EndPosition();
return a_start < b_start; return a_start < b_start;
} }
@ -74,18 +74,18 @@ void SortBlockData(std::vector<CoverageBlock>& v) {
} }
std::vector<CoverageBlock> GetSortedBlockData(SharedFunctionInfo shared) { std::vector<CoverageBlock> GetSortedBlockData(SharedFunctionInfo shared) {
DCHECK(shared->HasCoverageInfo()); DCHECK(shared.HasCoverageInfo());
CoverageInfo coverage_info = CoverageInfo coverage_info =
CoverageInfo::cast(shared->GetDebugInfo()->coverage_info()); CoverageInfo::cast(shared.GetDebugInfo().coverage_info());
std::vector<CoverageBlock> result; std::vector<CoverageBlock> result;
if (coverage_info->SlotCount() == 0) return result; if (coverage_info.SlotCount() == 0) return result;
for (int i = 0; i < coverage_info->SlotCount(); i++) { for (int i = 0; i < coverage_info.SlotCount(); i++) {
const int start_pos = coverage_info->StartSourcePosition(i); const int start_pos = coverage_info.StartSourcePosition(i);
const int until_pos = coverage_info->EndSourcePosition(i); const int until_pos = coverage_info.EndSourcePosition(i);
const int count = coverage_info->BlockCount(i); const int count = coverage_info.BlockCount(i);
DCHECK_NE(kNoSourcePosition, start_pos); DCHECK_NE(kNoSourcePosition, start_pos);
result.emplace_back(start_pos, until_pos, count); result.emplace_back(start_pos, until_pos, count);
@ -386,13 +386,13 @@ void ClampToBinary(CoverageFunction* function) {
} }
void ResetAllBlockCounts(SharedFunctionInfo shared) { void ResetAllBlockCounts(SharedFunctionInfo shared) {
DCHECK(shared->HasCoverageInfo()); DCHECK(shared.HasCoverageInfo());
CoverageInfo coverage_info = CoverageInfo coverage_info =
CoverageInfo::cast(shared->GetDebugInfo()->coverage_info()); CoverageInfo::cast(shared.GetDebugInfo().coverage_info());
for (int i = 0; i < coverage_info->SlotCount(); i++) { for (int i = 0; i < coverage_info.SlotCount(); i++) {
coverage_info->ResetBlockCount(i); coverage_info.ResetBlockCount(i);
} }
} }
@ -521,10 +521,10 @@ std::unique_ptr<Coverage> Coverage::Collect(
isolate->factory()->feedback_vectors_for_profiling_tools()); isolate->factory()->feedback_vectors_for_profiling_tools());
for (int i = 0; i < list->Length(); i++) { for (int i = 0; i < list->Length(); i++) {
FeedbackVector vector = FeedbackVector::cast(list->Get(i)); FeedbackVector vector = FeedbackVector::cast(list->Get(i));
SharedFunctionInfo shared = vector->shared_function_info(); SharedFunctionInfo shared = vector.shared_function_info();
DCHECK(shared->IsSubjectToDebugging()); DCHECK(shared.IsSubjectToDebugging());
uint32_t count = static_cast<uint32_t>(vector->invocation_count()); uint32_t count = static_cast<uint32_t>(vector.invocation_count());
if (reset_count) vector->clear_invocation_count(); if (reset_count) vector.clear_invocation_count();
counter_map.Add(shared, count); counter_map.Add(shared, count);
} }
break; break;
@ -537,18 +537,18 @@ std::unique_ptr<Coverage> Coverage::Collect(
HeapIterator heap_iterator(isolate->heap()); HeapIterator heap_iterator(isolate->heap());
for (HeapObject current_obj = heap_iterator.next(); for (HeapObject current_obj = heap_iterator.next();
!current_obj.is_null(); current_obj = heap_iterator.next()) { !current_obj.is_null(); current_obj = heap_iterator.next()) {
if (!current_obj->IsJSFunction()) continue; if (!current_obj.IsJSFunction()) continue;
JSFunction func = JSFunction::cast(current_obj); JSFunction func = JSFunction::cast(current_obj);
SharedFunctionInfo shared = func->shared(); SharedFunctionInfo shared = func.shared();
if (!shared->IsSubjectToDebugging()) continue; if (!shared.IsSubjectToDebugging()) continue;
if (!(func->has_feedback_vector() || if (!(func.has_feedback_vector() ||
func->has_closure_feedback_cell_array())) func.has_closure_feedback_cell_array()))
continue; continue;
uint32_t count = 0; uint32_t count = 0;
if (func->has_feedback_vector()) { if (func.has_feedback_vector()) {
count = static_cast<uint32_t>( count =
func->feedback_vector()->invocation_count()); static_cast<uint32_t>(func.feedback_vector().invocation_count());
} else if (func->raw_feedback_cell()->interrupt_budget() < } else if (func.raw_feedback_cell().interrupt_budget() <
FLAG_budget_for_feedback_vector_allocation) { FLAG_budget_for_feedback_vector_allocation) {
// We haven't allocated feedback vector, but executed the function // We haven't allocated feedback vector, but executed the function
// atleast once. We don't have precise invocation count here. // atleast once. We don't have precise invocation count here.
@ -562,7 +562,7 @@ std::unique_ptr<Coverage> Coverage::Collect(
// vector wasn't allocated yet and the function's interrupt budget wasn't // vector wasn't allocated yet and the function's interrupt budget wasn't
// updated (i.e. it didn't execute return / jump). // updated (i.e. it didn't execute return / jump).
for (JavaScriptFrameIterator it(isolate); !it.done(); it.Advance()) { for (JavaScriptFrameIterator it(isolate); !it.done(); it.Advance()) {
SharedFunctionInfo shared = it.frame()->function()->shared(); SharedFunctionInfo shared = it.frame()->function().shared();
if (counter_map.Get(shared) != 0) continue; if (counter_map.Get(shared) != 0) continue;
counter_map.Add(shared, 1); counter_map.Add(shared, 1);
} }
@ -576,7 +576,7 @@ std::unique_ptr<Coverage> Coverage::Collect(
Script::Iterator scripts(isolate); Script::Iterator scripts(isolate);
for (Script script = scripts.Next(); !script.is_null(); for (Script script = scripts.Next(); !script.is_null();
script = scripts.Next()) { script = scripts.Next()) {
if (!script->IsUserJavaScript()) continue; if (!script.IsUserJavaScript()) continue;
// Create and add new script data. // Create and add new script data.
Handle<Script> script_handle(script, isolate); Handle<Script> script_handle(script, isolate);
@ -601,7 +601,7 @@ std::unique_ptr<Coverage> Coverage::Collect(
// Use sorted list to reconstruct function nesting. // Use sorted list to reconstruct function nesting.
for (SharedFunctionInfo info : sorted) { for (SharedFunctionInfo info : sorted) {
int start = StartPosition(info); int start = StartPosition(info);
int end = info->EndPosition(); int end = info.EndPosition();
uint32_t count = counter_map.Get(info); uint32_t count = counter_map.Get(info);
// Find the correct outer function based on start position. // Find the correct outer function based on start position.
while (!nesting.empty() && functions->at(nesting.back()).end <= start) { while (!nesting.empty() && functions->at(nesting.back()).end <= start) {
@ -614,8 +614,8 @@ std::unique_ptr<Coverage> Coverage::Collect(
break; break;
case v8::debug::CoverageMode::kBlockBinary: case v8::debug::CoverageMode::kBlockBinary:
case v8::debug::CoverageMode::kPreciseBinary: case v8::debug::CoverageMode::kPreciseBinary:
count = info->has_reported_binary_coverage() ? 0 : 1; count = info.has_reported_binary_coverage() ? 0 : 1;
info->set_has_reported_binary_coverage(true); info.set_has_reported_binary_coverage(true);
break; break;
case v8::debug::CoverageMode::kBestEffort: case v8::debug::CoverageMode::kBestEffort:
count = 1; count = 1;
@ -623,10 +623,10 @@ std::unique_ptr<Coverage> Coverage::Collect(
} }
} }
Handle<String> name(info->DebugName(), isolate); Handle<String> name(info.DebugName(), isolate);
CoverageFunction function(start, end, count, name); CoverageFunction function(start, end, count, name);
if (IsBlockMode(collectionMode) && info->HasCoverageInfo()) { if (IsBlockMode(collectionMode) && info.HasCoverageInfo()) {
CollectBlockCoverage(&function, info, collectionMode); CollectBlockCoverage(&function, info, collectionMode);
} }
@ -681,21 +681,21 @@ void Coverage::SelectMode(Isolate* isolate, debug::CoverageMode mode) {
HeapIterator heap_iterator(isolate->heap()); HeapIterator heap_iterator(isolate->heap());
for (HeapObject o = heap_iterator.next(); !o.is_null(); for (HeapObject o = heap_iterator.next(); !o.is_null();
o = heap_iterator.next()) { o = heap_iterator.next()) {
if (o->IsJSFunction()) { if (o.IsJSFunction()) {
JSFunction func = JSFunction::cast(o); JSFunction func = JSFunction::cast(o);
if (func->has_closure_feedback_cell_array()) { if (func.has_closure_feedback_cell_array()) {
funcs_needing_feedback_vector.push_back( funcs_needing_feedback_vector.push_back(
Handle<JSFunction>(func, isolate)); Handle<JSFunction>(func, isolate));
} }
} else if (IsBinaryMode(mode) && o->IsSharedFunctionInfo()) { } else if (IsBinaryMode(mode) && o.IsSharedFunctionInfo()) {
// If collecting binary coverage, reset // If collecting binary coverage, reset
// SFI::has_reported_binary_coverage to avoid optimizing / inlining // SFI::has_reported_binary_coverage to avoid optimizing / inlining
// functions before they have reported coverage. // functions before they have reported coverage.
SharedFunctionInfo shared = SharedFunctionInfo::cast(o); SharedFunctionInfo shared = SharedFunctionInfo::cast(o);
shared->set_has_reported_binary_coverage(false); shared.set_has_reported_binary_coverage(false);
} else if (o->IsFeedbackVector()) { } else if (o.IsFeedbackVector()) {
// In any case, clear any collected invocation counts. // In any case, clear any collected invocation counts.
FeedbackVector::cast(o)->clear_invocation_count(); FeedbackVector::cast(o).clear_invocation_count();
} }
} }
} }

View File

@ -90,7 +90,7 @@ MaybeHandle<Object> DebugEvaluate::WithTopmostArguments(Isolate* isolate,
// Get context and receiver. // Get context and receiver.
Handle<Context> native_context( Handle<Context> native_context(
Context::cast(it.frame()->context())->native_context(), isolate); Context::cast(it.frame()->context()).native_context(), isolate);
// Materialize arguments as property on an extension object. // Materialize arguments as property on an extension object.
Handle<JSObject> materialized = factory->NewJSObjectWithNullProto(); Handle<JSObject> materialized = factory->NewJSObjectWithNullProto();
@ -115,7 +115,7 @@ MaybeHandle<Object> DebugEvaluate::WithTopmostArguments(Isolate* isolate,
factory->NewDebugEvaluateContext(native_context, scope_info, materialized, factory->NewDebugEvaluateContext(native_context, scope_info, materialized,
Handle<Context>(), Handle<StringSet>()); Handle<Context>(), Handle<StringSet>());
Handle<SharedFunctionInfo> outer_info( Handle<SharedFunctionInfo> outer_info(
native_context->empty_function()->shared(), isolate); native_context->empty_function().shared(), isolate);
Handle<JSObject> receiver(native_context->global_proxy(), isolate); Handle<JSObject> receiver(native_context->global_proxy(), isolate);
const bool throw_on_side_effect = false; const bool throw_on_side_effect = false;
MaybeHandle<Object> maybe_result = MaybeHandle<Object> maybe_result =
@ -226,7 +226,7 @@ void DebugEvaluate::ContextBuilder::UpdateValues() {
.ToHandleChecked(); .ToHandleChecked();
for (int i = 0; i < keys->length(); i++) { for (int i = 0; i < keys->length(); i++) {
DCHECK(keys->get(i)->IsString()); DCHECK(keys->get(i).IsString());
Handle<String> key(String::cast(keys->get(i)), isolate_); Handle<String> key(String::cast(keys->get(i)), isolate_);
Handle<Object> value = Handle<Object> value =
JSReceiver::GetDataProperty(element.materialized_object, key); JSReceiver::GetDataProperty(element.materialized_object, key);
@ -839,7 +839,7 @@ DebugInfo::SideEffectState DebugEvaluate::FunctionGetSideEffectState(
Isolate* isolate, Handle<SharedFunctionInfo> info) { Isolate* isolate, Handle<SharedFunctionInfo> info) {
if (FLAG_trace_side_effect_free_debug_evaluate) { if (FLAG_trace_side_effect_free_debug_evaluate) {
PrintF("[debug-evaluate] Checking function %s for side effect.\n", PrintF("[debug-evaluate] Checking function %s for side effect.\n",
info->DebugName()->ToCString().get()); info->DebugName().ToCString().get());
} }
DCHECK(info->is_compiled()); DCHECK(info->is_compiled());
@ -880,8 +880,8 @@ DebugInfo::SideEffectState DebugEvaluate::FunctionGetSideEffectState(
return requires_runtime_checks ? DebugInfo::kRequiresRuntimeChecks return requires_runtime_checks ? DebugInfo::kRequiresRuntimeChecks
: DebugInfo::kHasNoSideEffect; : DebugInfo::kHasNoSideEffect;
} else if (info->IsApiFunction()) { } else if (info->IsApiFunction()) {
if (info->GetCode()->is_builtin()) { if (info->GetCode().is_builtin()) {
return info->GetCode()->builtin_index() == Builtins::kHandleApiCall return info->GetCode().builtin_index() == Builtins::kHandleApiCall
? DebugInfo::kHasNoSideEffect ? DebugInfo::kHasNoSideEffect
: DebugInfo::kHasSideEffects; : DebugInfo::kHasSideEffects;
} }
@ -1024,9 +1024,9 @@ void DebugEvaluate::VerifyTransitiveBuiltins(Isolate* isolate) {
DCHECK(RelocInfo::IsCodeTargetMode(rinfo->rmode())); DCHECK(RelocInfo::IsCodeTargetMode(rinfo->rmode()));
Code callee_code = isolate->heap()->GcSafeFindCodeForInnerPointer( Code callee_code = isolate->heap()->GcSafeFindCodeForInnerPointer(
rinfo->target_address()); rinfo->target_address());
if (!callee_code->is_builtin()) continue; if (!callee_code.is_builtin()) continue;
Builtins::Name callee = Builtins::Name callee =
static_cast<Builtins::Name>(callee_code->builtin_index()); static_cast<Builtins::Name>(callee_code.builtin_index());
if (BuiltinGetSideEffectState(callee) == DebugInfo::kHasNoSideEffect) { if (BuiltinGetSideEffectState(callee) == DebugInfo::kHasNoSideEffect) {
continue; continue;
} }

View File

@ -47,7 +47,7 @@ FrameInspector::FrameInspector(StandardFrame* frame, int inlined_frame_index,
wasm_interpreted_frame_ = wasm_interpreted_frame_ =
WasmInterpreterEntryFrame::cast(frame_) WasmInterpreterEntryFrame::cast(frame_)
->debug_info() ->debug_info()
->GetInterpretedFrame(frame_->fp(), inlined_frame_index); .GetInterpretedFrame(frame_->fp(), inlined_frame_index);
DCHECK(wasm_interpreted_frame_); DCHECK(wasm_interpreted_frame_);
} }
} }
@ -97,9 +97,9 @@ bool FrameInspector::ParameterIsShadowedByContextLocal(
RedirectActiveFunctions::RedirectActiveFunctions(SharedFunctionInfo shared, RedirectActiveFunctions::RedirectActiveFunctions(SharedFunctionInfo shared,
Mode mode) Mode mode)
: shared_(shared), mode_(mode) { : shared_(shared), mode_(mode) {
DCHECK(shared->HasBytecodeArray()); DCHECK(shared.HasBytecodeArray());
if (mode == Mode::kUseDebugBytecode) { if (mode == Mode::kUseDebugBytecode) {
DCHECK(shared->HasDebugInfo()); DCHECK(shared.HasDebugInfo());
} }
} }
@ -109,12 +109,12 @@ void RedirectActiveFunctions::VisitThread(Isolate* isolate,
JavaScriptFrame* frame = it.frame(); JavaScriptFrame* frame = it.frame();
JSFunction function = frame->function(); JSFunction function = frame->function();
if (!frame->is_interpreted()) continue; if (!frame->is_interpreted()) continue;
if (function->shared() != shared_) continue; if (function.shared() != shared_) continue;
InterpretedFrame* interpreted_frame = InterpretedFrame* interpreted_frame =
reinterpret_cast<InterpretedFrame*>(frame); reinterpret_cast<InterpretedFrame*>(frame);
BytecodeArray bytecode = mode_ == Mode::kUseDebugBytecode BytecodeArray bytecode = mode_ == Mode::kUseDebugBytecode
? shared_->GetDebugInfo()->DebugBytecodeArray() ? shared_.GetDebugInfo().DebugBytecodeArray()
: shared_->GetBytecodeArray(); : shared_.GetBytecodeArray();
interpreted_frame->PatchBytecodeArray(bytecode); interpreted_frame->PatchBytecodeArray(bytecode);
} }
} }

View File

@ -47,8 +47,8 @@ Handle<Object> ScopeIterator::GetFunctionDebugName() const {
if (!context_->IsNativeContext()) { if (!context_->IsNativeContext()) {
DisallowHeapAllocation no_gc; DisallowHeapAllocation no_gc;
ScopeInfo closure_info = context_->closure_context()->scope_info(); ScopeInfo closure_info = context_->closure_context().scope_info();
Handle<String> debug_name(closure_info->FunctionDebugName(), isolate_); Handle<String> debug_name(closure_info.FunctionDebugName(), isolate_);
if (debug_name->length() > 0) return debug_name; if (debug_name->length() > 0) return debug_name;
} }
return isolate_->factory()->undefined_value(); return isolate_->factory()->undefined_value();
@ -56,11 +56,11 @@ Handle<Object> ScopeIterator::GetFunctionDebugName() const {
ScopeIterator::ScopeIterator(Isolate* isolate, Handle<JSFunction> function) ScopeIterator::ScopeIterator(Isolate* isolate, Handle<JSFunction> function)
: isolate_(isolate), context_(function->context(), isolate) { : isolate_(isolate), context_(function->context(), isolate) {
if (!function->shared()->IsSubjectToDebugging()) { if (!function->shared().IsSubjectToDebugging()) {
context_ = Handle<Context>(); context_ = Handle<Context>();
return; return;
} }
script_ = handle(Script::cast(function->shared()->script()), isolate); script_ = handle(Script::cast(function->shared().script()), isolate);
UnwrapEvaluationContext(); UnwrapEvaluationContext();
} }
@ -70,8 +70,8 @@ ScopeIterator::ScopeIterator(Isolate* isolate,
generator_(generator), generator_(generator),
function_(generator->function(), isolate), function_(generator->function(), isolate),
context_(generator->context(), isolate), context_(generator->context(), isolate),
script_(Script::cast(function_->shared()->script()), isolate) { script_(Script::cast(function_->shared().script()), isolate) {
CHECK(function_->shared()->IsSubjectToDebugging()); CHECK(function_->shared().IsSubjectToDebugging());
TryParseAndRetrieveScopes(DEFAULT); TryParseAndRetrieveScopes(DEFAULT);
} }
@ -88,7 +88,7 @@ void ScopeIterator::TryParseAndRetrieveScopes(ScopeIterator::Option option) {
// Catch the case when the debugger stops in an internal function. // Catch the case when the debugger stops in an internal function.
Handle<SharedFunctionInfo> shared_info(function_->shared(), isolate_); Handle<SharedFunctionInfo> shared_info(function_->shared(), isolate_);
Handle<ScopeInfo> scope_info(shared_info->scope_info(), isolate_); Handle<ScopeInfo> scope_info(shared_info->scope_info(), isolate_);
if (shared_info->script()->IsUndefined(isolate_)) { if (shared_info->script().IsUndefined(isolate_)) {
current_scope_ = closure_scope_ = nullptr; current_scope_ = closure_scope_ = nullptr;
context_ = handle(function_->context(), isolate_); context_ = handle(function_->context(), isolate_);
function_ = Handle<JSFunction>(); function_ = Handle<JSFunction>();
@ -191,14 +191,14 @@ void ScopeIterator::UnwrapEvaluationContext() {
if (!context_->IsDebugEvaluateContext()) return; if (!context_->IsDebugEvaluateContext()) return;
Context current = *context_; Context current = *context_;
do { do {
Object wrapped = current->get(Context::WRAPPED_CONTEXT_INDEX); Object wrapped = current.get(Context::WRAPPED_CONTEXT_INDEX);
if (wrapped->IsContext()) { if (wrapped.IsContext()) {
current = Context::cast(wrapped); current = Context::cast(wrapped);
} else { } else {
DCHECK(!current->previous().is_null()); DCHECK(!current.previous().is_null());
current = current->previous(); current = current.previous();
} }
} while (current->IsDebugEvaluateContext()); } while (current.IsDebugEvaluateContext());
context_ = handle(current, isolate_); context_ = handle(current, isolate_);
} }
@ -232,13 +232,13 @@ bool ScopeIterator::HasPositionInfo() {
int ScopeIterator::start_position() { int ScopeIterator::start_position() {
if (InInnerScope()) return current_scope_->start_position(); if (InInnerScope()) return current_scope_->start_position();
if (context_->IsNativeContext()) return 0; if (context_->IsNativeContext()) return 0;
return context_->closure_context()->scope_info()->StartPosition(); return context_->closure_context().scope_info().StartPosition();
} }
int ScopeIterator::end_position() { int ScopeIterator::end_position() {
if (InInnerScope()) return current_scope_->end_position(); if (InInnerScope()) return current_scope_->end_position();
if (context_->IsNativeContext()) return 0; if (context_->IsNativeContext()) return 0;
return context_->closure_context()->scope_info()->EndPosition(); return context_->closure_context().scope_info().EndPosition();
} }
bool ScopeIterator::DeclaresLocals(Mode mode) const { bool ScopeIterator::DeclaresLocals(Mode mode) const {
@ -341,7 +341,7 @@ ScopeIterator::ScopeType ScopeIterator::Type() const {
UNREACHABLE(); UNREACHABLE();
} }
if (context_->IsNativeContext()) { if (context_->IsNativeContext()) {
DCHECK(context_->global_object()->IsJSGlobalObject()); DCHECK(context_->global_object().IsJSGlobalObject());
// If we are at the native context and have not yet seen script scope, // If we are at the native context and have not yet seen script scope,
// fake it. // fake it.
return seen_script_scope_ ? ScopeTypeGlobal : ScopeTypeScript; return seen_script_scope_ ? ScopeTypeGlobal : ScopeTypeScript;
@ -481,13 +481,13 @@ void ScopeIterator::DebugPrint() {
case ScopeIterator::ScopeTypeWith: case ScopeIterator::ScopeTypeWith:
os << "With:\n"; os << "With:\n";
context_->extension()->Print(os); context_->extension().Print(os);
break; break;
case ScopeIterator::ScopeTypeCatch: case ScopeIterator::ScopeTypeCatch:
os << "Catch:\n"; os << "Catch:\n";
context_->extension()->Print(os); context_->extension().Print(os);
context_->get(Context::THROWN_OBJECT_INDEX)->Print(os); context_->get(Context::THROWN_OBJECT_INDEX).Print(os);
break; break;
case ScopeIterator::ScopeTypeClosure: case ScopeIterator::ScopeTypeClosure:
@ -502,10 +502,8 @@ void ScopeIterator::DebugPrint() {
case ScopeIterator::ScopeTypeScript: case ScopeIterator::ScopeTypeScript:
os << "Script:\n"; os << "Script:\n";
context_->global_object() context_->global_object().native_context().script_context_table().Print(
->native_context() os);
->script_context_table()
->Print(os);
break; break;
default: default:
@ -521,7 +519,7 @@ int ScopeIterator::GetSourcePosition() {
} else { } else {
DCHECK(!generator_.is_null()); DCHECK(!generator_.is_null());
SharedFunctionInfo::EnsureSourcePositionsAvailable( SharedFunctionInfo::EnsureSourcePositionsAvailable(
isolate_, handle(generator_->function()->shared(), isolate_)); isolate_, handle(generator_->function().shared(), isolate_));
return generator_->source_position(); return generator_->source_position();
} }
} }
@ -557,7 +555,7 @@ void ScopeIterator::RetrieveScopeChain(DeclarationScope* scope) {
void ScopeIterator::VisitScriptScope(const Visitor& visitor) const { void ScopeIterator::VisitScriptScope(const Visitor& visitor) const {
Handle<JSGlobalObject> global(context_->global_object(), isolate_); Handle<JSGlobalObject> global(context_->global_object(), isolate_);
Handle<ScriptContextTable> script_contexts( Handle<ScriptContextTable> script_contexts(
global->native_context()->script_context_table(), isolate_); global->native_context().script_context_table(), isolate_);
// Skip the first script since that just declares 'this'. // Skip the first script since that just declares 'this'.
for (int context_index = 1; context_index < script_contexts->used(); for (int context_index = 1; context_index < script_contexts->used();
@ -576,7 +574,7 @@ void ScopeIterator::VisitModuleScope(const Visitor& visitor) const {
if (VisitContextLocals(visitor, scope_info, context_)) return; if (VisitContextLocals(visitor, scope_info, context_)) return;
int count_index = scope_info->ModuleVariableCountIndex(); int count_index = scope_info->ModuleVariableCountIndex();
int module_variable_count = Smi::cast(scope_info->get(count_index))->value(); int module_variable_count = Smi::cast(scope_info->get(count_index)).value();
Handle<Module> module(context_->module(), isolate_); Handle<Module> module(context_->module(), isolate_);
@ -645,8 +643,8 @@ bool ScopeIterator::VisitLocals(const Visitor& visitor, Mode mode) const {
DCHECK(!generator_.is_null()); DCHECK(!generator_.is_null());
FixedArray parameters_and_registers = FixedArray parameters_and_registers =
generator_->parameters_and_registers(); generator_->parameters_and_registers();
DCHECK_LT(index, parameters_and_registers->length()); DCHECK_LT(index, parameters_and_registers.length());
value = handle(parameters_and_registers->get(index), isolate_); value = handle(parameters_and_registers.get(index), isolate_);
} else { } else {
value = frame_inspector_->GetParameter(index); value = frame_inspector_->GetParameter(index);
@ -664,10 +662,10 @@ bool ScopeIterator::VisitLocals(const Visitor& visitor, Mode mode) const {
FixedArray parameters_and_registers = FixedArray parameters_and_registers =
generator_->parameters_and_registers(); generator_->parameters_and_registers();
int parameter_count = int parameter_count =
function_->shared()->scope_info()->ParameterCount(); function_->shared().scope_info().ParameterCount();
index += parameter_count; index += parameter_count;
DCHECK_LT(index, parameters_and_registers->length()); DCHECK_LT(index, parameters_and_registers.length());
value = handle(parameters_and_registers->get(index), isolate_); value = handle(parameters_and_registers.get(index), isolate_);
if (value->IsTheHole(isolate_)) { if (value->IsTheHole(isolate_)) {
value = isolate_->factory()->undefined_value(); value = isolate_->factory()->undefined_value();
} }
@ -715,7 +713,7 @@ bool ScopeIterator::VisitLocals(const Visitor& visitor, Mode mode) const {
// a proxy, return an empty object. // a proxy, return an empty object.
Handle<JSObject> ScopeIterator::WithContextExtension() { Handle<JSObject> ScopeIterator::WithContextExtension() {
DCHECK(context_->IsWithContext()); DCHECK(context_->IsWithContext());
if (context_->extension_receiver()->IsJSProxy()) { if (context_->extension_receiver().IsJSProxy()) {
return isolate_->factory()->NewJSObjectWithNullProto(); return isolate_->factory()->NewJSObjectWithNullProto();
} }
return handle(JSObject::cast(context_->extension_receiver()), isolate_); return handle(JSObject::cast(context_->extension_receiver()), isolate_);
@ -761,7 +759,7 @@ void ScopeIterator::VisitLocalScope(const Visitor& visitor, Mode mode) const {
DCHECK(!context_->IsScriptContext()); DCHECK(!context_->IsScriptContext());
DCHECK(!context_->IsNativeContext()); DCHECK(!context_->IsNativeContext());
DCHECK(!context_->IsWithContext()); DCHECK(!context_->IsWithContext());
if (!context_->scope_info()->CallsSloppyEval()) return; if (!context_->scope_info().CallsSloppyEval()) return;
if (context_->extension_object().is_null()) return; if (context_->extension_object().is_null()) return;
Handle<JSObject> extension(context_->extension_object(), isolate_); Handle<JSObject> extension(context_->extension_object(), isolate_);
Handle<FixedArray> keys = Handle<FixedArray> keys =
@ -771,7 +769,7 @@ void ScopeIterator::VisitLocalScope(const Visitor& visitor, Mode mode) const {
for (int i = 0; i < keys->length(); i++) { for (int i = 0; i < keys->length(); i++) {
// Names of variables introduced by eval are strings. // Names of variables introduced by eval are strings.
DCHECK(keys->get(i)->IsString()); DCHECK(keys->get(i).IsString());
Handle<String> key(String::cast(keys->get(i)), isolate_); Handle<String> key(String::cast(keys->get(i)), isolate_);
Handle<Object> value = JSReceiver::GetDataProperty(extension, key); Handle<Object> value = JSReceiver::GetDataProperty(extension, key);
if (visitor(key, value)) return; if (visitor(key, value)) return;
@ -817,7 +815,7 @@ bool ScopeIterator::SetLocalVariableValue(Handle<String> variable_name,
// Set the variable in the suspended generator. // Set the variable in the suspended generator.
DCHECK(!generator_.is_null()); DCHECK(!generator_.is_null());
int parameter_count = int parameter_count =
function_->shared()->scope_info()->ParameterCount(); function_->shared().scope_info().ParameterCount();
index += parameter_count; index += parameter_count;
Handle<FixedArray> parameters_and_registers( Handle<FixedArray> parameters_and_registers(
generator_->parameters_and_registers(), isolate_); generator_->parameters_and_registers(), isolate_);
@ -854,7 +852,7 @@ bool ScopeIterator::SetContextExtensionValue(Handle<String> variable_name,
Handle<Object> new_value) { Handle<Object> new_value) {
if (!context_->has_extension()) return false; if (!context_->has_extension()) return false;
DCHECK(context_->extension_object()->IsJSContextExtensionObject()); DCHECK(context_->extension_object().IsJSContextExtensionObject());
Handle<JSObject> ext(context_->extension_object(), isolate_); Handle<JSObject> ext(context_->extension_object(), isolate_);
LookupIterator it(isolate_, ext, variable_name, LookupIterator::OWN); LookupIterator it(isolate_, ext, variable_name, LookupIterator::OWN);
Maybe<bool> maybe = JSReceiver::HasOwnProperty(ext, variable_name); Maybe<bool> maybe = JSReceiver::HasOwnProperty(ext, variable_name);
@ -887,7 +885,7 @@ bool ScopeIterator::SetModuleVariableValue(Handle<String> variable_name,
VariableMode mode; VariableMode mode;
InitializationFlag init_flag; InitializationFlag init_flag;
MaybeAssignedFlag maybe_assigned_flag; MaybeAssignedFlag maybe_assigned_flag;
cell_index = context_->scope_info()->ModuleIndex( cell_index = context_->scope_info().ModuleIndex(
*variable_name, &mode, &init_flag, &maybe_assigned_flag); *variable_name, &mode, &init_flag, &maybe_assigned_flag);
// Setting imports is currently not supported. // Setting imports is currently not supported.
@ -904,7 +902,7 @@ bool ScopeIterator::SetModuleVariableValue(Handle<String> variable_name,
bool ScopeIterator::SetScriptVariableValue(Handle<String> variable_name, bool ScopeIterator::SetScriptVariableValue(Handle<String> variable_name,
Handle<Object> new_value) { Handle<Object> new_value) {
Handle<ScriptContextTable> script_contexts( Handle<ScriptContextTable> script_contexts(
context_->global_object()->native_context()->script_context_table(), context_->global_object().native_context().script_context_table(),
isolate_); isolate_);
ScriptContextTable::LookupResult lookup_result; ScriptContextTable::LookupResult lookup_result;
if (ScriptContextTable::Lookup(isolate_, *script_contexts, *variable_name, if (ScriptContextTable::Lookup(isolate_, *script_contexts, *variable_name,

View File

@ -69,9 +69,8 @@ int DebugStackTraceIterator::GetContextId() const {
DCHECK(!Done()); DCHECK(!Done());
Handle<Object> context = frame_inspector_->GetContext(); Handle<Object> context = frame_inspector_->GetContext();
if (context->IsContext()) { if (context->IsContext()) {
Object value = Object value = Context::cast(*context).native_context().debug_context_id();
Context::cast(*context)->native_context()->debug_context_id(); if (value.IsSmi()) return Smi::ToInt(value);
if (value->IsSmi()) return Smi::ToInt(value);
} }
return 0; return 0;
} }
@ -79,7 +78,7 @@ int DebugStackTraceIterator::GetContextId() const {
v8::MaybeLocal<v8::Value> DebugStackTraceIterator::GetReceiver() const { v8::MaybeLocal<v8::Value> DebugStackTraceIterator::GetReceiver() const {
DCHECK(!Done()); DCHECK(!Done());
if (frame_inspector_->IsJavaScript() && if (frame_inspector_->IsJavaScript() &&
frame_inspector_->GetFunction()->shared()->kind() == kArrowFunction) { frame_inspector_->GetFunction()->shared().kind() == kArrowFunction) {
// FrameInspector is not able to get receiver for arrow function. // FrameInspector is not able to get receiver for arrow function.
// So let's try to fetch it using same logic as is used to retrieve 'this' // So let's try to fetch it using same logic as is used to retrieve 'this'
// during DebugEvaluate::Local. // during DebugEvaluate::Local.

View File

@ -26,7 +26,7 @@ std::unique_ptr<TypeProfile> TypeProfile::Collect(Isolate* isolate) {
for (Script script = scripts.Next(); !script.is_null(); for (Script script = scripts.Next(); !script.is_null();
script = scripts.Next()) { script = scripts.Next()) {
if (!script->IsUserJavaScript()) { if (!script.IsUserJavaScript()) {
continue; continue;
} }
@ -39,21 +39,20 @@ std::unique_ptr<TypeProfile> TypeProfile::Collect(Isolate* isolate) {
// the list multiple times. // the list multiple times.
for (int i = 0; i < list->Length(); i++) { for (int i = 0; i < list->Length(); i++) {
FeedbackVector vector = FeedbackVector::cast(list->Get(i)); FeedbackVector vector = FeedbackVector::cast(list->Get(i));
SharedFunctionInfo info = vector->shared_function_info(); SharedFunctionInfo info = vector.shared_function_info();
DCHECK(info->IsSubjectToDebugging()); DCHECK(info.IsSubjectToDebugging());
// Match vectors with script. // Match vectors with script.
if (script != info->script()) { if (script != info.script()) {
continue; continue;
} }
if (!info->HasFeedbackMetadata() || if (!info.HasFeedbackMetadata() || info.feedback_metadata().is_empty() ||
info->feedback_metadata()->is_empty() || !info.feedback_metadata().HasTypeProfileSlot()) {
!info->feedback_metadata()->HasTypeProfileSlot()) {
continue; continue;
} }
FeedbackSlot slot = vector->GetTypeProfileSlot(); FeedbackSlot slot = vector.GetTypeProfileSlot();
FeedbackNexus nexus(vector, slot); FeedbackNexus nexus(vector, slot);
Handle<String> name(info->DebugName(), isolate); Handle<String> name(info.DebugName(), isolate);
std::vector<int> source_positions = nexus.GetSourcePositions(); std::vector<int> source_positions = nexus.GetSourcePositions();
for (int position : source_positions) { for (int position : source_positions) {
DCHECK_GE(position, 0); DCHECK_GE(position, 0);
@ -89,10 +88,10 @@ void TypeProfile::SelectMode(Isolate* isolate, debug::TypeProfileMode mode) {
for (int i = 0; i < list->Length(); i++) { for (int i = 0; i < list->Length(); i++) {
FeedbackVector vector = FeedbackVector::cast(list->Get(i)); FeedbackVector vector = FeedbackVector::cast(list->Get(i));
SharedFunctionInfo info = vector->shared_function_info(); SharedFunctionInfo info = vector.shared_function_info();
DCHECK(info->IsSubjectToDebugging()); DCHECK(info.IsSubjectToDebugging());
if (info->feedback_metadata()->HasTypeProfileSlot()) { if (info.feedback_metadata().HasTypeProfileSlot()) {
FeedbackSlot slot = vector->GetTypeProfileSlot(); FeedbackSlot slot = vector.GetTypeProfileSlot();
FeedbackNexus nexus(vector, slot); FeedbackNexus nexus(vector, slot);
nexus.ResetTypeProfile(); nexus.ResetTypeProfile();
} }

View File

@ -202,8 +202,8 @@ BreakIterator::BreakIterator(Handle<DebugInfo> debug_info)
: debug_info_(debug_info), : debug_info_(debug_info),
break_index_(-1), break_index_(-1),
source_position_iterator_( source_position_iterator_(
debug_info->DebugBytecodeArray()->SourcePositionTable()) { debug_info->DebugBytecodeArray().SourcePositionTable()) {
position_ = debug_info->shared()->StartPosition(); position_ = debug_info->shared().StartPosition();
statement_position_ = position_; statement_position_ = position_;
// There is at least one break location. // There is at least one break location.
DCHECK(!Done()); DCHECK(!Done());
@ -251,12 +251,12 @@ void BreakIterator::Next() {
DebugBreakType BreakIterator::GetDebugBreakType() { DebugBreakType BreakIterator::GetDebugBreakType() {
BytecodeArray bytecode_array = debug_info_->OriginalBytecodeArray(); BytecodeArray bytecode_array = debug_info_->OriginalBytecodeArray();
interpreter::Bytecode bytecode = interpreter::Bytecode bytecode =
interpreter::Bytecodes::FromByte(bytecode_array->get(code_offset())); interpreter::Bytecodes::FromByte(bytecode_array.get(code_offset()));
// Make sure we read the actual bytecode, not a prefix scaling bytecode. // Make sure we read the actual bytecode, not a prefix scaling bytecode.
if (interpreter::Bytecodes::IsPrefixScalingBytecode(bytecode)) { if (interpreter::Bytecodes::IsPrefixScalingBytecode(bytecode)) {
bytecode = interpreter::Bytecodes::FromByte( bytecode =
bytecode_array->get(code_offset() + 1)); interpreter::Bytecodes::FromByte(bytecode_array.get(code_offset() + 1));
} }
if (bytecode == interpreter::Bytecode::kDebugger) { if (bytecode == interpreter::Bytecode::kDebugger) {
@ -296,7 +296,7 @@ void BreakIterator::ClearDebugBreak() {
DCHECK(debug_break_type >= DEBUG_BREAK_SLOT); DCHECK(debug_break_type >= DEBUG_BREAK_SLOT);
BytecodeArray bytecode_array = debug_info_->DebugBytecodeArray(); BytecodeArray bytecode_array = debug_info_->DebugBytecodeArray();
BytecodeArray original = debug_info_->OriginalBytecodeArray(); BytecodeArray original = debug_info_->OriginalBytecodeArray();
bytecode_array->set(code_offset(), original->get(code_offset())); bytecode_array.set(code_offset(), original.get(code_offset()));
} }
BreakLocation BreakIterator::GetBreakLocation() { BreakLocation BreakIterator::GetBreakLocation() {
@ -541,8 +541,8 @@ bool Debug::IsMutedAtCurrentLocation(JavaScriptFrame* frame) {
FrameSummary summary = FrameSummary::GetTop(frame); FrameSummary summary = FrameSummary::GetTop(frame);
DCHECK(!summary.IsWasm()); DCHECK(!summary.IsWasm());
Handle<JSFunction> function = summary.AsJavaScript().function(); Handle<JSFunction> function = summary.AsJavaScript().function();
if (!function->shared()->HasBreakInfo()) return false; if (!function->shared().HasBreakInfo()) return false;
Handle<DebugInfo> debug_info(function->shared()->GetDebugInfo(), isolate_); Handle<DebugInfo> debug_info(function->shared().GetDebugInfo(), isolate_);
// Enter the debugger. // Enter the debugger.
DebugScope debug_scope(this); DebugScope debug_scope(this);
std::vector<BreakLocation> break_locations; std::vector<BreakLocation> break_locations;
@ -563,7 +563,7 @@ bool Debug::CheckBreakPoint(Handle<BreakPoint> break_point,
bool is_break_at_entry) { bool is_break_at_entry) {
HandleScope scope(isolate_); HandleScope scope(isolate_);
if (!break_point->condition()->length()) return true; if (!break_point->condition().length()) return true;
Handle<String> condition(break_point->condition(), isolate_); Handle<String> condition(break_point->condition(), isolate_);
MaybeHandle<Object> maybe_result; MaybeHandle<Object> maybe_result;
Handle<Object> result; Handle<Object> result;
@ -685,13 +685,13 @@ void Debug::ApplyBreakPoints(Handle<DebugInfo> debug_info) {
} else { } else {
if (!debug_info->HasInstrumentedBytecodeArray()) return; if (!debug_info->HasInstrumentedBytecodeArray()) return;
FixedArray break_points = debug_info->break_points(); FixedArray break_points = debug_info->break_points();
for (int i = 0; i < break_points->length(); i++) { for (int i = 0; i < break_points.length(); i++) {
if (break_points->get(i)->IsUndefined(isolate_)) continue; if (break_points.get(i).IsUndefined(isolate_)) continue;
BreakPointInfo info = BreakPointInfo::cast(break_points->get(i)); BreakPointInfo info = BreakPointInfo::cast(break_points.get(i));
if (info->GetBreakPointCount(isolate_) == 0) continue; if (info.GetBreakPointCount(isolate_) == 0) continue;
DCHECK(debug_info->HasInstrumentedBytecodeArray()); DCHECK(debug_info->HasInstrumentedBytecodeArray());
BreakIterator it(debug_info); BreakIterator it(debug_info);
it.SkipToPosition(info->source_position()); it.SkipToPosition(info.source_position());
it.SetDebugBreak(); it.SetDebugBreak();
} }
} }
@ -873,7 +873,7 @@ void Debug::PrepareStepInSuspendedGenerator() {
thread_local_.last_step_action_ = StepIn; thread_local_.last_step_action_ = StepIn;
UpdateHookOnFunctionCall(); UpdateHookOnFunctionCall();
Handle<JSFunction> function( Handle<JSFunction> function(
JSGeneratorObject::cast(thread_local_.suspended_generator_)->function(), JSGeneratorObject::cast(thread_local_.suspended_generator_).function(),
isolate_); isolate_);
FloodWithOneShot(Handle<SharedFunctionInfo>(function->shared(), isolate_)); FloodWithOneShot(Handle<SharedFunctionInfo>(function->shared(), isolate_));
clear_suspended_generator(); clear_suspended_generator();
@ -977,12 +977,12 @@ void Debug::PrepareStep(StepAction step_action) {
if (frame->is_wasm_compiled()) return; if (frame->is_wasm_compiled()) return;
WasmInterpreterEntryFrame* wasm_frame = WasmInterpreterEntryFrame* wasm_frame =
WasmInterpreterEntryFrame::cast(frame); WasmInterpreterEntryFrame::cast(frame);
wasm_frame->debug_info()->PrepareStep(step_action); wasm_frame->debug_info().PrepareStep(step_action);
return; return;
} }
JavaScriptFrame* js_frame = JavaScriptFrame::cast(frame); JavaScriptFrame* js_frame = JavaScriptFrame::cast(frame);
DCHECK(js_frame->function()->IsJSFunction()); DCHECK(js_frame->function().IsJSFunction());
// Get the debug info (create it if it does not exist). // Get the debug info (create it if it does not exist).
auto summary = FrameSummary::GetTop(frame).AsJavaScript(); auto summary = FrameSummary::GetTop(frame).AsJavaScript();
@ -1089,15 +1089,15 @@ Handle<Object> Debug::GetSourceBreakLocations(
Handle<FixedArray> locations = isolate->factory()->NewFixedArray( Handle<FixedArray> locations = isolate->factory()->NewFixedArray(
debug_info->GetBreakPointCount(isolate)); debug_info->GetBreakPointCount(isolate));
int count = 0; int count = 0;
for (int i = 0; i < debug_info->break_points()->length(); ++i) { for (int i = 0; i < debug_info->break_points().length(); ++i) {
if (!debug_info->break_points()->get(i)->IsUndefined(isolate)) { if (!debug_info->break_points().get(i).IsUndefined(isolate)) {
BreakPointInfo break_point_info = BreakPointInfo break_point_info =
BreakPointInfo::cast(debug_info->break_points()->get(i)); BreakPointInfo::cast(debug_info->break_points().get(i));
int break_points = break_point_info->GetBreakPointCount(isolate); int break_points = break_point_info.GetBreakPointCount(isolate);
if (break_points == 0) continue; if (break_points == 0) continue;
for (int j = 0; j < break_points; ++j) { for (int j = 0; j < break_points; ++j) {
locations->set(count++, locations->set(count++,
Smi::FromInt(break_point_info->source_position())); Smi::FromInt(break_point_info.source_position()));
} }
} }
} }
@ -1148,8 +1148,8 @@ void Debug::DeoptimizeFunction(Handle<SharedFunctionInfo> shared) {
do { do {
Code code = iterator.Next(); Code code = iterator.Next();
if (code.is_null()) break; if (code.is_null()) break;
if (code->Inlines(*shared)) { if (code.Inlines(*shared)) {
code->set_marked_for_deoptimization(true); code.set_marked_for_deoptimization(true);
found_something = true; found_something = true;
} }
} while (true); } while (true);
@ -1213,7 +1213,7 @@ void Debug::InstallDebugBreakTrampoline() {
current = current->next()) { current = current->next()) {
if (current->debug_info()->CanBreakAtEntry()) { if (current->debug_info()->CanBreakAtEntry()) {
needs_to_use_trampoline = true; needs_to_use_trampoline = true;
if (current->debug_info()->shared()->IsApiFunction()) { if (current->debug_info()->shared().IsApiFunction()) {
needs_to_clear_ic = true; needs_to_clear_ic = true;
break; break;
} }
@ -1229,23 +1229,23 @@ void Debug::InstallDebugBreakTrampoline() {
HeapIterator iterator(isolate_->heap()); HeapIterator iterator(isolate_->heap());
for (HeapObject obj = iterator.next(); !obj.is_null(); for (HeapObject obj = iterator.next(); !obj.is_null();
obj = iterator.next()) { obj = iterator.next()) {
if (needs_to_clear_ic && obj->IsFeedbackVector()) { if (needs_to_clear_ic && obj.IsFeedbackVector()) {
FeedbackVector::cast(obj)->ClearSlots(isolate_); FeedbackVector::cast(obj).ClearSlots(isolate_);
continue; continue;
} else if (obj->IsJSFunction()) { } else if (obj.IsJSFunction()) {
JSFunction fun = JSFunction::cast(obj); JSFunction fun = JSFunction::cast(obj);
SharedFunctionInfo shared = fun->shared(); SharedFunctionInfo shared = fun.shared();
if (!shared->HasDebugInfo()) continue; if (!shared.HasDebugInfo()) continue;
if (!shared->GetDebugInfo()->CanBreakAtEntry()) continue; if (!shared.GetDebugInfo().CanBreakAtEntry()) continue;
if (!fun->is_compiled()) { if (!fun.is_compiled()) {
needs_compile.push_back(handle(fun, isolate_)); needs_compile.push_back(handle(fun, isolate_));
} else { } else {
fun->set_code(*trampoline); fun.set_code(*trampoline);
} }
} else if (obj->IsAccessorPair()) { } else if (obj.IsAccessorPair()) {
AccessorPair accessor_pair = AccessorPair::cast(obj); AccessorPair accessor_pair = AccessorPair::cast(obj);
if (accessor_pair->getter()->IsFunctionTemplateInfo() || if (accessor_pair.getter().IsFunctionTemplateInfo() ||
accessor_pair->setter()->IsFunctionTemplateInfo()) { accessor_pair.setter().IsFunctionTemplateInfo()) {
needs_instantiate.push_back(handle(accessor_pair, isolate_)); needs_instantiate.push_back(handle(accessor_pair, isolate_));
} }
} }
@ -1255,7 +1255,7 @@ void Debug::InstallDebugBreakTrampoline() {
// Forcibly instantiate all lazy accessor pairs to make sure that they // Forcibly instantiate all lazy accessor pairs to make sure that they
// properly hit the debug break trampoline. // properly hit the debug break trampoline.
for (Handle<AccessorPair> accessor_pair : needs_instantiate) { for (Handle<AccessorPair> accessor_pair : needs_instantiate) {
if (accessor_pair->getter()->IsFunctionTemplateInfo()) { if (accessor_pair->getter().IsFunctionTemplateInfo()) {
Handle<JSFunction> fun = Handle<JSFunction> fun =
ApiNatives::InstantiateFunction( ApiNatives::InstantiateFunction(
handle(FunctionTemplateInfo::cast(accessor_pair->getter()), handle(FunctionTemplateInfo::cast(accessor_pair->getter()),
@ -1263,7 +1263,7 @@ void Debug::InstallDebugBreakTrampoline() {
.ToHandleChecked(); .ToHandleChecked();
accessor_pair->set_getter(*fun); accessor_pair->set_getter(*fun);
} }
if (accessor_pair->setter()->IsFunctionTemplateInfo()) { if (accessor_pair->setter().IsFunctionTemplateInfo()) {
Handle<JSFunction> fun = Handle<JSFunction> fun =
ApiNatives::InstantiateFunction( ApiNatives::InstantiateFunction(
handle(FunctionTemplateInfo::cast(accessor_pair->setter()), handle(FunctionTemplateInfo::cast(accessor_pair->setter()),
@ -1330,12 +1330,12 @@ bool Debug::GetPossibleBreakpoints(Handle<Script> script, int start_position,
SharedFunctionInfo::ScriptIterator iterator(isolate_, *script); SharedFunctionInfo::ScriptIterator iterator(isolate_, *script);
for (SharedFunctionInfo info = iterator.Next(); !info.is_null(); for (SharedFunctionInfo info = iterator.Next(); !info.is_null();
info = iterator.Next()) { info = iterator.Next()) {
if (info->EndPosition() < start_position || if (info.EndPosition() < start_position ||
info->StartPosition() >= end_position) { info.StartPosition() >= end_position) {
continue; continue;
} }
if (!info->IsSubjectToDebugging()) continue; if (!info.IsSubjectToDebugging()) continue;
if (!info->is_compiled() && !info->allows_lazy_compilation()) continue; if (!info.is_compiled() && !info.allows_lazy_compilation()) continue;
candidates.push_back(i::handle(info, isolate_)); candidates.push_back(i::handle(info, isolate_));
} }
@ -1394,26 +1394,26 @@ class SharedFunctionInfoFinder {
void NewCandidate(SharedFunctionInfo shared, void NewCandidate(SharedFunctionInfo shared,
JSFunction closure = JSFunction()) { JSFunction closure = JSFunction()) {
if (!shared->IsSubjectToDebugging()) return; if (!shared.IsSubjectToDebugging()) return;
int start_position = shared->function_token_position(); int start_position = shared.function_token_position();
if (start_position == kNoSourcePosition) { if (start_position == kNoSourcePosition) {
start_position = shared->StartPosition(); start_position = shared.StartPosition();
} }
if (start_position > target_position_) return; if (start_position > target_position_) return;
if (target_position_ > shared->EndPosition()) return; if (target_position_ > shared.EndPosition()) return;
if (!current_candidate_.is_null()) { if (!current_candidate_.is_null()) {
if (current_start_position_ == start_position && if (current_start_position_ == start_position &&
shared->EndPosition() == current_candidate_->EndPosition()) { shared.EndPosition() == current_candidate_.EndPosition()) {
// If we already have a matching closure, do not throw it away. // If we already have a matching closure, do not throw it away.
if (!current_candidate_closure_.is_null() && closure.is_null()) return; if (!current_candidate_closure_.is_null() && closure.is_null()) return;
// If a top-level function contains only one function // If a top-level function contains only one function
// declaration the source for the top-level and the function // declaration the source for the top-level and the function
// is the same. In that case prefer the non top-level function. // is the same. In that case prefer the non top-level function.
if (!current_candidate_->is_toplevel() && shared->is_toplevel()) return; if (!current_candidate_.is_toplevel() && shared.is_toplevel()) return;
} else if (start_position < current_start_position_ || } else if (start_position < current_start_position_ ||
current_candidate_->EndPosition() < shared->EndPosition()) { current_candidate_.EndPosition() < shared.EndPosition()) {
return; return;
} }
} }
@ -1462,7 +1462,7 @@ Handle<Object> Debug::FindSharedFunctionInfoInScript(Handle<Script> script,
shared = finder.Result(); shared = finder.Result();
if (shared.is_null()) break; if (shared.is_null()) break;
// We found it if it's already compiled. // We found it if it's already compiled.
is_compiled_scope = shared->is_compiled_scope(); is_compiled_scope = shared.is_compiled_scope();
if (is_compiled_scope.is_compiled()) { if (is_compiled_scope.is_compiled()) {
Handle<SharedFunctionInfo> shared_handle(shared, isolate_); Handle<SharedFunctionInfo> shared_handle(shared, isolate_);
// If the iteration count is larger than 1, we had to compile the outer // If the iteration count is larger than 1, we had to compile the outer
@ -1479,7 +1479,7 @@ Handle<Object> Debug::FindSharedFunctionInfoInScript(Handle<Script> script,
// If not, compile to reveal inner functions. // If not, compile to reveal inner functions.
HandleScope scope(isolate_); HandleScope scope(isolate_);
// Code that cannot be compiled lazily are internal and not debuggable. // Code that cannot be compiled lazily are internal and not debuggable.
DCHECK(shared->allows_lazy_compilation()); DCHECK(shared.allows_lazy_compilation());
if (!Compiler::Compile(handle(shared, isolate_), Compiler::CLEAR_EXCEPTION, if (!Compiler::Compile(handle(shared, isolate_), Compiler::CLEAR_EXCEPTION,
&is_compiled_scope)) { &is_compiled_scope)) {
break; break;
@ -1617,7 +1617,7 @@ void Debug::FreeDebugInfoListNode(DebugInfoListNode* prev,
// Pack script back into the // Pack script back into the
// SFI::script_or_debug_info field. // SFI::script_or_debug_info field.
Handle<DebugInfo> debug_info(node->debug_info()); Handle<DebugInfo> debug_info(node->debug_info());
debug_info->shared()->set_script_or_debug_info(debug_info->script()); debug_info->shared().set_script_or_debug_info(debug_info->script());
delete node; delete node;
} }
@ -1626,7 +1626,7 @@ bool Debug::IsBreakAtReturn(JavaScriptFrame* frame) {
HandleScope scope(isolate_); HandleScope scope(isolate_);
// Get the executing function in which the debug break occurred. // Get the executing function in which the debug break occurred.
Handle<SharedFunctionInfo> shared(frame->function()->shared(), isolate_); Handle<SharedFunctionInfo> shared(frame->function().shared(), isolate_);
// With no debug info there are no break points, so we can't be at a return. // With no debug info there are no break points, so we can't be at a return.
if (!shared->HasBreakInfo()) return false; if (!shared->HasBreakInfo()) return false;
@ -1673,7 +1673,7 @@ Handle<FixedArray> Debug::GetLoadedScripts() {
Script::Iterator iterator(isolate_); Script::Iterator iterator(isolate_);
for (Script script = iterator.Next(); !script.is_null(); for (Script script = iterator.Next(); !script.is_null();
script = iterator.Next()) { script = iterator.Next()) {
if (script->HasValidSource()) results->set(length++, script); if (script.HasValidSource()) results->set(length++, script);
} }
} }
return FixedArray::ShrinkOrEmpty(isolate_, results, length); return FixedArray::ShrinkOrEmpty(isolate_, results, length);
@ -1806,7 +1806,7 @@ void Debug::OnDebugBreak(Handle<FixedArray> break_points_hit) {
// This array contains breakpoints installed using JS debug API. // This array contains breakpoints installed using JS debug API.
for (int i = 0; i < break_points_hit->length(); ++i) { for (int i = 0; i < break_points_hit->length(); ++i) {
BreakPoint break_point = BreakPoint::cast(break_points_hit->get(i)); BreakPoint break_point = BreakPoint::cast(break_points_hit->get(i));
inspector_break_points_hit.push_back(break_point->id()); inspector_break_points_hit.push_back(break_point.id());
++inspector_break_points_count; ++inspector_break_points_count;
} }
@ -1834,13 +1834,13 @@ bool Debug::IsBlackboxed(Handle<SharedFunctionInfo> shared) {
Handle<DebugInfo> debug_info = GetOrCreateDebugInfo(shared); Handle<DebugInfo> debug_info = GetOrCreateDebugInfo(shared);
if (!debug_info->computed_debug_is_blackboxed()) { if (!debug_info->computed_debug_is_blackboxed()) {
bool is_blackboxed = bool is_blackboxed =
!shared->IsSubjectToDebugging() || !shared->script()->IsScript(); !shared->IsSubjectToDebugging() || !shared->script().IsScript();
if (!is_blackboxed) { if (!is_blackboxed) {
SuppressDebug while_processing(this); SuppressDebug while_processing(this);
HandleScope handle_scope(isolate_); HandleScope handle_scope(isolate_);
PostponeInterruptsScope no_interrupts(isolate_); PostponeInterruptsScope no_interrupts(isolate_);
DisableBreak no_recursive_break(this); DisableBreak no_recursive_break(this);
DCHECK(shared->script()->IsScript()); DCHECK(shared->script().IsScript());
Handle<Script> script(Script::cast(shared->script()), isolate_); Handle<Script> script(Script::cast(shared->script()), isolate_);
DCHECK(script->IsUserJavaScript()); DCHECK(script->IsUserJavaScript());
debug::Location start = GetDebugLocation(script, shared->StartPosition()); debug::Location start = GetDebugLocation(script, shared->StartPosition());
@ -1978,7 +1978,7 @@ void Debug::HandleDebugBreak(IgnoreBreakMode ignore_break_mode) {
{ JavaScriptFrameIterator it(isolate_); { JavaScriptFrameIterator it(isolate_);
DCHECK(!it.done()); DCHECK(!it.done());
Object fun = it.frame()->function(); Object fun = it.frame()->function();
if (fun->IsJSFunction()) { if (fun.IsJSFunction()) {
HandleScope scope(isolate_); HandleScope scope(isolate_);
Handle<JSFunction> function(JSFunction::cast(fun), isolate_); Handle<JSFunction> function(JSFunction::cast(fun), isolate_);
// Don't stop in builtin and blackboxed functions. // Don't stop in builtin and blackboxed functions.
@ -2091,7 +2091,7 @@ void Debug::UpdateDebugInfosForExecutionMode() {
Handle<DebugInfo> debug_info = current->debug_info(); Handle<DebugInfo> debug_info = current->debug_info();
if (debug_info->HasInstrumentedBytecodeArray() && if (debug_info->HasInstrumentedBytecodeArray() &&
debug_info->DebugExecutionMode() != isolate_->debug_execution_mode()) { debug_info->DebugExecutionMode() != isolate_->debug_execution_mode()) {
DCHECK(debug_info->shared()->HasBytecodeArray()); DCHECK(debug_info->shared().HasBytecodeArray());
if (isolate_->debug_execution_mode() == DebugInfo::kBreakpoints) { if (isolate_->debug_execution_mode() == DebugInfo::kBreakpoints) {
ClearSideEffectChecks(debug_info); ClearSideEffectChecks(debug_info);
ApplyBreakPoints(debug_info); ApplyBreakPoints(debug_info);
@ -2173,7 +2173,7 @@ bool Debug::PerformSideEffectCheck(Handle<JSFunction> function,
Handle<Object> receiver) { Handle<Object> receiver) {
DCHECK_EQ(isolate_->debug_execution_mode(), DebugInfo::kSideEffects); DCHECK_EQ(isolate_->debug_execution_mode(), DebugInfo::kSideEffects);
DisallowJavascriptExecution no_js(isolate_); DisallowJavascriptExecution no_js(isolate_);
IsCompiledScope is_compiled_scope(function->shared()->is_compiled_scope()); IsCompiledScope is_compiled_scope(function->shared().is_compiled_scope());
if (!function->is_compiled() && if (!function->is_compiled() &&
!Compiler::Compile(function, Compiler::KEEP_EXCEPTION, !Compiler::Compile(function, Compiler::KEEP_EXCEPTION,
&is_compiled_scope)) { &is_compiled_scope)) {
@ -2188,7 +2188,7 @@ bool Debug::PerformSideEffectCheck(Handle<JSFunction> function,
case DebugInfo::kHasSideEffects: case DebugInfo::kHasSideEffects:
if (FLAG_trace_side_effect_free_debug_evaluate) { if (FLAG_trace_side_effect_free_debug_evaluate) {
PrintF("[debug-evaluate] Function %s failed side effect check.\n", PrintF("[debug-evaluate] Function %s failed side effect check.\n",
function->shared()->DebugName()->ToCString().get()); function->shared().DebugName().ToCString().get());
} }
side_effect_check_failed_ = true; side_effect_check_failed_ = true;
// Throw an uncatchable termination exception. // Throw an uncatchable termination exception.
@ -2225,7 +2225,7 @@ bool Debug::PerformSideEffectCheckForCallback(
DCHECK_EQ(!receiver.is_null(), callback_info->IsAccessorInfo()); DCHECK_EQ(!receiver.is_null(), callback_info->IsAccessorInfo());
DCHECK_EQ(isolate_->debug_execution_mode(), DebugInfo::kSideEffects); DCHECK_EQ(isolate_->debug_execution_mode(), DebugInfo::kSideEffects);
if (!callback_info.is_null() && callback_info->IsCallHandlerInfo() && if (!callback_info.is_null() && callback_info->IsCallHandlerInfo() &&
i::CallHandlerInfo::cast(*callback_info)->NextCallHasNoSideEffect()) { i::CallHandlerInfo::cast(*callback_info).NextCallHasNoSideEffect()) {
return true; return true;
} }
// TODO(7515): always pass a valid callback info object. // TODO(7515): always pass a valid callback info object.
@ -2234,8 +2234,8 @@ bool Debug::PerformSideEffectCheckForCallback(
// List of whitelisted internal accessors can be found in accessors.h. // List of whitelisted internal accessors can be found in accessors.h.
AccessorInfo info = AccessorInfo::cast(*callback_info); AccessorInfo info = AccessorInfo::cast(*callback_info);
DCHECK_NE(kNotAccessor, accessor_kind); DCHECK_NE(kNotAccessor, accessor_kind);
switch (accessor_kind == kSetter ? info->setter_side_effect_type() switch (accessor_kind == kSetter ? info.setter_side_effect_type()
: info->getter_side_effect_type()) { : info.getter_side_effect_type()) {
case SideEffectType::kHasNoSideEffect: case SideEffectType::kHasNoSideEffect:
// We do not support setter accessors with no side effects, since // We do not support setter accessors with no side effects, since
// calling set accessors go through a store bytecode. Store bytecodes // calling set accessors go through a store bytecode. Store bytecodes
@ -2252,18 +2252,18 @@ bool Debug::PerformSideEffectCheckForCallback(
} }
if (FLAG_trace_side_effect_free_debug_evaluate) { if (FLAG_trace_side_effect_free_debug_evaluate) {
PrintF("[debug-evaluate] API Callback '"); PrintF("[debug-evaluate] API Callback '");
info->name()->ShortPrint(); info.name().ShortPrint();
PrintF("' may cause side effect.\n"); PrintF("' may cause side effect.\n");
} }
} else if (callback_info->IsInterceptorInfo()) { } else if (callback_info->IsInterceptorInfo()) {
InterceptorInfo info = InterceptorInfo::cast(*callback_info); InterceptorInfo info = InterceptorInfo::cast(*callback_info);
if (info->has_no_side_effect()) return true; if (info.has_no_side_effect()) return true;
if (FLAG_trace_side_effect_free_debug_evaluate) { if (FLAG_trace_side_effect_free_debug_evaluate) {
PrintF("[debug-evaluate] API Interceptor may cause side effect.\n"); PrintF("[debug-evaluate] API Interceptor may cause side effect.\n");
} }
} else if (callback_info->IsCallHandlerInfo()) { } else if (callback_info->IsCallHandlerInfo()) {
CallHandlerInfo info = CallHandlerInfo::cast(*callback_info); CallHandlerInfo info = CallHandlerInfo::cast(*callback_info);
if (info->IsSideEffectFreeCallHandlerInfo()) return true; if (info.IsSideEffectFreeCallHandlerInfo()) return true;
if (FLAG_trace_side_effect_free_debug_evaluate) { if (FLAG_trace_side_effect_free_debug_evaluate) {
PrintF("[debug-evaluate] API CallHandlerInfo may cause side effect.\n"); PrintF("[debug-evaluate] API CallHandlerInfo may cause side effect.\n");
} }
@ -2280,8 +2280,8 @@ bool Debug::PerformSideEffectCheckAtBytecode(InterpretedFrame* frame) {
using interpreter::Bytecode; using interpreter::Bytecode;
DCHECK_EQ(isolate_->debug_execution_mode(), DebugInfo::kSideEffects); DCHECK_EQ(isolate_->debug_execution_mode(), DebugInfo::kSideEffects);
SharedFunctionInfo shared = frame->function()->shared(); SharedFunctionInfo shared = frame->function().shared();
BytecodeArray bytecode_array = shared->GetBytecodeArray(); BytecodeArray bytecode_array = shared.GetBytecodeArray();
int offset = frame->GetBytecodeOffset(); int offset = frame->GetBytecodeOffset();
interpreter::BytecodeArrayAccessor bytecode_accessor( interpreter::BytecodeArrayAccessor bytecode_accessor(
handle(bytecode_array, isolate_), offset); handle(bytecode_array, isolate_), offset);

View File

@ -811,12 +811,12 @@ class FunctionDataMap : public ThreadVisitor {
} }
bool Lookup(SharedFunctionInfo sfi, FunctionData** data) { bool Lookup(SharedFunctionInfo sfi, FunctionData** data) {
int start_position = sfi->StartPosition(); int start_position = sfi.StartPosition();
if (!sfi->script()->IsScript() || start_position == -1) { if (!sfi.script().IsScript() || start_position == -1) {
return false; return false;
} }
Script script = Script::cast(sfi->script()); Script script = Script::cast(sfi.script());
return Lookup(GetFuncId(script->id(), sfi), data); return Lookup(GetFuncId(script.id(), sfi), data);
} }
bool Lookup(Handle<Script> script, FunctionLiteral* literal, bool Lookup(Handle<Script> script, FunctionLiteral* literal,
@ -829,21 +829,21 @@ class FunctionDataMap : public ThreadVisitor {
HeapIterator iterator(isolate->heap(), HeapIterator::kFilterUnreachable); HeapIterator iterator(isolate->heap(), HeapIterator::kFilterUnreachable);
for (HeapObject obj = iterator.next(); !obj.is_null(); for (HeapObject obj = iterator.next(); !obj.is_null();
obj = iterator.next()) { obj = iterator.next()) {
if (obj->IsSharedFunctionInfo()) { if (obj.IsSharedFunctionInfo()) {
SharedFunctionInfo sfi = SharedFunctionInfo::cast(obj); SharedFunctionInfo sfi = SharedFunctionInfo::cast(obj);
FunctionData* data = nullptr; FunctionData* data = nullptr;
if (!Lookup(sfi, &data)) continue; if (!Lookup(sfi, &data)) continue;
data->shared = handle(sfi, isolate); data->shared = handle(sfi, isolate);
} else if (obj->IsJSFunction()) { } else if (obj.IsJSFunction()) {
JSFunction js_function = JSFunction::cast(obj); JSFunction js_function = JSFunction::cast(obj);
SharedFunctionInfo sfi = js_function->shared(); SharedFunctionInfo sfi = js_function.shared();
FunctionData* data = nullptr; FunctionData* data = nullptr;
if (!Lookup(sfi, &data)) continue; if (!Lookup(sfi, &data)) continue;
data->js_functions.emplace_back(js_function, isolate); data->js_functions.emplace_back(js_function, isolate);
} else if (obj->IsJSGeneratorObject()) { } else if (obj.IsJSGeneratorObject()) {
JSGeneratorObject gen = JSGeneratorObject::cast(obj); JSGeneratorObject gen = JSGeneratorObject::cast(obj);
if (gen->is_closed()) continue; if (gen.is_closed()) continue;
SharedFunctionInfo sfi = gen->function()->shared(); SharedFunctionInfo sfi = gen.function().shared();
FunctionData* data = nullptr; FunctionData* data = nullptr;
if (!Lookup(sfi, &data)) continue; if (!Lookup(sfi, &data)) continue;
data->running_generators.emplace_back(gen, isolate); data->running_generators.emplace_back(gen, isolate);
@ -903,10 +903,10 @@ class FunctionDataMap : public ThreadVisitor {
} }
FuncId GetFuncId(int script_id, SharedFunctionInfo sfi) { FuncId GetFuncId(int script_id, SharedFunctionInfo sfi) {
DCHECK_EQ(script_id, Script::cast(sfi->script())->id()); DCHECK_EQ(script_id, Script::cast(sfi.script()).id());
int start_position = sfi->StartPosition(); int start_position = sfi.StartPosition();
DCHECK_NE(start_position, -1); DCHECK_NE(start_position, -1);
if (sfi->is_toplevel()) { if (sfi.is_toplevel()) {
// This is the top-level function, so special case its start position // This is the top-level function, so special case its start position
DCHECK_EQ(start_position, 0); DCHECK_EQ(start_position, 0);
start_position = -1; start_position = -1;
@ -1119,10 +1119,10 @@ void LiveEdit::PatchScript(Isolate* isolate, Handle<Script> script,
sfi->set_script(*new_script); sfi->set_script(*new_script);
if (sfi->HasUncompiledData()) { if (sfi->HasUncompiledData()) {
sfi->uncompiled_data()->set_function_literal_id( sfi->uncompiled_data().set_function_literal_id(
mapping.second->function_literal_id()); mapping.second->function_literal_id());
} }
new_script->shared_function_infos()->Set( new_script->shared_function_infos().Set(
mapping.second->function_literal_id(), HeapObjectReference::Weak(*sfi)); mapping.second->function_literal_id(), HeapObjectReference::Weak(*sfi));
DCHECK_EQ(sfi->FunctionLiteralId(isolate), DCHECK_EQ(sfi->FunctionLiteralId(isolate),
mapping.second->function_literal_id()); mapping.second->function_literal_id());
@ -1144,11 +1144,11 @@ void LiveEdit::PatchScript(Isolate* isolate, Handle<Script> script,
} }
if (!sfi->HasBytecodeArray()) continue; if (!sfi->HasBytecodeArray()) continue;
FixedArray constants = sfi->GetBytecodeArray()->constant_pool(); FixedArray constants = sfi->GetBytecodeArray().constant_pool();
for (int i = 0; i < constants->length(); ++i) { for (int i = 0; i < constants.length(); ++i) {
if (!constants->get(i)->IsSharedFunctionInfo()) continue; if (!constants.get(i).IsSharedFunctionInfo()) continue;
FunctionData* data = nullptr; FunctionData* data = nullptr;
if (!function_data_map.Lookup(SharedFunctionInfo::cast(constants->get(i)), if (!function_data_map.Lookup(SharedFunctionInfo::cast(constants.get(i)),
&data)) { &data)) {
continue; continue;
} }
@ -1159,7 +1159,7 @@ void LiveEdit::PatchScript(Isolate* isolate, Handle<Script> script,
} }
Handle<SharedFunctionInfo> new_sfi; Handle<SharedFunctionInfo> new_sfi;
if (!data->shared.ToHandle(&new_sfi)) continue; if (!data->shared.ToHandle(&new_sfi)) continue;
constants->set(i, *new_sfi); constants.set(i, *new_sfi);
} }
} }
for (const auto& mapping : changed) { for (const auto& mapping : changed) {
@ -1176,7 +1176,7 @@ void LiveEdit::PatchScript(Isolate* isolate, Handle<Script> script,
isolate->compilation_cache()->Remove(sfi); isolate->compilation_cache()->Remove(sfi);
for (auto& js_function : data->js_functions) { for (auto& js_function : data->js_functions) {
js_function->set_shared(*new_sfi); js_function->set_shared(*new_sfi);
js_function->set_code(js_function->shared()->GetCode()); js_function->set_code(js_function->shared().GetCode());
js_function->set_raw_feedback_cell( js_function->set_raw_feedback_cell(
*isolate->factory()->many_closures_cell()); *isolate->factory()->many_closures_cell());
@ -1186,30 +1186,29 @@ void LiveEdit::PatchScript(Isolate* isolate, Handle<Script> script,
} }
SharedFunctionInfo::ScriptIterator it(isolate, *new_script); SharedFunctionInfo::ScriptIterator it(isolate, *new_script);
for (SharedFunctionInfo sfi = it.Next(); !sfi.is_null(); sfi = it.Next()) { for (SharedFunctionInfo sfi = it.Next(); !sfi.is_null(); sfi = it.Next()) {
if (!sfi->HasBytecodeArray()) continue; if (!sfi.HasBytecodeArray()) continue;
FixedArray constants = sfi->GetBytecodeArray()->constant_pool(); FixedArray constants = sfi.GetBytecodeArray().constant_pool();
for (int i = 0; i < constants->length(); ++i) { for (int i = 0; i < constants.length(); ++i) {
if (!constants->get(i)->IsSharedFunctionInfo()) continue; if (!constants.get(i).IsSharedFunctionInfo()) continue;
SharedFunctionInfo inner_sfi = SharedFunctionInfo inner_sfi = SharedFunctionInfo::cast(constants.get(i));
SharedFunctionInfo::cast(constants->get(i));
// See if there is a mapping from this function's start position to a // See if there is a mapping from this function's start position to a
// unchanged function's id. // unchanged function's id.
auto unchanged_it = auto unchanged_it =
start_position_to_unchanged_id.find(inner_sfi->StartPosition()); start_position_to_unchanged_id.find(inner_sfi.StartPosition());
if (unchanged_it == start_position_to_unchanged_id.end()) continue; if (unchanged_it == start_position_to_unchanged_id.end()) continue;
// Grab that function id from the new script's SFI list, which should have // Grab that function id from the new script's SFI list, which should have
// already been updated in in the unchanged pass. // already been updated in in the unchanged pass.
SharedFunctionInfo old_unchanged_inner_sfi = SharedFunctionInfo old_unchanged_inner_sfi =
SharedFunctionInfo::cast(new_script->shared_function_infos() SharedFunctionInfo::cast(new_script->shared_function_infos()
->Get(unchanged_it->second) .Get(unchanged_it->second)
->GetHeapObject()); ->GetHeapObject());
if (old_unchanged_inner_sfi == inner_sfi) continue; if (old_unchanged_inner_sfi == inner_sfi) continue;
DCHECK_NE(old_unchanged_inner_sfi, inner_sfi); DCHECK_NE(old_unchanged_inner_sfi, inner_sfi);
// Now some sanity checks. Make sure that the unchanged SFI has already // Now some sanity checks. Make sure that the unchanged SFI has already
// been processed and patched to be on the new script ... // been processed and patched to be on the new script ...
DCHECK_EQ(old_unchanged_inner_sfi->script(), *new_script); DCHECK_EQ(old_unchanged_inner_sfi.script(), *new_script);
constants->set(i, old_unchanged_inner_sfi); constants.set(i, old_unchanged_inner_sfi);
} }
} }
#ifdef DEBUG #ifdef DEBUG
@ -1222,28 +1221,28 @@ void LiveEdit::PatchScript(Isolate* isolate, Handle<Script> script,
SharedFunctionInfo::ScriptIterator it(isolate, *new_script); SharedFunctionInfo::ScriptIterator it(isolate, *new_script);
std::set<int> start_positions; std::set<int> start_positions;
for (SharedFunctionInfo sfi = it.Next(); !sfi.is_null(); sfi = it.Next()) { for (SharedFunctionInfo sfi = it.Next(); !sfi.is_null(); sfi = it.Next()) {
DCHECK_EQ(sfi->script(), *new_script); DCHECK_EQ(sfi.script(), *new_script);
DCHECK_EQ(sfi->FunctionLiteralId(isolate), it.CurrentIndex()); DCHECK_EQ(sfi.FunctionLiteralId(isolate), it.CurrentIndex());
// Don't check the start position of the top-level function, as it can // Don't check the start position of the top-level function, as it can
// overlap with a function in the script. // overlap with a function in the script.
if (sfi->is_toplevel()) { if (sfi.is_toplevel()) {
DCHECK_EQ(start_positions.find(sfi->StartPosition()), DCHECK_EQ(start_positions.find(sfi.StartPosition()),
start_positions.end()); start_positions.end());
start_positions.insert(sfi->StartPosition()); start_positions.insert(sfi.StartPosition());
} }
if (!sfi->HasBytecodeArray()) continue; if (!sfi.HasBytecodeArray()) continue;
// Check that all the functions in this function's constant pool are also // Check that all the functions in this function's constant pool are also
// on the new script, and that their id matches their index in the new // on the new script, and that their id matches their index in the new
// scripts function list. // scripts function list.
FixedArray constants = sfi->GetBytecodeArray()->constant_pool(); FixedArray constants = sfi.GetBytecodeArray().constant_pool();
for (int i = 0; i < constants->length(); ++i) { for (int i = 0; i < constants.length(); ++i) {
if (!constants->get(i)->IsSharedFunctionInfo()) continue; if (!constants.get(i).IsSharedFunctionInfo()) continue;
SharedFunctionInfo inner_sfi = SharedFunctionInfo inner_sfi =
SharedFunctionInfo::cast(constants->get(i)); SharedFunctionInfo::cast(constants.get(i));
DCHECK_EQ(inner_sfi->script(), *new_script); DCHECK_EQ(inner_sfi.script(), *new_script);
DCHECK_EQ(inner_sfi, new_script->shared_function_infos() DCHECK_EQ(inner_sfi, new_script->shared_function_infos()
->Get(inner_sfi->FunctionLiteralId(isolate)) .Get(inner_sfi.FunctionLiteralId(isolate))
->GetHeapObject()); ->GetHeapObject());
} }
} }

View File

@ -54,7 +54,7 @@ class FrameWriter {
} }
void PushRawObject(Object obj, const char* debug_hint) { void PushRawObject(Object obj, const char* debug_hint) {
intptr_t value = obj->ptr(); intptr_t value = obj.ptr();
PushValue(value); PushValue(value);
if (trace_scope_ != nullptr) { if (trace_scope_ != nullptr) {
DebugPrintOutputObject(obj, top_offset_, debug_hint); DebugPrintOutputObject(obj, top_offset_, debug_hint);
@ -121,10 +121,10 @@ class FrameWriter {
if (trace_scope_ != nullptr) { if (trace_scope_ != nullptr) {
PrintF(trace_scope_->file(), " " V8PRIxPTR_FMT ": [top + %3d] <- ", PrintF(trace_scope_->file(), " " V8PRIxPTR_FMT ": [top + %3d] <- ",
output_address(output_offset), output_offset); output_address(output_offset), output_offset);
if (obj->IsSmi()) { if (obj.IsSmi()) {
PrintF(V8PRIxPTR_FMT " <Smi %d>", obj->ptr(), Smi::cast(obj)->value()); PrintF(V8PRIxPTR_FMT " <Smi %d>", obj.ptr(), Smi::cast(obj).value());
} else { } else {
obj->ShortPrint(trace_scope_->file()); obj.ShortPrint(trace_scope_->file());
} }
PrintF(trace_scope_->file(), " ; %s", debug_hint); PrintF(trace_scope_->file(), " ; %s", debug_hint);
} }
@ -156,16 +156,16 @@ void DeoptimizerData::set_deopt_entry_code(DeoptimizeKind kind, Code code) {
} }
Code Deoptimizer::FindDeoptimizingCode(Address addr) { Code Deoptimizer::FindDeoptimizingCode(Address addr) {
if (function_->IsHeapObject()) { if (function_.IsHeapObject()) {
// Search all deoptimizing code in the native context of the function. // Search all deoptimizing code in the native context of the function.
Isolate* isolate = isolate_; Isolate* isolate = isolate_;
Context native_context = function_->context()->native_context(); Context native_context = function_.context().native_context();
Object element = native_context->DeoptimizedCodeListHead(); Object element = native_context.DeoptimizedCodeListHead();
while (!element->IsUndefined(isolate)) { while (!element.IsUndefined(isolate)) {
Code code = Code::cast(element); Code code = Code::cast(element);
CHECK(code->kind() == Code::OPTIMIZED_FUNCTION); CHECK(code.kind() == Code::OPTIMIZED_FUNCTION);
if (code->contains(addr)) return code; if (code.contains(addr)) return code;
element = code->next_code_link(); element = code.next_code_link();
} }
} }
return Code(); return Code();
@ -244,15 +244,15 @@ class ActivationsFinder : public ThreadVisitor {
for (StackFrameIterator it(isolate, top); !it.done(); it.Advance()) { for (StackFrameIterator it(isolate, top); !it.done(); it.Advance()) {
if (it.frame()->type() == StackFrame::OPTIMIZED) { if (it.frame()->type() == StackFrame::OPTIMIZED) {
Code code = it.frame()->LookupCode(); Code code = it.frame()->LookupCode();
if (code->kind() == Code::OPTIMIZED_FUNCTION && if (code.kind() == Code::OPTIMIZED_FUNCTION &&
code->marked_for_deoptimization()) { code.marked_for_deoptimization()) {
codes_->erase(code); codes_->erase(code);
// Obtain the trampoline to the deoptimizer call. // Obtain the trampoline to the deoptimizer call.
SafepointEntry safepoint = code->GetSafepointEntry(it.frame()->pc()); SafepointEntry safepoint = code.GetSafepointEntry(it.frame()->pc());
int trampoline_pc = safepoint.trampoline_pc(); int trampoline_pc = safepoint.trampoline_pc();
DCHECK_IMPLIES(code == topmost_, safe_to_deopt_); DCHECK_IMPLIES(code == topmost_, safe_to_deopt_);
// Replace the current pc on the stack with the trampoline. // Replace the current pc on the stack with the trampoline.
it.frame()->set_pc(code->raw_instruction_start() + trampoline_pc); it.frame()->set_pc(code.raw_instruction_start() + trampoline_pc);
} }
} }
} }
@ -273,7 +273,7 @@ class ActivationsFinder : public ThreadVisitor {
void Deoptimizer::DeoptimizeMarkedCodeForContext(Context context) { void Deoptimizer::DeoptimizeMarkedCodeForContext(Context context) {
DisallowHeapAllocation no_allocation; DisallowHeapAllocation no_allocation;
Isolate* isolate = context->GetIsolate(); Isolate* isolate = context.GetIsolate();
Code topmost_optimized_code; Code topmost_optimized_code;
bool safe_to_deopt_topmost_optimized_code = false; bool safe_to_deopt_topmost_optimized_code = false;
#ifdef DEBUG #ifdef DEBUG
@ -290,14 +290,14 @@ void Deoptimizer::DeoptimizeMarkedCodeForContext(Context context) {
if (FLAG_trace_deopt) { if (FLAG_trace_deopt) {
CodeTracer::Scope scope(isolate->GetCodeTracer()); CodeTracer::Scope scope(isolate->GetCodeTracer());
PrintF(scope.file(), "[deoptimizer found activation of function: "); PrintF(scope.file(), "[deoptimizer found activation of function: ");
function->PrintName(scope.file()); function.PrintName(scope.file());
PrintF(scope.file(), " / %" V8PRIxPTR "]\n", function.ptr()); PrintF(scope.file(), " / %" V8PRIxPTR "]\n", function.ptr());
} }
SafepointEntry safepoint = code->GetSafepointEntry(it.frame()->pc()); SafepointEntry safepoint = code.GetSafepointEntry(it.frame()->pc());
// Turbofan deopt is checked when we are patching addresses on stack. // Turbofan deopt is checked when we are patching addresses on stack.
bool safe_if_deopt_triggered = safepoint.has_deoptimization_index(); bool safe_if_deopt_triggered = safepoint.has_deoptimization_index();
bool is_builtin_code = code->kind() == Code::BUILTIN; bool is_builtin_code = code.kind() == Code::BUILTIN;
DCHECK(topmost_optimized_code.is_null() || safe_if_deopt_triggered || DCHECK(topmost_optimized_code.is_null() || safe_if_deopt_triggered ||
is_builtin_code); is_builtin_code);
if (topmost_optimized_code.is_null()) { if (topmost_optimized_code.is_null()) {
@ -315,26 +315,26 @@ void Deoptimizer::DeoptimizeMarkedCodeForContext(Context context) {
// Move marked code from the optimized code list to the deoptimized code list. // Move marked code from the optimized code list to the deoptimized code list.
// Walk over all optimized code objects in this native context. // Walk over all optimized code objects in this native context.
Code prev; Code prev;
Object element = context->OptimizedCodeListHead(); Object element = context.OptimizedCodeListHead();
while (!element->IsUndefined(isolate)) { while (!element.IsUndefined(isolate)) {
Code code = Code::cast(element); Code code = Code::cast(element);
CHECK_EQ(code->kind(), Code::OPTIMIZED_FUNCTION); CHECK_EQ(code.kind(), Code::OPTIMIZED_FUNCTION);
Object next = code->next_code_link(); Object next = code.next_code_link();
if (code->marked_for_deoptimization()) { if (code.marked_for_deoptimization()) {
codes.insert(code); codes.insert(code);
if (!prev.is_null()) { if (!prev.is_null()) {
// Skip this code in the optimized code list. // Skip this code in the optimized code list.
prev->set_next_code_link(next); prev.set_next_code_link(next);
} else { } else {
// There was no previous node, the next node is the new head. // There was no previous node, the next node is the new head.
context->SetOptimizedCodeListHead(next); context.SetOptimizedCodeListHead(next);
} }
// Move the code to the _deoptimized_ code list. // Move the code to the _deoptimized_ code list.
code->set_next_code_link(context->DeoptimizedCodeListHead()); code.set_next_code_link(context.DeoptimizedCodeListHead());
context->SetDeoptimizedCodeListHead(code); context.SetDeoptimizedCodeListHead(code);
} else { } else {
// Not marked; preserve this element. // Not marked; preserve this element.
prev = code; prev = code;
@ -372,11 +372,11 @@ void Deoptimizer::DeoptimizeAll(Isolate* isolate) {
DisallowHeapAllocation no_allocation; DisallowHeapAllocation no_allocation;
// For all contexts, mark all code, then deoptimize. // For all contexts, mark all code, then deoptimize.
Object context = isolate->heap()->native_contexts_list(); Object context = isolate->heap()->native_contexts_list();
while (!context->IsUndefined(isolate)) { while (!context.IsUndefined(isolate)) {
Context native_context = Context::cast(context); Context native_context = Context::cast(context);
MarkAllCodeForContext(native_context); MarkAllCodeForContext(native_context);
DeoptimizeMarkedCodeForContext(native_context); DeoptimizeMarkedCodeForContext(native_context);
context = native_context->next_context_link(); context = native_context.next_context_link();
} }
} }
@ -392,47 +392,47 @@ void Deoptimizer::DeoptimizeMarkedCode(Isolate* isolate) {
DisallowHeapAllocation no_allocation; DisallowHeapAllocation no_allocation;
// For all contexts, deoptimize code already marked. // For all contexts, deoptimize code already marked.
Object context = isolate->heap()->native_contexts_list(); Object context = isolate->heap()->native_contexts_list();
while (!context->IsUndefined(isolate)) { while (!context.IsUndefined(isolate)) {
Context native_context = Context::cast(context); Context native_context = Context::cast(context);
DeoptimizeMarkedCodeForContext(native_context); DeoptimizeMarkedCodeForContext(native_context);
context = native_context->next_context_link(); context = native_context.next_context_link();
} }
} }
void Deoptimizer::MarkAllCodeForContext(Context context) { void Deoptimizer::MarkAllCodeForContext(Context context) {
Object element = context->OptimizedCodeListHead(); Object element = context.OptimizedCodeListHead();
Isolate* isolate = context->GetIsolate(); Isolate* isolate = context.GetIsolate();
while (!element->IsUndefined(isolate)) { while (!element.IsUndefined(isolate)) {
Code code = Code::cast(element); Code code = Code::cast(element);
CHECK_EQ(code->kind(), Code::OPTIMIZED_FUNCTION); CHECK_EQ(code.kind(), Code::OPTIMIZED_FUNCTION);
code->set_marked_for_deoptimization(true); code.set_marked_for_deoptimization(true);
element = code->next_code_link(); element = code.next_code_link();
} }
} }
void Deoptimizer::DeoptimizeFunction(JSFunction function, Code code) { void Deoptimizer::DeoptimizeFunction(JSFunction function, Code code) {
Isolate* isolate = function->GetIsolate(); Isolate* isolate = function.GetIsolate();
RuntimeCallTimerScope runtimeTimer(isolate, RuntimeCallTimerScope runtimeTimer(isolate,
RuntimeCallCounterId::kDeoptimizeCode); RuntimeCallCounterId::kDeoptimizeCode);
TimerEventScope<TimerEventDeoptimizeCode> timer(isolate); TimerEventScope<TimerEventDeoptimizeCode> timer(isolate);
TRACE_EVENT0("v8", "V8.DeoptimizeCode"); TRACE_EVENT0("v8", "V8.DeoptimizeCode");
function->ResetIfBytecodeFlushed(); function.ResetIfBytecodeFlushed();
if (code.is_null()) code = function->code(); if (code.is_null()) code = function.code();
if (code->kind() == Code::OPTIMIZED_FUNCTION) { if (code.kind() == Code::OPTIMIZED_FUNCTION) {
// Mark the code for deoptimization and unlink any functions that also // Mark the code for deoptimization and unlink any functions that also
// refer to that code. The code cannot be shared across native contexts, // refer to that code. The code cannot be shared across native contexts,
// so we only need to search one. // so we only need to search one.
code->set_marked_for_deoptimization(true); code.set_marked_for_deoptimization(true);
// The code in the function's optimized code feedback vector slot might // The code in the function's optimized code feedback vector slot might
// be different from the code on the function - evict it if necessary. // be different from the code on the function - evict it if necessary.
function->feedback_vector()->EvictOptimizedCodeMarkedForDeoptimization( function.feedback_vector().EvictOptimizedCodeMarkedForDeoptimization(
function->shared(), "unlinking code marked for deopt"); function.shared(), "unlinking code marked for deopt");
if (!code->deopt_already_counted()) { if (!code.deopt_already_counted()) {
function->feedback_vector()->increment_deopt_count(); function.feedback_vector().increment_deopt_count();
code->set_deopt_already_counted(true); code.set_deopt_already_counted(true);
} }
DeoptimizeMarkedCodeForContext(function->context()->native_context()); DeoptimizeMarkedCodeForContext(function.context().native_context());
} }
} }
@ -485,7 +485,7 @@ Deoptimizer::Deoptimizer(Isolate* isolate, JSFunction function,
compiled_code_ = FindOptimizedCode(); compiled_code_ = FindOptimizedCode();
DCHECK(!compiled_code_.is_null()); DCHECK(!compiled_code_.is_null());
DCHECK(function->IsJSFunction()); DCHECK(function.IsJSFunction());
trace_scope_ = FLAG_trace_deopt trace_scope_ = FLAG_trace_deopt
? new CodeTracer::Scope(isolate->GetCodeTracer()) ? new CodeTracer::Scope(isolate->GetCodeTracer())
: nullptr; : nullptr;
@ -493,8 +493,8 @@ Deoptimizer::Deoptimizer(Isolate* isolate, JSFunction function,
DCHECK(AllowHeapAllocation::IsAllowed()); DCHECK(AllowHeapAllocation::IsAllowed());
disallow_heap_allocation_ = new DisallowHeapAllocation(); disallow_heap_allocation_ = new DisallowHeapAllocation();
#endif // DEBUG #endif // DEBUG
if (compiled_code_->kind() != Code::OPTIMIZED_FUNCTION || if (compiled_code_.kind() != Code::OPTIMIZED_FUNCTION ||
!compiled_code_->deopt_already_counted()) { !compiled_code_.deopt_already_counted()) {
// If the function is optimized, and we haven't counted that deopt yet, then // If the function is optimized, and we haven't counted that deopt yet, then
// increment the function's deopt count so that we can avoid optimising // increment the function's deopt count so that we can avoid optimising
// functions that deopt too often. // functions that deopt too often.
@ -504,17 +504,16 @@ Deoptimizer::Deoptimizer(Isolate* isolate, JSFunction function,
// that can eventually lead to disabling optimization for a function. // that can eventually lead to disabling optimization for a function.
isolate->counters()->soft_deopts_executed()->Increment(); isolate->counters()->soft_deopts_executed()->Increment();
} else if (!function.is_null()) { } else if (!function.is_null()) {
function->feedback_vector()->increment_deopt_count(); function.feedback_vector().increment_deopt_count();
} }
} }
if (compiled_code_->kind() == Code::OPTIMIZED_FUNCTION) { if (compiled_code_.kind() == Code::OPTIMIZED_FUNCTION) {
compiled_code_->set_deopt_already_counted(true); compiled_code_.set_deopt_already_counted(true);
PROFILE(isolate_, PROFILE(isolate_,
CodeDeoptEvent(compiled_code_, kind, from_, fp_to_sp_delta_)); CodeDeoptEvent(compiled_code_, kind, from_, fp_to_sp_delta_));
} }
unsigned size = ComputeInputFrameSize(); unsigned size = ComputeInputFrameSize();
int parameter_count = int parameter_count = function.shared().internal_formal_parameter_count() + 1;
function->shared()->internal_formal_parameter_count() + 1;
input_ = new (size) FrameDescription(size, parameter_count); input_ = new (size) FrameDescription(size, parameter_count);
} }
@ -525,11 +524,11 @@ Code Deoptimizer::FindOptimizedCode() {
} }
void Deoptimizer::PrintFunctionName() { void Deoptimizer::PrintFunctionName() {
if (function_->IsHeapObject() && function_->IsJSFunction()) { if (function_.IsHeapObject() && function_.IsJSFunction()) {
function_->ShortPrint(trace_scope_->file()); function_.ShortPrint(trace_scope_->file());
} else { } else {
PrintF(trace_scope_->file(), "%s", PrintF(trace_scope_->file(), "%s",
Code::Kind2String(compiled_code_->kind())); Code::Kind2String(compiled_code_.kind()));
} }
} }
@ -567,7 +566,7 @@ Address Deoptimizer::GetDeoptimizationEntry(Isolate* isolate,
DeoptimizerData* data = isolate->deoptimizer_data(); DeoptimizerData* data = isolate->deoptimizer_data();
CHECK_LE(kind, DeoptimizerData::kLastDeoptimizeKind); CHECK_LE(kind, DeoptimizerData::kLastDeoptimizeKind);
CHECK(!data->deopt_entry_code(kind).is_null()); CHECK(!data->deopt_entry_code(kind).is_null());
return data->deopt_entry_code(kind)->raw_instruction_start(); return data->deopt_entry_code(kind).raw_instruction_start();
} }
bool Deoptimizer::IsDeoptimizationEntry(Isolate* isolate, Address addr, bool Deoptimizer::IsDeoptimizationEntry(Isolate* isolate, Address addr,
@ -576,7 +575,7 @@ bool Deoptimizer::IsDeoptimizationEntry(Isolate* isolate, Address addr,
CHECK_LE(type, DeoptimizerData::kLastDeoptimizeKind); CHECK_LE(type, DeoptimizerData::kLastDeoptimizeKind);
Code code = data->deopt_entry_code(type); Code code = data->deopt_entry_code(type);
if (code.is_null()) return false; if (code.is_null()) return false;
return addr == code->raw_instruction_start(); return addr == code.raw_instruction_start();
} }
bool Deoptimizer::IsDeoptimizationEntry(Isolate* isolate, Address addr, bool Deoptimizer::IsDeoptimizationEntry(Isolate* isolate, Address addr,
@ -600,18 +599,18 @@ int Deoptimizer::GetDeoptimizedCodeCount(Isolate* isolate) {
int length = 0; int length = 0;
// Count all entries in the deoptimizing code list of every context. // Count all entries in the deoptimizing code list of every context.
Object context = isolate->heap()->native_contexts_list(); Object context = isolate->heap()->native_contexts_list();
while (!context->IsUndefined(isolate)) { while (!context.IsUndefined(isolate)) {
Context native_context = Context::cast(context); Context native_context = Context::cast(context);
Object element = native_context->DeoptimizedCodeListHead(); Object element = native_context.DeoptimizedCodeListHead();
while (!element->IsUndefined(isolate)) { while (!element.IsUndefined(isolate)) {
Code code = Code::cast(element); Code code = Code::cast(element);
DCHECK(code->kind() == Code::OPTIMIZED_FUNCTION); DCHECK(code.kind() == Code::OPTIMIZED_FUNCTION);
if (!code->marked_for_deoptimization()) { if (!code.marked_for_deoptimization()) {
length++; length++;
} }
element = code->next_code_link(); element = code.next_code_link();
} }
context = Context::cast(context)->next_context_link(); context = Context::cast(context).next_context_link();
} }
return length; return length;
} }
@ -623,7 +622,7 @@ int LookupCatchHandler(TranslatedFrame* translated_frame, int* data_out) {
case TranslatedFrame::kInterpretedFunction: { case TranslatedFrame::kInterpretedFunction: {
int bytecode_offset = translated_frame->node_id().ToInt(); int bytecode_offset = translated_frame->node_id().ToInt();
HandlerTable table( HandlerTable table(
translated_frame->raw_shared_info()->GetBytecodeArray()); translated_frame->raw_shared_info().GetBytecodeArray());
return table.LookupRange(bytecode_offset, data_out, nullptr); return table.LookupRange(bytecode_offset, data_out, nullptr);
} }
case TranslatedFrame::kJavaScriptBuiltinContinuationWithCatch: { case TranslatedFrame::kJavaScriptBuiltinContinuationWithCatch: {
@ -649,7 +648,7 @@ void Deoptimizer::DoComputeOutputFrames() {
// Determine basic deoptimization information. The optimized frame is // Determine basic deoptimization information. The optimized frame is
// described by the input data. // described by the input data.
DeoptimizationData input_data = DeoptimizationData input_data =
DeoptimizationData::cast(compiled_code_->deoptimization_data()); DeoptimizationData::cast(compiled_code_.deoptimization_data());
{ {
// Read caller's PC, caller's FP and caller's constant pool values // Read caller's PC, caller's FP and caller's constant pool values
@ -681,27 +680,26 @@ void Deoptimizer::DoComputeOutputFrames() {
PrintF(trace_scope_->file(), PrintF(trace_scope_->file(),
" (opt #%d) @%d, FP to SP delta: %d, caller sp: " V8PRIxPTR_FMT " (opt #%d) @%d, FP to SP delta: %d, caller sp: " V8PRIxPTR_FMT
"]\n", "]\n",
input_data->OptimizationId()->value(), bailout_id_, fp_to_sp_delta_, input_data.OptimizationId().value(), bailout_id_, fp_to_sp_delta_,
caller_frame_top_); caller_frame_top_);
if (deopt_kind_ == DeoptimizeKind::kEager || if (deopt_kind_ == DeoptimizeKind::kEager ||
deopt_kind_ == DeoptimizeKind::kSoft) { deopt_kind_ == DeoptimizeKind::kSoft) {
compiled_code_->PrintDeoptLocation( compiled_code_.PrintDeoptLocation(
trace_scope_->file(), " ;;; deoptimize at ", from_); trace_scope_->file(), " ;;; deoptimize at ", from_);
} }
} }
BailoutId node_id = input_data->BytecodeOffset(bailout_id_); BailoutId node_id = input_data.BytecodeOffset(bailout_id_);
ByteArray translations = input_data->TranslationByteArray(); ByteArray translations = input_data.TranslationByteArray();
unsigned translation_index = unsigned translation_index = input_data.TranslationIndex(bailout_id_).value();
input_data->TranslationIndex(bailout_id_)->value();
TranslationIterator state_iterator(translations, translation_index); TranslationIterator state_iterator(translations, translation_index);
translated_state_.Init( translated_state_.Init(
isolate_, input_->GetFramePointerAddress(), &state_iterator, isolate_, input_->GetFramePointerAddress(), &state_iterator,
input_data->LiteralArray(), input_->GetRegisterValues(), input_data.LiteralArray(), input_->GetRegisterValues(),
trace_scope_ == nullptr ? nullptr : trace_scope_->file(), trace_scope_ == nullptr ? nullptr : trace_scope_->file(),
function_->IsHeapObject() function_.IsHeapObject()
? function_->shared()->internal_formal_parameter_count() ? function_.shared().internal_formal_parameter_count()
: 0); : 0);
// Do the input frame to output frame(s) translation. // Do the input frame to output frame(s) translation.
@ -812,7 +810,7 @@ void Deoptimizer::DoComputeInterpretedFrame(TranslatedFrame* translated_frame,
TranslatedFrame::iterator function_iterator = value_iterator++; TranslatedFrame::iterator function_iterator = value_iterator++;
if (trace_scope_ != nullptr) { if (trace_scope_ != nullptr) {
PrintF(trace_scope_->file(), " translating interpreted frame "); PrintF(trace_scope_->file(), " translating interpreted frame ");
std::unique_ptr<char[]> name = shared->DebugName()->ToCString(); std::unique_ptr<char[]> name = shared.DebugName().ToCString();
PrintF(trace_scope_->file(), "%s", name.get()); PrintF(trace_scope_->file(), "%s", name.get());
PrintF(trace_scope_->file(), " => bytecode_offset=%d, height=%d%s\n", PrintF(trace_scope_->file(), " => bytecode_offset=%d, height=%d%s\n",
bytecode_offset, height_in_bytes, bytecode_offset, height_in_bytes,
@ -829,7 +827,7 @@ void Deoptimizer::DoComputeInterpretedFrame(TranslatedFrame* translated_frame,
unsigned output_frame_size = height_in_bytes + fixed_frame_size; unsigned output_frame_size = height_in_bytes + fixed_frame_size;
// Allocate and store the output frame description. // Allocate and store the output frame description.
int parameter_count = shared->internal_formal_parameter_count() + 1; int parameter_count = shared.internal_formal_parameter_count() + 1;
FrameDescription* output_frame = new (output_frame_size) FrameDescription* output_frame = new (output_frame_size)
FrameDescription(output_frame_size, parameter_count); FrameDescription(output_frame_size, parameter_count);
FrameWriter frame_writer(this, output_frame, trace_scope_); FrameWriter frame_writer(this, output_frame, trace_scope_);
@ -919,16 +917,16 @@ void Deoptimizer::DoComputeInterpretedFrame(TranslatedFrame* translated_frame,
} }
// Read the context from the translations. // Read the context from the translations.
Object context = context_pos->GetRawValue(); Object context = context_pos->GetRawValue();
output_frame->SetContext(static_cast<intptr_t>(context->ptr())); output_frame->SetContext(static_cast<intptr_t>(context.ptr()));
frame_writer.PushTranslatedValue(context_pos, "context"); frame_writer.PushTranslatedValue(context_pos, "context");
// The function was mentioned explicitly in the BEGIN_FRAME. // The function was mentioned explicitly in the BEGIN_FRAME.
frame_writer.PushTranslatedValue(function_iterator, "function"); frame_writer.PushTranslatedValue(function_iterator, "function");
// Set the bytecode array pointer. // Set the bytecode array pointer.
Object bytecode_array = shared->HasBreakInfo() Object bytecode_array = shared.HasBreakInfo()
? shared->GetDebugInfo()->DebugBytecodeArray() ? shared.GetDebugInfo().DebugBytecodeArray()
: shared->GetBytecodeArray(); : shared.GetBytecodeArray();
frame_writer.PushRawObject(bytecode_array, "bytecode array\n"); frame_writer.PushRawObject(bytecode_array, "bytecode array\n");
// The bytecode offset was mentioned explicitly in the BEGIN_FRAME. // The bytecode offset was mentioned explicitly in the BEGIN_FRAME.
@ -1029,12 +1027,12 @@ void Deoptimizer::DoComputeInterpretedFrame(TranslatedFrame* translated_frame,
? builtins->builtin(Builtins::kInterpreterEnterBytecodeAdvance) ? builtins->builtin(Builtins::kInterpreterEnterBytecodeAdvance)
: builtins->builtin(Builtins::kInterpreterEnterBytecodeDispatch); : builtins->builtin(Builtins::kInterpreterEnterBytecodeDispatch);
output_frame->SetPc( output_frame->SetPc(
static_cast<intptr_t>(dispatch_builtin->InstructionStart())); static_cast<intptr_t>(dispatch_builtin.InstructionStart()));
// Update constant pool. // Update constant pool.
if (FLAG_enable_embedded_constant_pool) { if (FLAG_enable_embedded_constant_pool) {
intptr_t constant_pool_value = intptr_t constant_pool_value =
static_cast<intptr_t>(dispatch_builtin->constant_pool()); static_cast<intptr_t>(dispatch_builtin.constant_pool());
output_frame->SetConstantPool(constant_pool_value); output_frame->SetConstantPool(constant_pool_value);
if (is_topmost) { if (is_topmost) {
Register constant_pool_reg = Register constant_pool_reg =
@ -1053,7 +1051,7 @@ void Deoptimizer::DoComputeInterpretedFrame(TranslatedFrame* translated_frame,
// Set the continuation for the topmost frame. // Set the continuation for the topmost frame.
Code continuation = builtins->builtin(Builtins::kNotifyDeoptimized); Code continuation = builtins->builtin(Builtins::kNotifyDeoptimized);
output_frame->SetContinuation( output_frame->SetContinuation(
static_cast<intptr_t>(continuation->InstructionStart())); static_cast<intptr_t>(continuation.InstructionStart()));
} }
} }
@ -1150,12 +1148,12 @@ void Deoptimizer::DoComputeArgumentsAdaptorFrame(
Code adaptor_trampoline = Code adaptor_trampoline =
builtins->builtin(Builtins::kArgumentsAdaptorTrampoline); builtins->builtin(Builtins::kArgumentsAdaptorTrampoline);
intptr_t pc_value = static_cast<intptr_t>( intptr_t pc_value = static_cast<intptr_t>(
adaptor_trampoline->InstructionStart() + adaptor_trampoline.InstructionStart() +
isolate_->heap()->arguments_adaptor_deopt_pc_offset()->value()); isolate_->heap()->arguments_adaptor_deopt_pc_offset().value());
output_frame->SetPc(pc_value); output_frame->SetPc(pc_value);
if (FLAG_enable_embedded_constant_pool) { if (FLAG_enable_embedded_constant_pool) {
intptr_t constant_pool_value = intptr_t constant_pool_value =
static_cast<intptr_t>(adaptor_trampoline->constant_pool()); static_cast<intptr_t>(adaptor_trampoline.constant_pool());
output_frame->SetConstantPool(constant_pool_value); output_frame->SetConstantPool(constant_pool_value);
} }
} }
@ -1297,18 +1295,18 @@ void Deoptimizer::DoComputeConstructStubFrame(TranslatedFrame* translated_frame,
// Compute this frame's PC. // Compute this frame's PC.
DCHECK(bailout_id.IsValidForConstructStub()); DCHECK(bailout_id.IsValidForConstructStub());
Address start = construct_stub->InstructionStart(); Address start = construct_stub.InstructionStart();
int pc_offset = int pc_offset =
bailout_id == BailoutId::ConstructStubCreate() bailout_id == BailoutId::ConstructStubCreate()
? isolate_->heap()->construct_stub_create_deopt_pc_offset()->value() ? isolate_->heap()->construct_stub_create_deopt_pc_offset().value()
: isolate_->heap()->construct_stub_invoke_deopt_pc_offset()->value(); : isolate_->heap()->construct_stub_invoke_deopt_pc_offset().value();
intptr_t pc_value = static_cast<intptr_t>(start + pc_offset); intptr_t pc_value = static_cast<intptr_t>(start + pc_offset);
output_frame->SetPc(pc_value); output_frame->SetPc(pc_value);
// Update constant pool. // Update constant pool.
if (FLAG_enable_embedded_constant_pool) { if (FLAG_enable_embedded_constant_pool) {
intptr_t constant_pool_value = intptr_t constant_pool_value =
static_cast<intptr_t>(construct_stub->constant_pool()); static_cast<intptr_t>(construct_stub.constant_pool());
output_frame->SetConstantPool(constant_pool_value); output_frame->SetConstantPool(constant_pool_value);
if (is_topmost) { if (is_topmost) {
Register constant_pool_reg = Register constant_pool_reg =
@ -1332,7 +1330,7 @@ void Deoptimizer::DoComputeConstructStubFrame(TranslatedFrame* translated_frame,
DCHECK_EQ(DeoptimizeKind::kLazy, deopt_kind_); DCHECK_EQ(DeoptimizeKind::kLazy, deopt_kind_);
Code continuation = builtins->builtin(Builtins::kNotifyDeoptimized); Code continuation = builtins->builtin(Builtins::kNotifyDeoptimized);
output_frame->SetContinuation( output_frame->SetContinuation(
static_cast<intptr_t>(continuation->InstructionStart())); static_cast<intptr_t>(continuation.InstructionStart()));
} }
} }
@ -1557,7 +1555,7 @@ void Deoptimizer::DoComputeBuiltinContinuation(
// Get the possible JSFunction for the case that this is a // Get the possible JSFunction for the case that this is a
// JavaScriptBuiltinContinuationFrame, which needs the JSFunction pointer // JavaScriptBuiltinContinuationFrame, which needs the JSFunction pointer
// like a normal JavaScriptFrame. // like a normal JavaScriptFrame.
const intptr_t maybe_function = value_iterator->GetRawValue()->ptr(); const intptr_t maybe_function = value_iterator->GetRawValue().ptr();
++value_iterator; ++value_iterator;
ReadOnlyRoots roots(isolate()); ReadOnlyRoots roots(isolate());
@ -1609,7 +1607,7 @@ void Deoptimizer::DoComputeBuiltinContinuation(
// set (it was automatically added at the end of the FrameState by the // set (it was automatically added at the end of the FrameState by the
// instruction selector). // instruction selector).
Object context = value_iterator->GetRawValue(); Object context = value_iterator->GetRawValue();
const intptr_t value = context->ptr(); const intptr_t value = context.ptr();
TranslatedFrame::iterator context_register_value = value_iterator++; TranslatedFrame::iterator context_register_value = value_iterator++;
register_values[kContextRegister.code()] = context_register_value; register_values[kContextRegister.code()] = context_register_value;
output_frame->SetContext(value); output_frame->SetContext(value);
@ -1723,12 +1721,12 @@ void Deoptimizer::DoComputeBuiltinContinuation(
Code continue_to_builtin = isolate()->builtins()->builtin( Code continue_to_builtin = isolate()->builtins()->builtin(
TrampolineForBuiltinContinuation(mode, must_handle_result)); TrampolineForBuiltinContinuation(mode, must_handle_result));
output_frame->SetPc( output_frame->SetPc(
static_cast<intptr_t>(continue_to_builtin->InstructionStart())); static_cast<intptr_t>(continue_to_builtin.InstructionStart()));
Code continuation = Code continuation =
isolate()->builtins()->builtin(Builtins::kNotifyDeoptimized); isolate()->builtins()->builtin(Builtins::kNotifyDeoptimized);
output_frame->SetContinuation( output_frame->SetContinuation(
static_cast<intptr_t>(continuation->InstructionStart())); static_cast<intptr_t>(continuation.InstructionStart()));
} }
void Deoptimizer::MaterializeHeapObjects() { void Deoptimizer::MaterializeHeapObjects() {
@ -1759,8 +1757,8 @@ void Deoptimizer::MaterializeHeapObjects() {
bool feedback_updated = translated_state_.DoUpdateFeedback(); bool feedback_updated = translated_state_.DoUpdateFeedback();
if (trace_scope_ != nullptr && feedback_updated) { if (trace_scope_ != nullptr && feedback_updated) {
PrintF(trace_scope_->file(), "Feedback updated"); PrintF(trace_scope_->file(), "Feedback updated");
compiled_code_->PrintDeoptLocation(trace_scope_->file(), compiled_code_.PrintDeoptLocation(trace_scope_->file(),
" from deoptimization at ", from_); " from deoptimization at ", from_);
} }
isolate_->materialized_object_store()->Remove( isolate_->materialized_object_store()->Remove(
@ -1779,8 +1777,8 @@ unsigned Deoptimizer::ComputeInputFrameAboveFpFixedSize() const {
unsigned fixed_size = CommonFrameConstants::kFixedFrameSizeAboveFp; unsigned fixed_size = CommonFrameConstants::kFixedFrameSizeAboveFp;
// TODO(jkummerow): If {function_->IsSmi()} can indeed be true, then // TODO(jkummerow): If {function_->IsSmi()} can indeed be true, then
// {function_} should not have type {JSFunction}. // {function_} should not have type {JSFunction}.
if (!function_->IsSmi()) { if (!function_.IsSmi()) {
fixed_size += ComputeIncomingArgumentSize(function_->shared()); fixed_size += ComputeIncomingArgumentSize(function_.shared());
} }
return fixed_size; return fixed_size;
} }
@ -1790,8 +1788,8 @@ unsigned Deoptimizer::ComputeInputFrameSize() const {
// function into account so we have to avoid double counting them. // function into account so we have to avoid double counting them.
unsigned fixed_size_above_fp = ComputeInputFrameAboveFpFixedSize(); unsigned fixed_size_above_fp = ComputeInputFrameAboveFpFixedSize();
unsigned result = fixed_size_above_fp + fp_to_sp_delta_; unsigned result = fixed_size_above_fp + fp_to_sp_delta_;
if (compiled_code_->kind() == Code::OPTIMIZED_FUNCTION) { if (compiled_code_.kind() == Code::OPTIMIZED_FUNCTION) {
unsigned stack_slots = compiled_code_->stack_slots(); unsigned stack_slots = compiled_code_.stack_slots();
unsigned outgoing_size = 0; unsigned outgoing_size = 0;
// ComputeOutgoingArgumentSize(compiled_code_, bailout_id_); // ComputeOutgoingArgumentSize(compiled_code_, bailout_id_);
CHECK_EQ(fixed_size_above_fp + (stack_slots * kSystemPointerSize) - CHECK_EQ(fixed_size_above_fp + (stack_slots * kSystemPointerSize) -
@ -1811,7 +1809,7 @@ unsigned Deoptimizer::ComputeInterpretedFixedSize(SharedFunctionInfo shared) {
// static // static
unsigned Deoptimizer::ComputeIncomingArgumentSize(SharedFunctionInfo shared) { unsigned Deoptimizer::ComputeIncomingArgumentSize(SharedFunctionInfo shared) {
int parameter_slots = shared->internal_formal_parameter_count() + 1; int parameter_slots = shared.internal_formal_parameter_count() + 1;
if (kPadArguments) parameter_slots = RoundUp(parameter_slots, 2); if (kPadArguments) parameter_slots = RoundUp(parameter_slots, 2);
return parameter_slots * kSystemPointerSize; return parameter_slots * kSystemPointerSize;
} }
@ -1895,7 +1893,7 @@ void TranslationBuffer::Add(int32_t value) {
TranslationIterator::TranslationIterator(ByteArray buffer, int index) TranslationIterator::TranslationIterator(ByteArray buffer, int index)
: buffer_(buffer), index_(index) { : buffer_(buffer), index_(index) {
DCHECK(index >= 0 && index < buffer->length()); DCHECK(index >= 0 && index < buffer.length());
} }
int32_t TranslationIterator::Next() { int32_t TranslationIterator::Next() {
@ -1904,7 +1902,7 @@ int32_t TranslationIterator::Next() {
uint32_t bits = 0; uint32_t bits = 0;
for (int i = 0; true; i += 7) { for (int i = 0; true; i += 7) {
DCHECK(HasNext()); DCHECK(HasNext());
uint8_t next = buffer_->get(index_++); uint8_t next = buffer_.get(index_++);
bits |= (next >> 1) << i; bits |= (next >> 1) << i;
if ((next & 1) == 0) break; if ((next & 1) == 0) break;
} }
@ -1914,7 +1912,7 @@ int32_t TranslationIterator::Next() {
return is_negative ? -result : result; return is_negative ? -result : result;
} }
bool TranslationIterator::HasNext() const { return index_ < buffer_->length(); } bool TranslationIterator::HasNext() const { return index_ < buffer_.length(); }
Handle<ByteArray> TranslationBuffer::CreateByteArray(Factory* factory) { Handle<ByteArray> TranslationBuffer::CreateByteArray(Factory* factory) {
Handle<ByteArray> result = Handle<ByteArray> result =
@ -2163,12 +2161,12 @@ bool MaterializedObjectStore::Remove(Address fp) {
frame_fps_.erase(it); frame_fps_.erase(it);
FixedArray array = isolate()->heap()->materialized_objects(); FixedArray array = isolate()->heap()->materialized_objects();
CHECK_LT(index, array->length()); CHECK_LT(index, array.length());
int fps_size = static_cast<int>(frame_fps_.size()); int fps_size = static_cast<int>(frame_fps_.size());
for (int i = index; i < fps_size; i++) { for (int i = index; i < fps_size; i++) {
array->set(i, array->get(i + 1)); array.set(i, array.get(i + 1));
} }
array->set(fps_size, ReadOnlyRoots(isolate()).undefined_value()); array.set(fps_size, ReadOnlyRoots(isolate()).undefined_value());
return true; return true;
} }
@ -2241,7 +2239,7 @@ DeoptimizedFrameInfo::DeoptimizedFrameInfo(TranslatedState* state,
*frame_it->shared_info(), frame_it->node_id()); *frame_it->shared_info(), frame_it->node_id());
DCHECK_EQ(parameter_count, DCHECK_EQ(parameter_count,
function_->shared()->internal_formal_parameter_count()); function_->shared().internal_formal_parameter_count());
parameters_.resize(static_cast<size_t>(parameter_count)); parameters_.resize(static_cast<size_t>(parameter_count));
for (int i = 0; i < parameter_count; i++) { for (int i = 0; i < parameter_count; i++) {
@ -2276,7 +2274,7 @@ DeoptimizedFrameInfo::DeoptimizedFrameInfo(TranslatedState* state,
} }
Deoptimizer::DeoptInfo Deoptimizer::GetDeoptInfo(Code code, Address pc) { Deoptimizer::DeoptInfo Deoptimizer::GetDeoptInfo(Code code, Address pc) {
CHECK(code->InstructionStart() <= pc && pc <= code->InstructionEnd()); CHECK(code.InstructionStart() <= pc && pc <= code.InstructionEnd());
SourcePosition last_position = SourcePosition::Unknown(); SourcePosition last_position = SourcePosition::Unknown();
DeoptimizeReason last_reason = DeoptimizeReason::kUnknown; DeoptimizeReason last_reason = DeoptimizeReason::kUnknown;
int last_deopt_id = kNoDeoptimizationId; int last_deopt_id = kNoDeoptimizationId;
@ -2305,9 +2303,9 @@ Deoptimizer::DeoptInfo Deoptimizer::GetDeoptInfo(Code code, Address pc) {
// static // static
int Deoptimizer::ComputeSourcePositionFromBytecodeArray( int Deoptimizer::ComputeSourcePositionFromBytecodeArray(
SharedFunctionInfo shared, BailoutId node_id) { SharedFunctionInfo shared, BailoutId node_id) {
DCHECK(shared->HasBytecodeArray()); DCHECK(shared.HasBytecodeArray());
return AbstractCode::cast(shared->GetBytecodeArray()) return AbstractCode::cast(shared.GetBytecodeArray())
->SourcePosition(node_id.ToInt()); .SourcePosition(node_id.ToInt());
} }
// static // static
@ -2692,7 +2690,7 @@ int TranslatedFrame::GetValueCount() {
switch (kind()) { switch (kind()) {
case kInterpretedFunction: { case kInterpretedFunction: {
int parameter_count = int parameter_count =
raw_shared_info_->internal_formal_parameter_count() + 1; raw_shared_info_.internal_formal_parameter_count() + 1;
// + 2 for function and context. // + 2 for function and context.
return height_ + parameter_count + 2; return height_ + parameter_count + 2;
} }
@ -2713,7 +2711,7 @@ int TranslatedFrame::GetValueCount() {
void TranslatedFrame::Handlify() { void TranslatedFrame::Handlify() {
if (!raw_shared_info_.is_null()) { if (!raw_shared_info_.is_null()) {
shared_info_ = Handle<SharedFunctionInfo>(raw_shared_info_, shared_info_ = Handle<SharedFunctionInfo>(raw_shared_info_,
raw_shared_info_->GetIsolate()); raw_shared_info_.GetIsolate());
raw_shared_info_ = SharedFunctionInfo(); raw_shared_info_ = SharedFunctionInfo();
} }
for (auto& value : values_) { for (auto& value : values_) {
@ -2730,14 +2728,14 @@ TranslatedFrame TranslatedState::CreateNextTranslatedFrame(
case Translation::INTERPRETED_FRAME: { case Translation::INTERPRETED_FRAME: {
BailoutId bytecode_offset = BailoutId(iterator->Next()); BailoutId bytecode_offset = BailoutId(iterator->Next());
SharedFunctionInfo shared_info = SharedFunctionInfo shared_info =
SharedFunctionInfo::cast(literal_array->get(iterator->Next())); SharedFunctionInfo::cast(literal_array.get(iterator->Next()));
int height = iterator->Next(); int height = iterator->Next();
int return_value_offset = iterator->Next(); int return_value_offset = iterator->Next();
int return_value_count = iterator->Next(); int return_value_count = iterator->Next();
if (trace_file != nullptr) { if (trace_file != nullptr) {
std::unique_ptr<char[]> name = shared_info->DebugName()->ToCString(); std::unique_ptr<char[]> name = shared_info.DebugName().ToCString();
PrintF(trace_file, " reading input frame %s", name.get()); PrintF(trace_file, " reading input frame %s", name.get());
int arg_count = shared_info->internal_formal_parameter_count() + 1; int arg_count = shared_info.internal_formal_parameter_count() + 1;
PrintF(trace_file, PrintF(trace_file,
" => bytecode_offset=%d, args=%d, height=%d, retval=%i(#%i); " " => bytecode_offset=%d, args=%d, height=%d, retval=%i(#%i); "
"inputs:\n", "inputs:\n",
@ -2751,10 +2749,10 @@ TranslatedFrame TranslatedState::CreateNextTranslatedFrame(
case Translation::ARGUMENTS_ADAPTOR_FRAME: { case Translation::ARGUMENTS_ADAPTOR_FRAME: {
SharedFunctionInfo shared_info = SharedFunctionInfo shared_info =
SharedFunctionInfo::cast(literal_array->get(iterator->Next())); SharedFunctionInfo::cast(literal_array.get(iterator->Next()));
int height = iterator->Next(); int height = iterator->Next();
if (trace_file != nullptr) { if (trace_file != nullptr) {
std::unique_ptr<char[]> name = shared_info->DebugName()->ToCString(); std::unique_ptr<char[]> name = shared_info.DebugName().ToCString();
PrintF(trace_file, " reading arguments adaptor frame %s", name.get()); PrintF(trace_file, " reading arguments adaptor frame %s", name.get());
PrintF(trace_file, " => height=%d; inputs:\n", height); PrintF(trace_file, " => height=%d; inputs:\n", height);
} }
@ -2764,10 +2762,10 @@ TranslatedFrame TranslatedState::CreateNextTranslatedFrame(
case Translation::CONSTRUCT_STUB_FRAME: { case Translation::CONSTRUCT_STUB_FRAME: {
BailoutId bailout_id = BailoutId(iterator->Next()); BailoutId bailout_id = BailoutId(iterator->Next());
SharedFunctionInfo shared_info = SharedFunctionInfo shared_info =
SharedFunctionInfo::cast(literal_array->get(iterator->Next())); SharedFunctionInfo::cast(literal_array.get(iterator->Next()));
int height = iterator->Next(); int height = iterator->Next();
if (trace_file != nullptr) { if (trace_file != nullptr) {
std::unique_ptr<char[]> name = shared_info->DebugName()->ToCString(); std::unique_ptr<char[]> name = shared_info.DebugName().ToCString();
PrintF(trace_file, " reading construct stub frame %s", name.get()); PrintF(trace_file, " reading construct stub frame %s", name.get());
PrintF(trace_file, " => bailout_id=%d, height=%d; inputs:\n", PrintF(trace_file, " => bailout_id=%d, height=%d; inputs:\n",
bailout_id.ToInt(), height); bailout_id.ToInt(), height);
@ -2779,10 +2777,10 @@ TranslatedFrame TranslatedState::CreateNextTranslatedFrame(
case Translation::BUILTIN_CONTINUATION_FRAME: { case Translation::BUILTIN_CONTINUATION_FRAME: {
BailoutId bailout_id = BailoutId(iterator->Next()); BailoutId bailout_id = BailoutId(iterator->Next());
SharedFunctionInfo shared_info = SharedFunctionInfo shared_info =
SharedFunctionInfo::cast(literal_array->get(iterator->Next())); SharedFunctionInfo::cast(literal_array.get(iterator->Next()));
int height = iterator->Next(); int height = iterator->Next();
if (trace_file != nullptr) { if (trace_file != nullptr) {
std::unique_ptr<char[]> name = shared_info->DebugName()->ToCString(); std::unique_ptr<char[]> name = shared_info.DebugName().ToCString();
PrintF(trace_file, " reading builtin continuation frame %s", PrintF(trace_file, " reading builtin continuation frame %s",
name.get()); name.get());
PrintF(trace_file, " => bailout_id=%d, height=%d; inputs:\n", PrintF(trace_file, " => bailout_id=%d, height=%d; inputs:\n",
@ -2798,10 +2796,10 @@ TranslatedFrame TranslatedState::CreateNextTranslatedFrame(
case Translation::JAVA_SCRIPT_BUILTIN_CONTINUATION_FRAME: { case Translation::JAVA_SCRIPT_BUILTIN_CONTINUATION_FRAME: {
BailoutId bailout_id = BailoutId(iterator->Next()); BailoutId bailout_id = BailoutId(iterator->Next());
SharedFunctionInfo shared_info = SharedFunctionInfo shared_info =
SharedFunctionInfo::cast(literal_array->get(iterator->Next())); SharedFunctionInfo::cast(literal_array.get(iterator->Next()));
int height = iterator->Next(); int height = iterator->Next();
if (trace_file != nullptr) { if (trace_file != nullptr) {
std::unique_ptr<char[]> name = shared_info->DebugName()->ToCString(); std::unique_ptr<char[]> name = shared_info.DebugName().ToCString();
PrintF(trace_file, " reading JavaScript builtin continuation frame %s", PrintF(trace_file, " reading JavaScript builtin continuation frame %s",
name.get()); name.get());
PrintF(trace_file, " => bailout_id=%d, height=%d; inputs:\n", PrintF(trace_file, " => bailout_id=%d, height=%d; inputs:\n",
@ -2816,10 +2814,10 @@ TranslatedFrame TranslatedState::CreateNextTranslatedFrame(
case Translation::JAVA_SCRIPT_BUILTIN_CONTINUATION_WITH_CATCH_FRAME: { case Translation::JAVA_SCRIPT_BUILTIN_CONTINUATION_WITH_CATCH_FRAME: {
BailoutId bailout_id = BailoutId(iterator->Next()); BailoutId bailout_id = BailoutId(iterator->Next());
SharedFunctionInfo shared_info = SharedFunctionInfo shared_info =
SharedFunctionInfo::cast(literal_array->get(iterator->Next())); SharedFunctionInfo::cast(literal_array.get(iterator->Next()));
int height = iterator->Next(); int height = iterator->Next();
if (trace_file != nullptr) { if (trace_file != nullptr) {
std::unique_ptr<char[]> name = shared_info->DebugName()->ToCString(); std::unique_ptr<char[]> name = shared_info.DebugName().ToCString();
PrintF(trace_file, PrintF(trace_file,
" reading JavaScript builtin continuation frame with catch %s", " reading JavaScript builtin continuation frame with catch %s",
name.get()); name.get());
@ -2888,7 +2886,7 @@ Address TranslatedState::ComputeArgumentsPosition(Address input_frame_pointer,
*length = Smi::cast(*FullObjectSlot( *length = Smi::cast(*FullObjectSlot(
parent_frame_pointer + parent_frame_pointer +
ArgumentsAdaptorFrameConstants::kLengthOffset)) ArgumentsAdaptorFrameConstants::kLengthOffset))
->value(); .value();
arguments_frame = parent_frame_pointer; arguments_frame = parent_frame_pointer;
} else { } else {
if (length) *length = formal_parameter_count_; if (length) *length = formal_parameter_count_;
@ -3044,7 +3042,7 @@ int TranslatedState::CreateNextTranslatedValue(
if (trace_file != nullptr) { if (trace_file != nullptr) {
PrintF(trace_file, V8PRIxPTR_FMT " ; %s ", uncompressed_value, PrintF(trace_file, V8PRIxPTR_FMT " ; %s ", uncompressed_value,
converter.NameOfCPURegister(input_reg)); converter.NameOfCPURegister(input_reg));
Object(uncompressed_value)->ShortPrint(trace_file); Object(uncompressed_value).ShortPrint(trace_file);
} }
TranslatedValue translated_value = TranslatedValue translated_value =
TranslatedValue::NewTagged(this, Object(uncompressed_value)); TranslatedValue::NewTagged(this, Object(uncompressed_value));
@ -3173,7 +3171,7 @@ int TranslatedState::CreateNextTranslatedValue(
PrintF(trace_file, V8PRIxPTR_FMT " ; [fp %c %3d] ", PrintF(trace_file, V8PRIxPTR_FMT " ; [fp %c %3d] ",
uncompressed_value, slot_offset < 0 ? '-' : '+', uncompressed_value, slot_offset < 0 ? '-' : '+',
std::abs(slot_offset)); std::abs(slot_offset));
Object(uncompressed_value)->ShortPrint(trace_file); Object(uncompressed_value).ShortPrint(trace_file);
} }
TranslatedValue translated_value = TranslatedValue translated_value =
TranslatedValue::NewTagged(this, Object(uncompressed_value)); TranslatedValue::NewTagged(this, Object(uncompressed_value));
@ -3265,11 +3263,11 @@ int TranslatedState::CreateNextTranslatedValue(
case Translation::LITERAL: { case Translation::LITERAL: {
int literal_index = iterator->Next(); int literal_index = iterator->Next();
Object value = literal_array->get(literal_index); Object value = literal_array.get(literal_index);
if (trace_file != nullptr) { if (trace_file != nullptr) {
PrintF(trace_file, V8PRIxPTR_FMT " ; (literal %2d) ", value->ptr(), PrintF(trace_file, V8PRIxPTR_FMT " ; (literal %2d) ", value.ptr(),
literal_index); literal_index);
value->ShortPrint(trace_file); value.ShortPrint(trace_file);
} }
TranslatedValue translated_value = TranslatedValue translated_value =
@ -3288,11 +3286,11 @@ TranslatedState::TranslatedState(const JavaScriptFrame* frame) {
static_cast<const OptimizedFrame*>(frame)->GetDeoptimizationData( static_cast<const OptimizedFrame*>(frame)->GetDeoptimizationData(
&deopt_index); &deopt_index);
DCHECK(!data.is_null() && deopt_index != Safepoint::kNoDeoptimizationIndex); DCHECK(!data.is_null() && deopt_index != Safepoint::kNoDeoptimizationIndex);
TranslationIterator it(data->TranslationByteArray(), TranslationIterator it(data.TranslationByteArray(),
data->TranslationIndex(deopt_index)->value()); data.TranslationIndex(deopt_index).value());
Init(frame->isolate(), frame->fp(), &it, data->LiteralArray(), Init(frame->isolate(), frame->fp(), &it, data.LiteralArray(),
nullptr /* registers */, nullptr /* trace file */, nullptr /* registers */, nullptr /* trace file */,
frame->function()->shared()->internal_formal_parameter_count()); frame->function().shared().internal_formal_parameter_count());
} }
void TranslatedState::Init(Isolate* isolate, Address input_frame_pointer, void TranslatedState::Init(Isolate* isolate, Address input_frame_pointer,
@ -3510,7 +3508,7 @@ void TranslatedState::MaterializeFixedDoubleArray(TranslatedFrame* frame,
int* value_index, int* value_index,
TranslatedValue* slot, TranslatedValue* slot,
Handle<Map> map) { Handle<Map> map) {
int length = Smi::cast(frame->values_[*value_index].GetRawValue())->value(); int length = Smi::cast(frame->values_[*value_index].GetRawValue()).value();
(*value_index)++; (*value_index)++;
Handle<FixedDoubleArray> array = Handle<FixedDoubleArray>::cast( Handle<FixedDoubleArray> array = Handle<FixedDoubleArray>::cast(
isolate()->factory()->NewFixedDoubleArray(length)); isolate()->factory()->NewFixedDoubleArray(length));
@ -3621,13 +3619,13 @@ void TranslatedState::EnsureCapturedObjectAllocatedAt(
case STRING_TABLE_TYPE: { case STRING_TABLE_TYPE: {
// Check we have the right size. // Check we have the right size.
int array_length = int array_length =
Smi::cast(frame->values_[value_index].GetRawValue())->value(); Smi::cast(frame->values_[value_index].GetRawValue()).value();
int instance_size = FixedArray::SizeFor(array_length); int instance_size = FixedArray::SizeFor(array_length);
CHECK_EQ(instance_size, slot->GetChildrenCount() * kTaggedSize); CHECK_EQ(instance_size, slot->GetChildrenCount() * kTaggedSize);
// Canonicalize empty fixed array. // Canonicalize empty fixed array.
if (*map == ReadOnlyRoots(isolate()).empty_fixed_array()->map() && if (*map == ReadOnlyRoots(isolate()).empty_fixed_array().map() &&
array_length == 0) { array_length == 0) {
slot->set_storage(isolate()->factory()->empty_fixed_array()); slot->set_storage(isolate()->factory()->empty_fixed_array());
} else { } else {
@ -3642,7 +3640,7 @@ void TranslatedState::EnsureCapturedObjectAllocatedAt(
case PROPERTY_ARRAY_TYPE: { case PROPERTY_ARRAY_TYPE: {
// Check we have the right size. // Check we have the right size.
int length_or_hash = int length_or_hash =
Smi::cast(frame->values_[value_index].GetRawValue())->value(); Smi::cast(frame->values_[value_index].GetRawValue()).value();
int array_length = PropertyArray::LengthField::decode(length_or_hash); int array_length = PropertyArray::LengthField::decode(length_or_hash);
int instance_size = PropertyArray::SizeFor(array_length); int instance_size = PropertyArray::SizeFor(array_length);
CHECK_EQ(instance_size, slot->GetChildrenCount() * kTaggedSize); CHECK_EQ(instance_size, slot->GetChildrenCount() * kTaggedSize);
@ -3808,10 +3806,10 @@ void TranslatedState::InitializeJSObjectAt(
if (marker == kStoreUnboxedDouble) { if (marker == kStoreUnboxedDouble) {
double double_field_value; double double_field_value;
if (field_value->IsSmi()) { if (field_value->IsSmi()) {
double_field_value = Smi::cast(*field_value)->value(); double_field_value = Smi::cast(*field_value).value();
} else { } else {
CHECK(field_value->IsHeapNumber()); CHECK(field_value->IsHeapNumber());
double_field_value = HeapNumber::cast(*field_value)->value(); double_field_value = HeapNumber::cast(*field_value).value();
} }
object_storage->WriteField<double>(offset, double_field_value); object_storage->WriteField<double>(offset, double_field_value);
} else if (marker == kStoreMutableHeapNumber) { } else if (marker == kStoreMutableHeapNumber) {
@ -4030,7 +4028,7 @@ void TranslatedState::ReadUpdateFeedback(TranslationIterator* iterator,
FixedArray literal_array, FixedArray literal_array,
FILE* trace_file) { FILE* trace_file) {
CHECK_EQ(Translation::UPDATE_FEEDBACK, iterator->Next()); CHECK_EQ(Translation::UPDATE_FEEDBACK, iterator->Next());
feedback_vector_ = FeedbackVector::cast(literal_array->get(iterator->Next())); feedback_vector_ = FeedbackVector::cast(literal_array.get(iterator->Next()));
feedback_slot_ = FeedbackSlot(iterator->Next()); feedback_slot_ = FeedbackSlot(iterator->Next());
if (trace_file != nullptr) { if (trace_file != nullptr) {
PrintF(trace_file, " reading FeedbackVector (slot %d)\n", PrintF(trace_file, " reading FeedbackVector (slot %d)\n",

View File

@ -221,7 +221,7 @@ static void PrintRelocInfo(StringBuilder* out, Isolate* isolate,
} else if (RelocInfo::IsEmbeddedObjectMode(rmode)) { } else if (RelocInfo::IsEmbeddedObjectMode(rmode)) {
HeapStringAllocator allocator; HeapStringAllocator allocator;
StringStream accumulator(&allocator); StringStream accumulator(&allocator);
relocinfo->target_object()->ShortPrint(&accumulator); relocinfo->target_object().ShortPrint(&accumulator);
std::unique_ptr<char[]> obj_name = accumulator.ToCString(); std::unique_ptr<char[]> obj_name = accumulator.ToCString();
const bool is_compressed = RelocInfo::IsCompressedEmbeddedObject(rmode); const bool is_compressed = RelocInfo::IsCompressedEmbeddedObject(rmode);
out->AddFormatted(" ;; %sobject: %s", out->AddFormatted(" ;; %sobject: %s",
@ -236,9 +236,9 @@ static void PrintRelocInfo(StringBuilder* out, Isolate* isolate,
out->AddFormatted(" ;; code:"); out->AddFormatted(" ;; code:");
Code code = isolate->heap()->GcSafeFindCodeForInnerPointer( Code code = isolate->heap()->GcSafeFindCodeForInnerPointer(
relocinfo->target_address()); relocinfo->target_address());
Code::Kind kind = code->kind(); Code::Kind kind = code.kind();
if (code->is_builtin()) { if (code.is_builtin()) {
out->AddFormatted(" Builtin::%s", Builtins::name(code->builtin_index())); out->AddFormatted(" Builtin::%s", Builtins::name(code.builtin_index()));
} else { } else {
out->AddFormatted(" %s", Code::Kind2String(kind)); out->AddFormatted(" %s", Code::Kind2String(kind));
} }

View File

@ -902,7 +902,7 @@ class CodeDescription {
LineInfo* lineinfo() const { return lineinfo_; } LineInfo* lineinfo() const { return lineinfo_; }
bool is_function() const { bool is_function() const {
Code::Kind kind = code_->kind(); Code::Kind kind = code_.kind();
return kind == Code::OPTIMIZED_FUNCTION; return kind == Code::OPTIMIZED_FUNCTION;
} }
@ -910,24 +910,24 @@ class CodeDescription {
ScopeInfo scope_info() const { ScopeInfo scope_info() const {
DCHECK(has_scope_info()); DCHECK(has_scope_info());
return shared_info_->scope_info(); return shared_info_.scope_info();
} }
uintptr_t CodeStart() const { uintptr_t CodeStart() const {
return static_cast<uintptr_t>(code_->InstructionStart()); return static_cast<uintptr_t>(code_.InstructionStart());
} }
uintptr_t CodeEnd() const { uintptr_t CodeEnd() const {
return static_cast<uintptr_t>(code_->InstructionEnd()); return static_cast<uintptr_t>(code_.InstructionEnd());
} }
uintptr_t CodeSize() const { return CodeEnd() - CodeStart(); } uintptr_t CodeSize() const { return CodeEnd() - CodeStart(); }
bool has_script() { bool has_script() {
return !shared_info_.is_null() && shared_info_->script()->IsScript(); return !shared_info_.is_null() && shared_info_.script().IsScript();
} }
Script script() { return Script::cast(shared_info_->script()); } Script script() { return Script::cast(shared_info_.script()); }
bool IsLineInfoAvailable() { return lineinfo_ != nullptr; } bool IsLineInfoAvailable() { return lineinfo_ != nullptr; }
@ -945,7 +945,7 @@ class CodeDescription {
std::unique_ptr<char[]> GetFilename() { std::unique_ptr<char[]> GetFilename() {
if (!shared_info_.is_null()) { if (!shared_info_.is_null()) {
return String::cast(script()->name())->ToCString(); return String::cast(script().name()).ToCString();
} else { } else {
std::unique_ptr<char[]> result(new char[1]); std::unique_ptr<char[]> result(new char[1]);
result[0] = 0; result[0] = 0;
@ -955,7 +955,7 @@ class CodeDescription {
int GetScriptLineNumber(int pos) { int GetScriptLineNumber(int pos) {
if (!shared_info_.is_null()) { if (!shared_info_.is_null()) {
return script()->GetLineNumber(pos) + 1; return script().GetLineNumber(pos) + 1;
} else { } else {
return 0; return 0;
} }
@ -1087,8 +1087,8 @@ class DebugInfoSection : public DebugSection {
#endif #endif
fb_block_size.set(static_cast<uint32_t>(w->position() - fb_block_start)); fb_block_size.set(static_cast<uint32_t>(w->position() - fb_block_start));
int params = scope->ParameterCount(); int params = scope.ParameterCount();
int context_slots = scope->ContextLocalCount(); int context_slots = scope.ContextLocalCount();
// The real slot ID is internal_slots + context_slot_id. // The real slot ID is internal_slots + context_slot_id.
int internal_slots = Context::MIN_CONTEXT_SLOTS; int internal_slots = Context::MIN_CONTEXT_SLOTS;
int current_abbreviation = 4; int current_abbreviation = 4;
@ -1254,8 +1254,8 @@ class DebugAbbrevSection : public DebugSection {
if (extra_info) { if (extra_info) {
ScopeInfo scope = desc_->scope_info(); ScopeInfo scope = desc_->scope_info();
int params = scope->ParameterCount(); int params = scope.ParameterCount();
int context_slots = scope->ContextLocalCount(); int context_slots = scope.ContextLocalCount();
// The real slot ID is internal_slots + context_slot_id. // The real slot ID is internal_slots + context_slot_id.
int internal_slots = Context::MIN_CONTEXT_SLOTS; int internal_slots = Context::MIN_CONTEXT_SLOTS;
// Total children is params + context_slots + internal_slots + 2 // Total children is params + context_slots + internal_slots + 2
@ -1737,7 +1737,7 @@ JITDescriptor __jit_debug_descriptor = {1, 0, nullptr, nullptr};
#ifdef OBJECT_PRINT #ifdef OBJECT_PRINT
void __gdb_print_v8_object(Object object) { void __gdb_print_v8_object(Object object) {
StdoutStream os; StdoutStream os;
object->Print(os); object.Print(os);
os << std::flush; os << std::flush;
} }
#endif #endif
@ -1969,8 +1969,8 @@ static void AddCode(const char* name, Code code, SharedFunctionInfo shared,
CodeMap* code_map = GetCodeMap(); CodeMap* code_map = GetCodeMap();
AddressRange range; AddressRange range;
range.start = code->address(); range.start = code.address();
range.end = code->address() + code->CodeSize(); range.end = code.address() + code.CodeSize();
RemoveJITCodeEntries(code_map, range); RemoveJITCodeEntries(code_map, range);
CodeDescription code_desc(name, code, shared, lineinfo); CodeDescription code_desc(name, code, shared, lineinfo);
@ -1981,7 +1981,7 @@ static void AddCode(const char* name, Code code, SharedFunctionInfo shared,
} }
AddUnwindInfo(&code_desc); AddUnwindInfo(&code_desc);
Isolate* isolate = code->GetIsolate(); Isolate* isolate = code.GetIsolate();
JITCodeEntry* entry = CreateELFObject(&code_desc, isolate); JITCodeEntry* entry = CreateELFObject(&code_desc, isolate);
delete lineinfo; delete lineinfo;

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -201,8 +201,8 @@ void PerfJitLogger::LogRecordedBuffer(AbstractCode abstract_code,
SharedFunctionInfo shared, SharedFunctionInfo shared,
const char* name, int length) { const char* name, int length) {
if (FLAG_perf_basic_prof_only_functions && if (FLAG_perf_basic_prof_only_functions &&
(abstract_code->kind() != AbstractCode::INTERPRETED_FUNCTION && (abstract_code.kind() != AbstractCode::INTERPRETED_FUNCTION &&
abstract_code->kind() != AbstractCode::OPTIMIZED_FUNCTION)) { abstract_code.kind() != AbstractCode::OPTIMIZED_FUNCTION)) {
return; return;
} }
@ -211,25 +211,25 @@ void PerfJitLogger::LogRecordedBuffer(AbstractCode abstract_code,
if (perf_output_handle_ == nullptr) return; if (perf_output_handle_ == nullptr) return;
// We only support non-interpreted functions. // We only support non-interpreted functions.
if (!abstract_code->IsCode()) return; if (!abstract_code.IsCode()) return;
Code code = abstract_code->GetCode(); Code code = abstract_code.GetCode();
DCHECK(code->raw_instruction_start() == code->address() + Code::kHeaderSize); DCHECK(code.raw_instruction_start() == code.address() + Code::kHeaderSize);
// Debug info has to be emitted first. // Debug info has to be emitted first.
if (FLAG_perf_prof && !shared.is_null()) { if (FLAG_perf_prof && !shared.is_null()) {
// TODO(herhut): This currently breaks for js2wasm/wasm2js functions. // TODO(herhut): This currently breaks for js2wasm/wasm2js functions.
if (code->kind() != Code::JS_TO_WASM_FUNCTION && if (code.kind() != Code::JS_TO_WASM_FUNCTION &&
code->kind() != Code::WASM_TO_JS_FUNCTION) { code.kind() != Code::WASM_TO_JS_FUNCTION) {
LogWriteDebugInfo(code, shared); LogWriteDebugInfo(code, shared);
} }
} }
const char* code_name = name; const char* code_name = name;
uint8_t* code_pointer = reinterpret_cast<uint8_t*>(code->InstructionStart()); uint8_t* code_pointer = reinterpret_cast<uint8_t*>(code.InstructionStart());
// Code generated by Turbofan will have the safepoint table directly after // Code generated by Turbofan will have the safepoint table directly after
// instructions. There is no need to record the safepoint table itself. // instructions. There is no need to record the safepoint table itself.
uint32_t code_size = code->ExecutableInstructionSize(); uint32_t code_size = code.ExecutableInstructionSize();
// Unwinding info comes right after debug info. // Unwinding info comes right after debug info.
if (FLAG_perf_prof_unwinding_info) LogWriteUnwindingInfo(code); if (FLAG_perf_prof_unwinding_info) LogWriteUnwindingInfo(code);
@ -281,11 +281,11 @@ constexpr size_t kUnknownScriptNameStringLen =
size_t GetScriptNameLength(const SourcePositionInfo& info) { size_t GetScriptNameLength(const SourcePositionInfo& info) {
if (!info.script.is_null()) { if (!info.script.is_null()) {
Object name_or_url = info.script->GetNameOrSourceURL(); Object name_or_url = info.script->GetNameOrSourceURL();
if (name_or_url->IsString()) { if (name_or_url.IsString()) {
String str = String::cast(name_or_url); String str = String::cast(name_or_url);
if (str->IsOneByteRepresentation()) return str->length(); if (str.IsOneByteRepresentation()) return str.length();
int length; int length;
str->ToCString(DISALLOW_NULLS, FAST_STRING_TRAVERSAL, &length); str.ToCString(DISALLOW_NULLS, FAST_STRING_TRAVERSAL, &length);
return static_cast<size_t>(length); return static_cast<size_t>(length);
} }
} }
@ -297,15 +297,14 @@ Vector<const char> GetScriptName(const SourcePositionInfo& info,
const DisallowHeapAllocation& no_gc) { const DisallowHeapAllocation& no_gc) {
if (!info.script.is_null()) { if (!info.script.is_null()) {
Object name_or_url = info.script->GetNameOrSourceURL(); Object name_or_url = info.script->GetNameOrSourceURL();
if (name_or_url->IsSeqOneByteString()) { if (name_or_url.IsSeqOneByteString()) {
SeqOneByteString str = SeqOneByteString::cast(name_or_url); SeqOneByteString str = SeqOneByteString::cast(name_or_url);
return {reinterpret_cast<char*>(str->GetChars(no_gc)), return {reinterpret_cast<char*>(str.GetChars(no_gc)),
static_cast<size_t>(str->length())}; static_cast<size_t>(str.length())};
} else if (name_or_url->IsString()) { } else if (name_or_url.IsString()) {
int length; int length;
*storage = *storage = String::cast(name_or_url)
String::cast(name_or_url) .ToCString(DISALLOW_NULLS, FAST_STRING_TRAVERSAL, &length);
->ToCString(DISALLOW_NULLS, FAST_STRING_TRAVERSAL, &length);
return {storage->get(), static_cast<size_t>(length)}; return {storage->get(), static_cast<size_t>(length)};
} }
} }
@ -328,21 +327,21 @@ SourcePositionInfo GetSourcePositionInfo(Handle<Code> code,
void PerfJitLogger::LogWriteDebugInfo(Code code, SharedFunctionInfo shared) { void PerfJitLogger::LogWriteDebugInfo(Code code, SharedFunctionInfo shared) {
// Compute the entry count and get the name of the script. // Compute the entry count and get the name of the script.
uint32_t entry_count = 0; uint32_t entry_count = 0;
for (SourcePositionTableIterator iterator(code->SourcePositionTable()); for (SourcePositionTableIterator iterator(code.SourcePositionTable());
!iterator.done(); iterator.Advance()) { !iterator.done(); iterator.Advance()) {
entry_count++; entry_count++;
} }
if (entry_count == 0) return; if (entry_count == 0) return;
// The WasmToJS wrapper stubs have source position entries. // The WasmToJS wrapper stubs have source position entries.
if (!shared->HasSourceCode()) return; if (!shared.HasSourceCode()) return;
Isolate* isolate = shared->GetIsolate(); Isolate* isolate = shared.GetIsolate();
Handle<Script> script(Script::cast(shared->script()), isolate); Handle<Script> script(Script::cast(shared.script()), isolate);
PerfJitCodeDebugInfo debug_info; PerfJitCodeDebugInfo debug_info;
debug_info.event_ = PerfJitCodeLoad::kDebugInfo; debug_info.event_ = PerfJitCodeLoad::kDebugInfo;
debug_info.time_stamp_ = GetTimestamp(); debug_info.time_stamp_ = GetTimestamp();
debug_info.address_ = code->InstructionStart(); debug_info.address_ = code.InstructionStart();
debug_info.entry_count_ = entry_count; debug_info.entry_count_ = entry_count;
uint32_t size = sizeof(debug_info); uint32_t size = sizeof(debug_info);
@ -352,7 +351,7 @@ void PerfJitLogger::LogWriteDebugInfo(Code code, SharedFunctionInfo shared) {
Handle<Code> code_handle(code, isolate); Handle<Code> code_handle(code, isolate);
Handle<SharedFunctionInfo> function_handle(shared, isolate); Handle<SharedFunctionInfo> function_handle(shared, isolate);
for (SourcePositionTableIterator iterator(code->SourcePositionTable()); for (SourcePositionTableIterator iterator(code.SourcePositionTable());
!iterator.done(); iterator.Advance()) { !iterator.done(); iterator.Advance()) {
SourcePositionInfo info(GetSourcePositionInfo(code_handle, function_handle, SourcePositionInfo info(GetSourcePositionInfo(code_handle, function_handle,
iterator.source_position())); iterator.source_position()));
@ -363,9 +362,9 @@ void PerfJitLogger::LogWriteDebugInfo(Code code, SharedFunctionInfo shared) {
debug_info.size_ = size + padding; debug_info.size_ = size + padding;
LogWriteBytes(reinterpret_cast<const char*>(&debug_info), sizeof(debug_info)); LogWriteBytes(reinterpret_cast<const char*>(&debug_info), sizeof(debug_info));
Address code_start = code->InstructionStart(); Address code_start = code.InstructionStart();
for (SourcePositionTableIterator iterator(code->SourcePositionTable()); for (SourcePositionTableIterator iterator(code.SourcePositionTable());
!iterator.done(); iterator.Advance()) { !iterator.done(); iterator.Advance()) {
SourcePositionInfo info(GetSourcePositionInfo(code_handle, function_handle, SourcePositionInfo info(GetSourcePositionInfo(code_handle, function_handle,
iterator.source_position())); iterator.source_position()));
@ -394,8 +393,8 @@ void PerfJitLogger::LogWriteUnwindingInfo(Code code) {
unwinding_info_header.time_stamp_ = GetTimestamp(); unwinding_info_header.time_stamp_ = GetTimestamp();
unwinding_info_header.eh_frame_hdr_size_ = EhFrameConstants::kEhFrameHdrSize; unwinding_info_header.eh_frame_hdr_size_ = EhFrameConstants::kEhFrameHdrSize;
if (code->has_unwinding_info()) { if (code.has_unwinding_info()) {
unwinding_info_header.unwinding_size_ = code->unwinding_info_size(); unwinding_info_header.unwinding_size_ = code.unwinding_info_size();
unwinding_info_header.mapped_size_ = unwinding_info_header.unwinding_size_; unwinding_info_header.mapped_size_ = unwinding_info_header.unwinding_size_;
} else { } else {
unwinding_info_header.unwinding_size_ = EhFrameConstants::kEhFrameHdrSize; unwinding_info_header.unwinding_size_ = EhFrameConstants::kEhFrameHdrSize;
@ -410,9 +409,9 @@ void PerfJitLogger::LogWriteUnwindingInfo(Code code) {
LogWriteBytes(reinterpret_cast<const char*>(&unwinding_info_header), LogWriteBytes(reinterpret_cast<const char*>(&unwinding_info_header),
sizeof(unwinding_info_header)); sizeof(unwinding_info_header));
if (code->has_unwinding_info()) { if (code.has_unwinding_info()) {
LogWriteBytes(reinterpret_cast<const char*>(code->unwinding_info_start()), LogWriteBytes(reinterpret_cast<const char*>(code.unwinding_info_start()),
code->unwinding_info_size()); code.unwinding_info_size());
} else { } else {
OFStream perf_output_stream(perf_output_handle_); OFStream perf_output_stream(perf_output_handle_);
EhFrameWriter::WriteEmptyEhFrame(perf_output_stream); EhFrameWriter::WriteEmptyEhFrame(perf_output_stream);
@ -426,7 +425,7 @@ void PerfJitLogger::LogWriteUnwindingInfo(Code code) {
void PerfJitLogger::CodeMoveEvent(AbstractCode from, AbstractCode to) { void PerfJitLogger::CodeMoveEvent(AbstractCode from, AbstractCode to) {
// We may receive a CodeMove event if a BytecodeArray object moves. Otherwise // We may receive a CodeMove event if a BytecodeArray object moves. Otherwise
// code relocation is not supported. // code relocation is not supported.
CHECK(from->IsBytecodeArray()); CHECK(from.IsBytecodeArray());
} }
void PerfJitLogger::LogWriteBytes(const char* bytes, int size) { void PerfJitLogger::LogWriteBytes(const char* bytes, int size) {

View File

@ -22,7 +22,7 @@ int Arguments::smi_at(int index) {
return Smi::ToInt(Object(*address_of_arg_at(index))); return Smi::ToInt(Object(*address_of_arg_at(index)));
} }
double Arguments::number_at(int index) { return (*this)[index]->Number(); } double Arguments::number_at(int index) { return (*this)[index].Number(); }
} // namespace internal } // namespace internal
} // namespace v8 } // namespace v8

View File

@ -47,7 +47,7 @@ class Arguments {
inline double number_at(int index); inline double number_at(int index);
inline void set_at(int index, Object value) { inline void set_at(int index, Object value) {
*address_of_arg_at(index) = value->ptr(); *address_of_arg_at(index) = value.ptr();
} }
inline FullObjectSlot slot_at(int index) { inline FullObjectSlot slot_at(int index) {
@ -101,7 +101,7 @@ double ClobberDoubleRegisters(double x1, double x2, double x3, double x4);
} \ } \
\ \
Type Name(int args_length, Address* args_object, Isolate* isolate) { \ Type Name(int args_length, Address* args_object, Isolate* isolate) { \
DCHECK(isolate->context().is_null() || isolate->context()->IsContext()); \ DCHECK(isolate->context().is_null() || isolate->context().IsContext()); \
CLOBBER_DOUBLE_REGISTERS(); \ CLOBBER_DOUBLE_REGISTERS(); \
if (V8_UNLIKELY(TracingFlags::is_runtime_stats_enabled())) { \ if (V8_UNLIKELY(TracingFlags::is_runtime_stats_enabled())) { \
return Stats_##Name(args_length, args_object, isolate); \ return Stats_##Name(args_length, args_object, isolate); \
@ -112,7 +112,7 @@ double ClobberDoubleRegisters(double x1, double x2, double x3, double x4);
\ \
static InternalType __RT_impl_##Name(Arguments args, Isolate* isolate) static InternalType __RT_impl_##Name(Arguments args, Isolate* isolate)
#define CONVERT_OBJECT(x) (x)->ptr() #define CONVERT_OBJECT(x) (x).ptr()
#define CONVERT_OBJECTPAIR(x) (x) #define CONVERT_OBJECTPAIR(x) (x)
#define RUNTIME_FUNCTION(Name) \ #define RUNTIME_FUNCTION(Name) \

View File

@ -195,10 +195,10 @@ V8_WARN_UNUSED_RESULT MaybeHandle<Object> Invoke(Isolate* isolate,
if (params.target->IsJSFunction()) { if (params.target->IsJSFunction()) {
Handle<JSFunction> function = Handle<JSFunction>::cast(params.target); Handle<JSFunction> function = Handle<JSFunction>::cast(params.target);
if ((!params.is_construct || function->IsConstructor()) && if ((!params.is_construct || function->IsConstructor()) &&
function->shared()->IsApiFunction() && function->shared().IsApiFunction() &&
!function->shared()->BreakAtEntry()) { !function->shared().BreakAtEntry()) {
SaveAndSwitchContext save(isolate, function->context()); SaveAndSwitchContext save(isolate, function->context());
DCHECK(function->context()->global_object()->IsJSGlobalObject()); DCHECK(function->context().global_object().IsJSGlobalObject());
Handle<Object> receiver = params.is_construct Handle<Object> receiver = params.is_construct
? isolate->factory()->the_hole_value() ? isolate->factory()->the_hole_value()
@ -286,12 +286,12 @@ V8_WARN_UNUSED_RESULT MaybeHandle<Object> Invoke(Isolate* isolate,
#ifdef VERIFY_HEAP #ifdef VERIFY_HEAP
if (FLAG_verify_heap) { if (FLAG_verify_heap) {
value->ObjectVerify(isolate); value.ObjectVerify(isolate);
} }
#endif #endif
// Update the pending exception flag and return the value. // Update the pending exception flag and return the value.
bool has_exception = value->IsException(isolate); bool has_exception = value.IsException(isolate);
DCHECK(has_exception == isolate->has_pending_exception()); DCHECK(has_exception == isolate->has_pending_exception());
if (has_exception) { if (has_exception) {
if (params.message_handling == Execution::MessageHandling::kReport) { if (params.message_handling == Execution::MessageHandling::kReport) {

View File

@ -107,7 +107,7 @@ inline Object BuiltinExitFrame::receiver_slot_object() const {
// fp[4]: argc. // fp[4]: argc.
// fp[2 + argc - 1]: receiver. // fp[2 + argc - 1]: receiver.
Object argc_slot = argc_slot_object(); Object argc_slot = argc_slot_object();
DCHECK(argc_slot->IsSmi()); DCHECK(argc_slot.IsSmi());
int argc = Smi::ToInt(argc_slot); int argc = Smi::ToInt(argc_slot);
const int receiverOffset = BuiltinExitFrameConstants::kNewTargetOffset + const int receiverOffset = BuiltinExitFrameConstants::kNewTargetOffset +
@ -138,7 +138,7 @@ inline Object StandardFrame::GetExpression(int index) const {
} }
inline void StandardFrame::SetExpression(int index, Object value) { inline void StandardFrame::SetExpression(int index, Object value) {
Memory<Address>(GetExpressionAddress(index)) = value->ptr(); Memory<Address>(GetExpressionAddress(index)) = value.ptr();
} }
inline Address StandardFrame::caller_fp() const { inline Address StandardFrame::caller_fp() const {
@ -187,7 +187,7 @@ Address JavaScriptFrame::GetParameterSlot(int index) const {
} }
inline void JavaScriptFrame::set_receiver(Object value) { inline void JavaScriptFrame::set_receiver(Object value) {
Memory<Address>(GetParameterSlot(-1)) = value->ptr(); Memory<Address>(GetParameterSlot(-1)) = value.ptr();
} }
inline bool JavaScriptFrame::has_adapted_arguments() const { inline bool JavaScriptFrame::has_adapted_arguments() const {

View File

@ -160,8 +160,8 @@ void StackTraceFrameIterator::Advance() {
bool StackTraceFrameIterator::IsValidFrame(StackFrame* frame) const { bool StackTraceFrameIterator::IsValidFrame(StackFrame* frame) const {
if (frame->is_java_script()) { if (frame->is_java_script()) {
JavaScriptFrame* jsFrame = static_cast<JavaScriptFrame*>(frame); JavaScriptFrame* jsFrame = static_cast<JavaScriptFrame*>(frame);
if (!jsFrame->function()->IsJSFunction()) return false; if (!jsFrame->function().IsJSFunction()) return false;
return jsFrame->function()->shared()->IsSubjectToDebugging(); return jsFrame->function().shared().IsSubjectToDebugging();
} }
// apart from javascript, only wasm is valid // apart from javascript, only wasm is valid
return frame->is_wasm(); return frame->is_wasm();
@ -180,9 +180,9 @@ bool IsInterpreterFramePc(Isolate* isolate, Address pc,
Code interpreter_bytecode_dispatch = Code interpreter_bytecode_dispatch =
isolate->builtins()->builtin(Builtins::kInterpreterEnterBytecodeDispatch); isolate->builtins()->builtin(Builtins::kInterpreterEnterBytecodeDispatch);
if (interpreter_entry_trampoline->contains(pc) || if (interpreter_entry_trampoline.contains(pc) ||
interpreter_bytecode_advance->contains(pc) || interpreter_bytecode_advance.contains(pc) ||
interpreter_bytecode_dispatch->contains(pc)) { interpreter_bytecode_dispatch.contains(pc)) {
return true; return true;
} else if (FLAG_interpreted_frames_native_stack) { } else if (FLAG_interpreted_frames_native_stack) {
intptr_t marker = Memory<intptr_t>( intptr_t marker = Memory<intptr_t>(
@ -194,14 +194,14 @@ bool IsInterpreterFramePc(Isolate* isolate, Address pc,
Memory<Address>(state->fp + StandardFrameConstants::kFunctionOffset)); Memory<Address>(state->fp + StandardFrameConstants::kFunctionOffset));
// There's no need to run a full ContainsSlow if we know the frame can't be // There's no need to run a full ContainsSlow if we know the frame can't be
// an InterpretedFrame, so we do these fast checks first // an InterpretedFrame, so we do these fast checks first
if (StackFrame::IsTypeMarker(marker) || maybe_function->IsSmi()) { if (StackFrame::IsTypeMarker(marker) || maybe_function.IsSmi()) {
return false; return false;
} else if (!isolate->heap()->InSpaceSlow(pc, CODE_SPACE)) { } else if (!isolate->heap()->InSpaceSlow(pc, CODE_SPACE)) {
return false; return false;
} }
interpreter_entry_trampoline = interpreter_entry_trampoline =
isolate->heap()->GcSafeFindCodeForInnerPointer(pc); isolate->heap()->GcSafeFindCodeForInnerPointer(pc);
return interpreter_entry_trampoline->is_interpreter_trampoline_builtin(); return interpreter_entry_trampoline.is_interpreter_trampoline_builtin();
} else { } else {
return false; return false;
} }
@ -384,7 +384,7 @@ bool SafeStackFrameIterator::IsValidCaller(StackFrame* frame) {
// that it really an Smi. // that it really an Smi.
Object number_of_args = Object number_of_args =
reinterpret_cast<ArgumentsAdaptorFrame*>(frame)->GetExpression(0); reinterpret_cast<ArgumentsAdaptorFrame*>(frame)->GetExpression(0);
if (!number_of_args->IsSmi()) { if (!number_of_args.IsSmi()) {
return false; return false;
} }
} }
@ -444,24 +444,24 @@ Code GetContainingCode(Isolate* isolate, Address pc) {
Code StackFrame::LookupCode() const { Code StackFrame::LookupCode() const {
Code result = GetContainingCode(isolate(), pc()); Code result = GetContainingCode(isolate(), pc());
DCHECK_GE(pc(), result->InstructionStart()); DCHECK_GE(pc(), result.InstructionStart());
DCHECK_LT(pc(), result->InstructionEnd()); DCHECK_LT(pc(), result.InstructionEnd());
return result; return result;
} }
void StackFrame::IteratePc(RootVisitor* v, Address* pc_address, void StackFrame::IteratePc(RootVisitor* v, Address* pc_address,
Address* constant_pool_address, Code holder) { Address* constant_pool_address, Code holder) {
Address pc = *pc_address; Address pc = *pc_address;
DCHECK(holder->GetHeap()->GcSafeCodeContains(holder, pc)); DCHECK(holder.GetHeap()->GcSafeCodeContains(holder, pc));
unsigned pc_offset = static_cast<unsigned>(pc - holder->InstructionStart()); unsigned pc_offset = static_cast<unsigned>(pc - holder.InstructionStart());
Object code = holder; Object code = holder;
v->VisitRootPointer(Root::kTop, nullptr, FullObjectSlot(&code)); v->VisitRootPointer(Root::kTop, nullptr, FullObjectSlot(&code));
if (code == holder) return; if (code == holder) return;
holder = Code::unchecked_cast(code); holder = Code::unchecked_cast(code);
pc = holder->InstructionStart() + pc_offset; pc = holder.InstructionStart() + pc_offset;
*pc_address = pc; *pc_address = pc;
if (FLAG_enable_embedded_constant_pool && constant_pool_address) { if (FLAG_enable_embedded_constant_pool && constant_pool_address) {
*constant_pool_address = holder->constant_pool(); *constant_pool_address = holder.constant_pool();
} }
} }
@ -492,7 +492,7 @@ StackFrame::Type StackFrame::ComputeType(const StackFrameIteratorBase* iterator,
Object maybe_function = Object( Object maybe_function = Object(
Memory<Address>(state->fp + StandardFrameConstants::kFunctionOffset)); Memory<Address>(state->fp + StandardFrameConstants::kFunctionOffset));
if (!StackFrame::IsTypeMarker(marker)) { if (!StackFrame::IsTypeMarker(marker)) {
if (maybe_function->IsSmi()) { if (maybe_function.IsSmi()) {
return NATIVE; return NATIVE;
} else if (IsInterpreterFramePc(iterator->isolate(), *(state->pc_address), } else if (IsInterpreterFramePc(iterator->isolate(), *(state->pc_address),
state)) { state)) {
@ -532,13 +532,13 @@ StackFrame::Type StackFrame::ComputeType(const StackFrameIteratorBase* iterator,
// Look up the code object to figure out the type of the stack frame. // Look up the code object to figure out the type of the stack frame.
Code code_obj = GetContainingCode(iterator->isolate(), pc); Code code_obj = GetContainingCode(iterator->isolate(), pc);
if (!code_obj.is_null()) { if (!code_obj.is_null()) {
switch (code_obj->kind()) { switch (code_obj.kind()) {
case Code::BUILTIN: case Code::BUILTIN:
if (StackFrame::IsTypeMarker(marker)) break; if (StackFrame::IsTypeMarker(marker)) break;
if (code_obj->is_interpreter_trampoline_builtin()) { if (code_obj.is_interpreter_trampoline_builtin()) {
return INTERPRETED; return INTERPRETED;
} }
if (code_obj->is_turbofanned()) { if (code_obj.is_turbofanned()) {
// TODO(bmeurer): We treat frames for BUILTIN Code objects as // TODO(bmeurer): We treat frames for BUILTIN Code objects as
// OptimizedFrame for now (all the builtins with JavaScript // OptimizedFrame for now (all the builtins with JavaScript
// linkage are actually generated with TurboFan currently, so // linkage are actually generated with TurboFan currently, so
@ -679,7 +679,7 @@ StackFrame::Type ExitFrame::ComputeFrameType(Address fp) {
const int offset = ExitFrameConstants::kFrameTypeOffset; const int offset = ExitFrameConstants::kFrameTypeOffset;
Object marker(Memory<Address>(fp + offset)); Object marker(Memory<Address>(fp + offset));
if (!marker->IsSmi()) { if (!marker.IsSmi()) {
return EXIT; return EXIT;
} }
@ -719,7 +719,7 @@ JSFunction BuiltinExitFrame::function() const {
Object BuiltinExitFrame::receiver() const { return receiver_slot_object(); } Object BuiltinExitFrame::receiver() const { return receiver_slot_object(); }
bool BuiltinExitFrame::IsConstructor() const { bool BuiltinExitFrame::IsConstructor() const {
return !new_target_slot_object()->IsUndefined(isolate()); return !new_target_slot_object().IsUndefined(isolate());
} }
Object BuiltinExitFrame::GetParameter(int i) const { Object BuiltinExitFrame::GetParameter(int i) const {
@ -731,7 +731,7 @@ Object BuiltinExitFrame::GetParameter(int i) const {
int BuiltinExitFrame::ComputeParametersCount() const { int BuiltinExitFrame::ComputeParametersCount() const {
Object argc_slot = argc_slot_object(); Object argc_slot = argc_slot_object();
DCHECK(argc_slot->IsSmi()); DCHECK(argc_slot.IsSmi());
// Argc also counts the receiver, target, new target, and argc itself as args, // Argc also counts the receiver, target, new target, and argc itself as args,
// therefore the real argument count is argc - 4. // therefore the real argument count is argc - 4.
int argc = Smi::ToInt(argc_slot) - 4; int argc = Smi::ToInt(argc_slot) - 4;
@ -816,8 +816,8 @@ Object StandardFrame::context() const {
int StandardFrame::position() const { int StandardFrame::position() const {
AbstractCode code = AbstractCode::cast(LookupCode()); AbstractCode code = AbstractCode::cast(LookupCode());
int code_offset = static_cast<int>(pc() - code->InstructionStart()); int code_offset = static_cast<int>(pc() - code.InstructionStart());
return code->SourcePosition(code_offset); return code.SourcePosition(code_offset);
} }
int StandardFrame::ComputeExpressionsCount() const { int StandardFrame::ComputeExpressionsCount() const {
@ -879,17 +879,17 @@ void StandardFrame::IterateCompiledFrame(RootVisitor* v) const {
InnerPointerToCodeCache::InnerPointerToCodeCacheEntry* entry = InnerPointerToCodeCache::InnerPointerToCodeCacheEntry* entry =
isolate()->inner_pointer_to_code_cache()->GetCacheEntry(inner_pointer); isolate()->inner_pointer_to_code_cache()->GetCacheEntry(inner_pointer);
if (!entry->safepoint_entry.is_valid()) { if (!entry->safepoint_entry.is_valid()) {
entry->safepoint_entry = entry->code->GetSafepointEntry(inner_pointer); entry->safepoint_entry = entry->code.GetSafepointEntry(inner_pointer);
DCHECK(entry->safepoint_entry.is_valid()); DCHECK(entry->safepoint_entry.is_valid());
} else { } else {
DCHECK(entry->safepoint_entry.Equals( DCHECK(entry->safepoint_entry.Equals(
entry->code->GetSafepointEntry(inner_pointer))); entry->code.GetSafepointEntry(inner_pointer)));
} }
code = entry->code; code = entry->code;
safepoint_entry = entry->safepoint_entry; safepoint_entry = entry->safepoint_entry;
stack_slots = code->stack_slots(); stack_slots = code.stack_slots();
has_tagged_params = code->has_tagged_params(); has_tagged_params = code.has_tagged_params();
} }
uint32_t slot_space = stack_slots * kSystemPointerSize; uint32_t slot_space = stack_slots * kSystemPointerSize;
@ -1044,18 +1044,18 @@ Address StubFrame::GetCallerStackPointer() const {
int StubFrame::LookupExceptionHandlerInTable(int* stack_slots) { int StubFrame::LookupExceptionHandlerInTable(int* stack_slots) {
Code code = LookupCode(); Code code = LookupCode();
DCHECK(code->is_turbofanned()); DCHECK(code.is_turbofanned());
DCHECK_EQ(code->kind(), Code::BUILTIN); DCHECK_EQ(code.kind(), Code::BUILTIN);
HandlerTable table(code); HandlerTable table(code);
int pc_offset = static_cast<int>(pc() - code->InstructionStart()); int pc_offset = static_cast<int>(pc() - code.InstructionStart());
*stack_slots = code->stack_slots(); *stack_slots = code.stack_slots();
return table.LookupReturn(pc_offset); return table.LookupReturn(pc_offset);
} }
void OptimizedFrame::Iterate(RootVisitor* v) const { IterateCompiledFrame(v); } void OptimizedFrame::Iterate(RootVisitor* v) const { IterateCompiledFrame(v); }
void JavaScriptFrame::SetParameterValue(int index, Object value) const { void JavaScriptFrame::SetParameterValue(int index, Object value) const {
Memory<Address>(GetParameterSlot(index)) = value->ptr(); Memory<Address>(GetParameterSlot(index)) = value.ptr();
} }
bool JavaScriptFrame::IsConstructor() const { bool JavaScriptFrame::IsConstructor() const {
@ -1073,11 +1073,11 @@ bool JavaScriptFrame::HasInlinedFrames() const {
return functions.size() > 1; return functions.size() > 1;
} }
Code JavaScriptFrame::unchecked_code() const { return function()->code(); } Code JavaScriptFrame::unchecked_code() const { return function().code(); }
int OptimizedFrame::ComputeParametersCount() const { int OptimizedFrame::ComputeParametersCount() const {
Code code = LookupCode(); Code code = LookupCode();
if (code->kind() == Code::BUILTIN) { if (code.kind() == Code::BUILTIN) {
return static_cast<int>( return static_cast<int>(
Memory<intptr_t>(fp() + OptimizedBuiltinFrameConstants::kArgCOffset)); Memory<intptr_t>(fp() + OptimizedBuiltinFrameConstants::kArgCOffset));
} else { } else {
@ -1092,7 +1092,7 @@ Address JavaScriptFrame::GetCallerStackPointer() const {
void JavaScriptFrame::GetFunctions( void JavaScriptFrame::GetFunctions(
std::vector<SharedFunctionInfo>* functions) const { std::vector<SharedFunctionInfo>* functions) const {
DCHECK(functions->empty()); DCHECK(functions->empty());
functions->push_back(function()->shared()); functions->push_back(function().shared());
} }
void JavaScriptFrame::GetFunctions( void JavaScriptFrame::GetFunctions(
@ -1102,14 +1102,14 @@ void JavaScriptFrame::GetFunctions(
GetFunctions(&raw_functions); GetFunctions(&raw_functions);
for (const auto& raw_function : raw_functions) { for (const auto& raw_function : raw_functions) {
functions->push_back( functions->push_back(
Handle<SharedFunctionInfo>(raw_function, function()->GetIsolate())); Handle<SharedFunctionInfo>(raw_function, function().GetIsolate()));
} }
} }
void JavaScriptFrame::Summarize(std::vector<FrameSummary>* functions) const { void JavaScriptFrame::Summarize(std::vector<FrameSummary>* functions) const {
DCHECK(functions->empty()); DCHECK(functions->empty());
Code code = LookupCode(); Code code = LookupCode();
int offset = static_cast<int>(pc() - code->InstructionStart()); int offset = static_cast<int>(pc() - code.InstructionStart());
AbstractCode abstract_code = AbstractCode::cast(code); AbstractCode abstract_code = AbstractCode::cast(code);
Handle<FixedArray> params = GetParameters(); Handle<FixedArray> params = GetParameters();
FrameSummary::JavaScriptFrameSummary summary( FrameSummary::JavaScriptFrameSummary summary(
@ -1126,7 +1126,7 @@ Object JavaScriptFrame::unchecked_function() const {
// During deoptimization of an optimized function, we may have yet to // During deoptimization of an optimized function, we may have yet to
// materialize some closures on the stack. The arguments marker object // materialize some closures on the stack. The arguments marker object
// marks this case. // marks this case.
DCHECK(function_slot_object()->IsJSFunction() || DCHECK(function_slot_object().IsJSFunction() ||
ReadOnlyRoots(isolate()).arguments_marker() == function_slot_object()); ReadOnlyRoots(isolate()).arguments_marker() == function_slot_object());
return function_slot_object(); return function_slot_object();
} }
@ -1136,18 +1136,18 @@ Object JavaScriptFrame::receiver() const { return GetParameter(-1); }
Object JavaScriptFrame::context() const { Object JavaScriptFrame::context() const {
const int offset = StandardFrameConstants::kContextOffset; const int offset = StandardFrameConstants::kContextOffset;
Object maybe_result(Memory<Address>(fp() + offset)); Object maybe_result(Memory<Address>(fp() + offset));
DCHECK(!maybe_result->IsSmi()); DCHECK(!maybe_result.IsSmi());
return maybe_result; return maybe_result;
} }
Script JavaScriptFrame::script() const { Script JavaScriptFrame::script() const {
return Script::cast(function()->shared()->script()); return Script::cast(function().shared().script());
} }
int JavaScriptFrame::LookupExceptionHandlerInTable( int JavaScriptFrame::LookupExceptionHandlerInTable(
int* stack_depth, HandlerTable::CatchPrediction* prediction) { int* stack_depth, HandlerTable::CatchPrediction* prediction) {
DCHECK(!LookupCode()->has_handler_table()); DCHECK(!LookupCode().has_handler_table());
DCHECK(!LookupCode()->is_optimized_code()); DCHECK(!LookupCode().is_optimized_code());
return -1; return -1;
} }
@ -1155,21 +1155,21 @@ void JavaScriptFrame::PrintFunctionAndOffset(JSFunction function,
AbstractCode code, int code_offset, AbstractCode code, int code_offset,
FILE* file, FILE* file,
bool print_line_number) { bool print_line_number) {
PrintF(file, "%s", function->IsOptimized() ? "*" : "~"); PrintF(file, "%s", function.IsOptimized() ? "*" : "~");
function->PrintName(file); function.PrintName(file);
PrintF(file, "+%d", code_offset); PrintF(file, "+%d", code_offset);
if (print_line_number) { if (print_line_number) {
SharedFunctionInfo shared = function->shared(); SharedFunctionInfo shared = function.shared();
int source_pos = code->SourcePosition(code_offset); int source_pos = code.SourcePosition(code_offset);
Object maybe_script = shared->script(); Object maybe_script = shared.script();
if (maybe_script->IsScript()) { if (maybe_script.IsScript()) {
Script script = Script::cast(maybe_script); Script script = Script::cast(maybe_script);
int line = script->GetLineNumber(source_pos) + 1; int line = script.GetLineNumber(source_pos) + 1;
Object script_name_raw = script->name(); Object script_name_raw = script.name();
if (script_name_raw->IsString()) { if (script_name_raw.IsString()) {
String script_name = String::cast(script->name()); String script_name = String::cast(script.name());
std::unique_ptr<char[]> c_script_name = std::unique_ptr<char[]> c_script_name =
script_name->ToCString(DISALLOW_NULLS, ROBUST_STRING_TRAVERSAL); script_name.ToCString(DISALLOW_NULLS, ROBUST_STRING_TRAVERSAL);
PrintF(file, " at %s:%d", c_script_name.get(), line); PrintF(file, " at %s:%d", c_script_name.get(), line);
} else { } else {
PrintF(file, " at <unknown>:%d", line); PrintF(file, " at <unknown>:%d", line);
@ -1196,20 +1196,20 @@ void JavaScriptFrame::PrintTop(Isolate* isolate, FILE* file, bool print_args,
code_offset = iframe->GetBytecodeOffset(); code_offset = iframe->GetBytecodeOffset();
} else { } else {
Code code = frame->unchecked_code(); Code code = frame->unchecked_code();
code_offset = static_cast<int>(frame->pc() - code->InstructionStart()); code_offset = static_cast<int>(frame->pc() - code.InstructionStart());
} }
PrintFunctionAndOffset(function, function->abstract_code(), code_offset, PrintFunctionAndOffset(function, function.abstract_code(), code_offset,
file, print_line_number); file, print_line_number);
if (print_args) { if (print_args) {
// function arguments // function arguments
// (we are intentionally only printing the actually // (we are intentionally only printing the actually
// supplied parameters, not all parameters required) // supplied parameters, not all parameters required)
PrintF(file, "(this="); PrintF(file, "(this=");
frame->receiver()->ShortPrint(file); frame->receiver().ShortPrint(file);
const int length = frame->ComputeParametersCount(); const int length = frame->ComputeParametersCount();
for (int i = 0; i < length; i++) { for (int i = 0; i < length; i++) {
PrintF(file, ", "); PrintF(file, ", ");
frame->GetParameter(i)->ShortPrint(file); frame->GetParameter(i).ShortPrint(file);
} }
PrintF(file, ")"); PrintF(file, ")");
} }
@ -1224,16 +1224,16 @@ void JavaScriptFrame::CollectFunctionAndOffsetForICStats(JSFunction function,
int code_offset) { int code_offset) {
auto ic_stats = ICStats::instance(); auto ic_stats = ICStats::instance();
ICInfo& ic_info = ic_stats->Current(); ICInfo& ic_info = ic_stats->Current();
SharedFunctionInfo shared = function->shared(); SharedFunctionInfo shared = function.shared();
ic_info.function_name = ic_stats->GetOrCacheFunctionName(function); ic_info.function_name = ic_stats->GetOrCacheFunctionName(function);
ic_info.script_offset = code_offset; ic_info.script_offset = code_offset;
int source_pos = code->SourcePosition(code_offset); int source_pos = code.SourcePosition(code_offset);
Object maybe_script = shared->script(); Object maybe_script = shared.script();
if (maybe_script->IsScript()) { if (maybe_script.IsScript()) {
Script script = Script::cast(maybe_script); Script script = Script::cast(maybe_script);
ic_info.line_num = script->GetLineNumber(source_pos) + 1; ic_info.line_num = script.GetLineNumber(source_pos) + 1;
ic_info.script_name = ic_stats->GetOrCacheScriptName(script); ic_info.script_name = ic_stats->GetOrCacheScriptName(script);
} }
} }
@ -1245,7 +1245,7 @@ Object JavaScriptFrame::GetParameter(int index) const {
int JavaScriptFrame::ComputeParametersCount() const { int JavaScriptFrame::ComputeParametersCount() const {
DCHECK(can_access_heap_objects() && DCHECK(can_access_heap_objects() &&
isolate()->heap()->gc_state() == Heap::NOT_IN_GC); isolate()->heap()->gc_state() == Heap::NOT_IN_GC);
return function()->shared()->internal_formal_parameter_count(); return function().shared().internal_formal_parameter_count();
} }
Handle<FixedArray> JavaScriptFrame::GetParameters() const { Handle<FixedArray> JavaScriptFrame::GetParameters() const {
@ -1293,7 +1293,7 @@ void JavaScriptBuiltinContinuationWithCatchFrame::SetException(
// Only allow setting exception if previous value was the hole. // Only allow setting exception if previous value was the hole.
CHECK_EQ(ReadOnlyRoots(isolate()).the_hole_value(), CHECK_EQ(ReadOnlyRoots(isolate()).the_hole_value(),
Object(Memory<Address>(exception_argument_slot))); Object(Memory<Address>(exception_argument_slot)));
Memory<Address>(exception_argument_slot) = exception->ptr(); Memory<Address>(exception_argument_slot) = exception.ptr();
} }
FrameSummary::JavaScriptFrameSummary::JavaScriptFrameSummary( FrameSummary::JavaScriptFrameSummary::JavaScriptFrameSummary(
@ -1307,8 +1307,8 @@ FrameSummary::JavaScriptFrameSummary::JavaScriptFrameSummary(
code_offset_(code_offset), code_offset_(code_offset),
is_constructor_(is_constructor), is_constructor_(is_constructor),
parameters_(parameters, isolate) { parameters_(parameters, isolate) {
DCHECK(abstract_code->IsBytecodeArray() || DCHECK(abstract_code.IsBytecodeArray() ||
Code::cast(abstract_code)->kind() != Code::OPTIMIZED_FUNCTION); Code::cast(abstract_code).kind() != Code::OPTIMIZED_FUNCTION);
} }
void FrameSummary::EnsureSourcePositionsAvailable() { void FrameSummary::EnsureSourcePositionsAvailable() {
@ -1331,11 +1331,11 @@ void FrameSummary::JavaScriptFrameSummary::EnsureSourcePositionsAvailable() {
bool FrameSummary::JavaScriptFrameSummary::AreSourcePositionsAvailable() const { bool FrameSummary::JavaScriptFrameSummary::AreSourcePositionsAvailable() const {
return !FLAG_enable_lazy_source_positions || return !FLAG_enable_lazy_source_positions ||
function()->shared()->GetBytecodeArray()->HasSourcePositionTable(); function()->shared().GetBytecodeArray().HasSourcePositionTable();
} }
bool FrameSummary::JavaScriptFrameSummary::is_subject_to_debugging() const { bool FrameSummary::JavaScriptFrameSummary::is_subject_to_debugging() const {
return function()->shared()->IsSubjectToDebugging(); return function()->shared().IsSubjectToDebugging();
} }
int FrameSummary::JavaScriptFrameSummary::SourcePosition() const { int FrameSummary::JavaScriptFrameSummary::SourcePosition() const {
@ -1347,7 +1347,7 @@ int FrameSummary::JavaScriptFrameSummary::SourceStatementPosition() const {
} }
Handle<Object> FrameSummary::JavaScriptFrameSummary::script() const { Handle<Object> FrameSummary::JavaScriptFrameSummary::script() const {
return handle(function_->shared()->script(), isolate()); return handle(function_->shared().script(), isolate());
} }
Handle<String> FrameSummary::JavaScriptFrameSummary::FunctionName() const { Handle<String> FrameSummary::JavaScriptFrameSummary::FunctionName() const {
@ -1355,7 +1355,7 @@ Handle<String> FrameSummary::JavaScriptFrameSummary::FunctionName() const {
} }
Handle<Context> FrameSummary::JavaScriptFrameSummary::native_context() const { Handle<Context> FrameSummary::JavaScriptFrameSummary::native_context() const {
return handle(function_->context()->native_context(), isolate()); return handle(function_->context().native_context(), isolate());
} }
FrameSummary::WasmFrameSummary::WasmFrameSummary( FrameSummary::WasmFrameSummary::WasmFrameSummary(
@ -1392,7 +1392,7 @@ int FrameSummary::WasmFrameSummary::SourcePosition() const {
} }
Handle<Script> FrameSummary::WasmFrameSummary::script() const { Handle<Script> FrameSummary::WasmFrameSummary::script() const {
return handle(wasm_instance()->module_object()->script(), return handle(wasm_instance()->module_object().script(),
wasm_instance()->GetIsolate()); wasm_instance()->GetIsolate());
} }
@ -1516,7 +1516,7 @@ void OptimizedFrame::Summarize(std::vector<FrameSummary>* frames) const {
// Delegate to JS frame in absence of turbofan deoptimization. // Delegate to JS frame in absence of turbofan deoptimization.
// TODO(turbofan): Revisit once we support deoptimization across the board. // TODO(turbofan): Revisit once we support deoptimization across the board.
Code code = LookupCode(); Code code = LookupCode();
if (code->kind() == Code::BUILTIN) { if (code.kind() == Code::BUILTIN) {
return JavaScriptFrame::Summarize(frames); return JavaScriptFrame::Summarize(frames);
} }
@ -1597,14 +1597,14 @@ int OptimizedFrame::LookupExceptionHandlerInTable(
DCHECK_NULL(prediction); DCHECK_NULL(prediction);
Code code = LookupCode(); Code code = LookupCode();
HandlerTable table(code); HandlerTable table(code);
int pc_offset = static_cast<int>(pc() - code->InstructionStart()); int pc_offset = static_cast<int>(pc() - code.InstructionStart());
if (stack_slots) *stack_slots = code->stack_slots(); if (stack_slots) *stack_slots = code.stack_slots();
// When the return pc has been replaced by a trampoline there won't be // When the return pc has been replaced by a trampoline there won't be
// a handler for this trampoline. Thus we need to use the return pc that // a handler for this trampoline. Thus we need to use the return pc that
// _used to be_ on the stack to get the right ExceptionHandler. // _used to be_ on the stack to get the right ExceptionHandler.
if (code->kind() == Code::OPTIMIZED_FUNCTION && if (code.kind() == Code::OPTIMIZED_FUNCTION &&
code->marked_for_deoptimization()) { code.marked_for_deoptimization()) {
SafepointTable safepoints(code); SafepointTable safepoints(code);
pc_offset = safepoints.find_return_pc(pc_offset); pc_offset = safepoints.find_return_pc(pc_offset);
} }
@ -1616,21 +1616,21 @@ DeoptimizationData OptimizedFrame::GetDeoptimizationData(
DCHECK(is_optimized()); DCHECK(is_optimized());
JSFunction opt_function = function(); JSFunction opt_function = function();
Code code = opt_function->code(); Code code = opt_function.code();
// The code object may have been replaced by lazy deoptimization. Fall // The code object may have been replaced by lazy deoptimization. Fall
// back to a slow search in this case to find the original optimized // back to a slow search in this case to find the original optimized
// code object. // code object.
if (!code->contains(pc())) { if (!code.contains(pc())) {
code = isolate()->heap()->GcSafeFindCodeForInnerPointer(pc()); code = isolate()->heap()->GcSafeFindCodeForInnerPointer(pc());
} }
DCHECK(!code.is_null()); DCHECK(!code.is_null());
DCHECK(code->kind() == Code::OPTIMIZED_FUNCTION); DCHECK(code.kind() == Code::OPTIMIZED_FUNCTION);
SafepointEntry safepoint_entry = code->GetSafepointEntry(pc()); SafepointEntry safepoint_entry = code.GetSafepointEntry(pc());
if (safepoint_entry.has_deoptimization_index()) { if (safepoint_entry.has_deoptimization_index()) {
*deopt_index = safepoint_entry.deoptimization_index(); *deopt_index = safepoint_entry.deoptimization_index();
return DeoptimizationData::cast(code->deoptimization_data()); return DeoptimizationData::cast(code.deoptimization_data());
} }
*deopt_index = Safepoint::kNoDeoptimizationIndex; *deopt_index = Safepoint::kNoDeoptimizationIndex;
return DeoptimizationData(); return DeoptimizationData();
@ -1638,7 +1638,7 @@ DeoptimizationData OptimizedFrame::GetDeoptimizationData(
Object OptimizedFrame::receiver() const { Object OptimizedFrame::receiver() const {
Code code = LookupCode(); Code code = LookupCode();
if (code->kind() == Code::BUILTIN) { if (code.kind() == Code::BUILTIN) {
Address argc_ptr = fp() + OptimizedBuiltinFrameConstants::kArgCOffset; Address argc_ptr = fp() + OptimizedBuiltinFrameConstants::kArgCOffset;
intptr_t argc = *reinterpret_cast<intptr_t*>(argc_ptr); intptr_t argc = *reinterpret_cast<intptr_t*>(argc_ptr);
intptr_t args_size = intptr_t args_size =
@ -1659,7 +1659,7 @@ void OptimizedFrame::GetFunctions(
// Delegate to JS frame in absence of turbofan deoptimization. // Delegate to JS frame in absence of turbofan deoptimization.
// TODO(turbofan): Revisit once we support deoptimization across the board. // TODO(turbofan): Revisit once we support deoptimization across the board.
Code code = LookupCode(); Code code = LookupCode();
if (code->kind() == Code::BUILTIN) { if (code.kind() == Code::BUILTIN) {
return JavaScriptFrame::GetFunctions(functions); return JavaScriptFrame::GetFunctions(functions);
} }
@ -1668,10 +1668,10 @@ void OptimizedFrame::GetFunctions(
DeoptimizationData const data = GetDeoptimizationData(&deopt_index); DeoptimizationData const data = GetDeoptimizationData(&deopt_index);
DCHECK(!data.is_null()); DCHECK(!data.is_null());
DCHECK_NE(Safepoint::kNoDeoptimizationIndex, deopt_index); DCHECK_NE(Safepoint::kNoDeoptimizationIndex, deopt_index);
FixedArray const literal_array = data->LiteralArray(); FixedArray const literal_array = data.LiteralArray();
TranslationIterator it(data->TranslationByteArray(), TranslationIterator it(data.TranslationByteArray(),
data->TranslationIndex(deopt_index)->value()); data.TranslationIndex(deopt_index).value());
Translation::Opcode opcode = static_cast<Translation::Opcode>(it.Next()); Translation::Opcode opcode = static_cast<Translation::Opcode>(it.Next());
DCHECK_EQ(Translation::BEGIN, opcode); DCHECK_EQ(Translation::BEGIN, opcode);
it.Next(); // Skip frame count. it.Next(); // Skip frame count.
@ -1690,7 +1690,7 @@ void OptimizedFrame::GetFunctions(
jsframe_count--; jsframe_count--;
// The second operand of the frame points to the function. // The second operand of the frame points to the function.
Object shared = literal_array->get(it.Next()); Object shared = literal_array.get(it.Next());
functions->push_back(SharedFunctionInfo::cast(shared)); functions->push_back(SharedFunctionInfo::cast(shared));
// Skip over remaining operands to advance to the next opcode. // Skip over remaining operands to advance to the next opcode.
@ -1714,7 +1714,7 @@ Object OptimizedFrame::StackSlotAt(int index) const {
int InterpretedFrame::position() const { int InterpretedFrame::position() const {
AbstractCode code = AbstractCode::cast(GetBytecodeArray()); AbstractCode code = AbstractCode::cast(GetBytecodeArray());
int code_offset = GetBytecodeOffset(); int code_offset = GetBytecodeOffset();
return code->SourcePosition(code_offset); return code.SourcePosition(code_offset);
} }
int InterpretedFrame::LookupExceptionHandlerInTable( int InterpretedFrame::LookupExceptionHandlerInTable(
@ -1823,21 +1823,21 @@ void WasmCompiledFrame::Print(StringStream* accumulator, PrintMode mode,
int index) const { int index) const {
PrintIndex(accumulator, mode, index); PrintIndex(accumulator, mode, index);
accumulator->Add("WASM ["); accumulator->Add("WASM [");
accumulator->PrintName(script()->name()); accumulator->PrintName(script().name());
Address instruction_start = isolate() Address instruction_start = isolate()
->wasm_engine() ->wasm_engine()
->code_manager() ->code_manager()
->LookupCode(pc()) ->LookupCode(pc())
->instruction_start(); ->instruction_start();
Vector<const uint8_t> raw_func_name = Vector<const uint8_t> raw_func_name =
module_object()->GetRawFunctionName(function_index()); module_object().GetRawFunctionName(function_index());
const int kMaxPrintedFunctionName = 64; const int kMaxPrintedFunctionName = 64;
char func_name[kMaxPrintedFunctionName + 1]; char func_name[kMaxPrintedFunctionName + 1];
int func_name_len = std::min(kMaxPrintedFunctionName, raw_func_name.length()); int func_name_len = std::min(kMaxPrintedFunctionName, raw_func_name.length());
memcpy(func_name, raw_func_name.begin(), func_name_len); memcpy(func_name, raw_func_name.begin(), func_name_len);
func_name[func_name_len] = '\0'; func_name[func_name_len] = '\0';
int pos = position(); int pos = position();
const wasm::WasmModule* module = wasm_instance()->module_object()->module(); const wasm::WasmModule* module = wasm_instance().module_object().module();
int func_index = function_index(); int func_index = function_index();
int func_code_offset = module->functions[func_index].code.offset(); int func_code_offset = module->functions[func_index].code.offset();
accumulator->Add("], function #%u ('%s'), pc=%p (+0x%x), pos=%d (+%d)\n", accumulator->Add("], function #%u ('%s'), pc=%p (+0x%x), pos=%d (+%d)\n",
@ -1870,14 +1870,14 @@ WasmInstanceObject WasmCompiledFrame::wasm_instance() const {
} }
WasmModuleObject WasmCompiledFrame::module_object() const { WasmModuleObject WasmCompiledFrame::module_object() const {
return wasm_instance()->module_object(); return wasm_instance().module_object();
} }
uint32_t WasmCompiledFrame::function_index() const { uint32_t WasmCompiledFrame::function_index() const {
return FrameSummary::GetSingle(this).AsWasmCompiled().function_index(); return FrameSummary::GetSingle(this).AsWasmCompiled().function_index();
} }
Script WasmCompiledFrame::script() const { return module_object()->script(); } Script WasmCompiledFrame::script() const { return module_object().script(); }
int WasmCompiledFrame::position() const { int WasmCompiledFrame::position() const {
return FrameSummary::GetSingle(this).SourcePosition(); return FrameSummary::GetSingle(this).SourcePosition();
@ -1934,7 +1934,7 @@ void WasmInterpreterEntryFrame::Print(StringStream* accumulator, PrintMode mode,
PrintIndex(accumulator, mode, index); PrintIndex(accumulator, mode, index);
accumulator->Add("WASM INTERPRETER ENTRY ["); accumulator->Add("WASM INTERPRETER ENTRY [");
Script script = this->script(); Script script = this->script();
accumulator->PrintName(script->name()); accumulator->PrintName(script.name());
accumulator->Add("]"); accumulator->Add("]");
if (mode != OVERVIEW) accumulator->Add("\n"); if (mode != OVERVIEW) accumulator->Add("\n");
} }
@ -1943,7 +1943,7 @@ void WasmInterpreterEntryFrame::Summarize(
std::vector<FrameSummary>* functions) const { std::vector<FrameSummary>* functions) const {
Handle<WasmInstanceObject> instance(wasm_instance(), isolate()); Handle<WasmInstanceObject> instance(wasm_instance(), isolate());
std::vector<std::pair<uint32_t, int>> interpreted_stack = std::vector<std::pair<uint32_t, int>> interpreted_stack =
instance->debug_info()->GetInterpretedStack(fp()); instance->debug_info().GetInterpretedStack(fp());
for (auto& e : interpreted_stack) { for (auto& e : interpreted_stack) {
FrameSummary::WasmInterpretedFrameSummary summary(isolate(), instance, FrameSummary::WasmInterpretedFrameSummary summary(isolate(), instance,
@ -1961,15 +1961,15 @@ WasmInstanceObject WasmInterpreterEntryFrame::wasm_instance() const {
} }
WasmDebugInfo WasmInterpreterEntryFrame::debug_info() const { WasmDebugInfo WasmInterpreterEntryFrame::debug_info() const {
return wasm_instance()->debug_info(); return wasm_instance().debug_info();
} }
WasmModuleObject WasmInterpreterEntryFrame::module_object() const { WasmModuleObject WasmInterpreterEntryFrame::module_object() const {
return wasm_instance()->module_object(); return wasm_instance().module_object();
} }
Script WasmInterpreterEntryFrame::script() const { Script WasmInterpreterEntryFrame::script() const {
return module_object()->script(); return module_object().script();
} }
int WasmInterpreterEntryFrame::position() const { int WasmInterpreterEntryFrame::position() const {
@ -1977,7 +1977,7 @@ int WasmInterpreterEntryFrame::position() const {
} }
Object WasmInterpreterEntryFrame::context() const { Object WasmInterpreterEntryFrame::context() const {
return wasm_instance()->native_context(); return wasm_instance().native_context();
} }
Address WasmInterpreterEntryFrame::GetCallerStackPointer() const { Address WasmInterpreterEntryFrame::GetCallerStackPointer() const {
@ -2024,7 +2024,7 @@ void PrintFunctionSource(StringStream* accumulator, SharedFunctionInfo shared,
void JavaScriptFrame::Print(StringStream* accumulator, PrintMode mode, void JavaScriptFrame::Print(StringStream* accumulator, PrintMode mode,
int index) const { int index) const {
Handle<SharedFunctionInfo> shared = handle(function()->shared(), isolate()); Handle<SharedFunctionInfo> shared = handle(function().shared(), isolate());
SharedFunctionInfo::EnsureSourcePositionsAvailable(isolate(), shared); SharedFunctionInfo::EnsureSourcePositionsAvailable(isolate(), shared);
DisallowHeapAllocation no_gc; DisallowHeapAllocation no_gc;
@ -2045,23 +2045,23 @@ void JavaScriptFrame::Print(StringStream* accumulator, PrintMode mode,
// or context slots. // or context slots.
ScopeInfo scope_info = shared->scope_info(); ScopeInfo scope_info = shared->scope_info();
Object script_obj = shared->script(); Object script_obj = shared->script();
if (script_obj->IsScript()) { if (script_obj.IsScript()) {
Script script = Script::cast(script_obj); Script script = Script::cast(script_obj);
accumulator->Add(" ["); accumulator->Add(" [");
accumulator->PrintName(script->name()); accumulator->PrintName(script.name());
if (is_interpreted()) { if (is_interpreted()) {
const InterpretedFrame* iframe = const InterpretedFrame* iframe =
reinterpret_cast<const InterpretedFrame*>(this); reinterpret_cast<const InterpretedFrame*>(this);
BytecodeArray bytecodes = iframe->GetBytecodeArray(); BytecodeArray bytecodes = iframe->GetBytecodeArray();
int offset = iframe->GetBytecodeOffset(); int offset = iframe->GetBytecodeOffset();
int source_pos = AbstractCode::cast(bytecodes)->SourcePosition(offset); int source_pos = AbstractCode::cast(bytecodes).SourcePosition(offset);
int line = script->GetLineNumber(source_pos) + 1; int line = script.GetLineNumber(source_pos) + 1;
accumulator->Add(":%d] [bytecode=%p offset=%d]", line, accumulator->Add(":%d] [bytecode=%p offset=%d]", line,
reinterpret_cast<void*>(bytecodes.ptr()), offset); reinterpret_cast<void*>(bytecodes.ptr()), offset);
} else { } else {
int function_start_pos = shared->StartPosition(); int function_start_pos = shared->StartPosition();
int line = script->GetLineNumber(function_start_pos) + 1; int line = script.GetLineNumber(function_start_pos) + 1;
accumulator->Add(":~%d] [pc=%p]", line, reinterpret_cast<void*>(pc())); accumulator->Add(":~%d] [pc=%p]", line, reinterpret_cast<void*>(pc()));
} }
} }
@ -2089,15 +2089,15 @@ void JavaScriptFrame::Print(StringStream* accumulator, PrintMode mode,
accumulator->Add(" {\n"); accumulator->Add(" {\n");
// Compute the number of locals and expression stack elements. // Compute the number of locals and expression stack elements.
int heap_locals_count = scope_info->ContextLocalCount(); int heap_locals_count = scope_info.ContextLocalCount();
int expressions_count = ComputeExpressionsCount(); int expressions_count = ComputeExpressionsCount();
// Try to get hold of the context of this frame. // Try to get hold of the context of this frame.
Context context; Context context;
if (this->context()->IsContext()) { if (this->context().IsContext()) {
context = Context::cast(this->context()); context = Context::cast(this->context());
while (context->IsWithContext()) { while (context.IsWithContext()) {
context = context->previous(); context = context.previous();
DCHECK(!context.is_null()); DCHECK(!context.is_null());
} }
} }
@ -2108,12 +2108,12 @@ void JavaScriptFrame::Print(StringStream* accumulator, PrintMode mode,
} }
for (int i = 0; i < heap_locals_count; i++) { for (int i = 0; i < heap_locals_count; i++) {
accumulator->Add(" var "); accumulator->Add(" var ");
accumulator->PrintName(scope_info->ContextLocalName(i)); accumulator->PrintName(scope_info.ContextLocalName(i));
accumulator->Add(" = "); accumulator->Add(" = ");
if (!context.is_null()) { if (!context.is_null()) {
int index = Context::MIN_CONTEXT_SLOTS + i; int index = Context::MIN_CONTEXT_SLOTS + i;
if (index < context->length()) { if (index < context.length()) {
accumulator->Add("%o", context->get(index)); accumulator->Add("%o", context.get(index));
} else { } else {
accumulator->Add( accumulator->Add(
"// warning: missing context slot - inconsistent frame?"); "// warning: missing context slot - inconsistent frame?");
@ -2142,7 +2142,7 @@ void ArgumentsAdaptorFrame::Print(StringStream* accumulator, PrintMode mode,
int actual = ComputeParametersCount(); int actual = ComputeParametersCount();
int expected = -1; int expected = -1;
JSFunction function = this->function(); JSFunction function = this->function();
expected = function->shared()->internal_formal_parameter_count(); expected = function.shared().internal_formal_parameter_count();
PrintIndex(accumulator, mode, index); PrintIndex(accumulator, mode, index);
accumulator->Add("arguments adaptor frame: %d->%d", actual, expected); accumulator->Add("arguments adaptor frame: %d->%d", actual, expected);
@ -2190,7 +2190,7 @@ void InternalFrame::Iterate(RootVisitor* v) const {
// the full stack frame contains only tagged pointers or only raw values. // the full stack frame contains only tagged pointers or only raw values.
// This is used for the WasmCompileLazy builtin, where we actually pass // This is used for the WasmCompileLazy builtin, where we actually pass
// untagged arguments and also store untagged values on the stack. // untagged arguments and also store untagged values on the stack.
if (code->has_tagged_params()) IterateExpressions(v); if (code.has_tagged_params()) IterateExpressions(v);
} }
// ------------------------------------------------------------------------- // -------------------------------------------------------------------------

View File

@ -84,7 +84,7 @@ Object FutexEmulation::WaitJs(Isolate* isolate,
Handle<JSArrayBuffer> array_buffer, size_t addr, Handle<JSArrayBuffer> array_buffer, size_t addr,
int32_t value, double rel_timeout_ms) { int32_t value, double rel_timeout_ms) {
Object res = Wait32(isolate, array_buffer, addr, value, rel_timeout_ms); Object res = Wait32(isolate, array_buffer, addr, value, rel_timeout_ms);
if (res->IsSmi()) { if (res.IsSmi()) {
int val = Smi::ToInt(res); int val = Smi::ToInt(res);
switch (val) { switch (val) {
case WaitReturnValue::kOk: case WaitReturnValue::kOk:
@ -201,7 +201,7 @@ Object FutexEmulation::Wait(Isolate* isolate,
// be false, so we'll loop and then check interrupts. // be false, so we'll loop and then check interrupts.
if (interrupted) { if (interrupted) {
Object interrupt_object = isolate->stack_guard()->HandleInterrupts(); Object interrupt_object = isolate->stack_guard()->HandleInterrupts();
if (interrupt_object->IsException(isolate)) { if (interrupt_object.IsException(isolate)) {
result = interrupt_object; result = interrupt_object;
callback_result = AtomicsWaitEvent::kTerminatedExecution; callback_result = AtomicsWaitEvent::kTerminatedExecution;
mutex_.Pointer()->Lock(); mutex_.Pointer()->Lock();

View File

@ -21,37 +21,37 @@ IsolateAllocationMode Isolate::isolate_allocation_mode() {
} }
void Isolate::set_context(Context context) { void Isolate::set_context(Context context) {
DCHECK(context.is_null() || context->IsContext()); DCHECK(context.is_null() || context.IsContext());
thread_local_top()->context_ = context; thread_local_top()->context_ = context;
} }
Handle<NativeContext> Isolate::native_context() { Handle<NativeContext> Isolate::native_context() {
return handle(context()->native_context(), this); return handle(context().native_context(), this);
} }
NativeContext Isolate::raw_native_context() { NativeContext Isolate::raw_native_context() {
return context()->native_context(); return context().native_context();
} }
Object Isolate::pending_exception() { Object Isolate::pending_exception() {
DCHECK(has_pending_exception()); DCHECK(has_pending_exception());
DCHECK(!thread_local_top()->pending_exception_->IsException(this)); DCHECK(!thread_local_top()->pending_exception_.IsException(this));
return thread_local_top()->pending_exception_; return thread_local_top()->pending_exception_;
} }
void Isolate::set_pending_exception(Object exception_obj) { void Isolate::set_pending_exception(Object exception_obj) {
DCHECK(!exception_obj->IsException(this)); DCHECK(!exception_obj.IsException(this));
thread_local_top()->pending_exception_ = exception_obj; thread_local_top()->pending_exception_ = exception_obj;
} }
void Isolate::clear_pending_exception() { void Isolate::clear_pending_exception() {
DCHECK(!thread_local_top()->pending_exception_->IsException(this)); DCHECK(!thread_local_top()->pending_exception_.IsException(this));
thread_local_top()->pending_exception_ = ReadOnlyRoots(this).the_hole_value(); thread_local_top()->pending_exception_ = ReadOnlyRoots(this).the_hole_value();
} }
bool Isolate::has_pending_exception() { bool Isolate::has_pending_exception() {
DCHECK(!thread_local_top()->pending_exception_->IsException(this)); DCHECK(!thread_local_top()->pending_exception_.IsException(this));
return !thread_local_top()->pending_exception_->IsTheHole(this); return !thread_local_top()->pending_exception_.IsTheHole(this);
} }
void Isolate::clear_pending_message() { void Isolate::clear_pending_message() {
@ -61,18 +61,18 @@ void Isolate::clear_pending_message() {
Object Isolate::scheduled_exception() { Object Isolate::scheduled_exception() {
DCHECK(has_scheduled_exception()); DCHECK(has_scheduled_exception());
DCHECK(!thread_local_top()->scheduled_exception_->IsException(this)); DCHECK(!thread_local_top()->scheduled_exception_.IsException(this));
return thread_local_top()->scheduled_exception_; return thread_local_top()->scheduled_exception_;
} }
bool Isolate::has_scheduled_exception() { bool Isolate::has_scheduled_exception() {
DCHECK(!thread_local_top()->scheduled_exception_->IsException(this)); DCHECK(!thread_local_top()->scheduled_exception_.IsException(this));
return thread_local_top()->scheduled_exception_ != return thread_local_top()->scheduled_exception_ !=
ReadOnlyRoots(this).the_hole_value(); ReadOnlyRoots(this).the_hole_value();
} }
void Isolate::clear_scheduled_exception() { void Isolate::clear_scheduled_exception() {
DCHECK(!thread_local_top()->scheduled_exception_->IsException(this)); DCHECK(!thread_local_top()->scheduled_exception_.IsException(this));
thread_local_top()->scheduled_exception_ = thread_local_top()->scheduled_exception_ =
ReadOnlyRoots(this).the_hole_value(); ReadOnlyRoots(this).the_hole_value();
} }
@ -88,11 +88,11 @@ void Isolate::FireBeforeCallEnteredCallback() {
} }
Handle<JSGlobalObject> Isolate::global_object() { Handle<JSGlobalObject> Isolate::global_object() {
return handle(context()->global_object(), this); return handle(context().global_object(), this);
} }
Handle<JSGlobalProxy> Isolate::global_proxy() { Handle<JSGlobalProxy> Isolate::global_proxy() {
return handle(context()->global_proxy(), this); return handle(context().global_proxy(), this);
} }
Isolate::ExceptionScope::ExceptionScope(Isolate* isolate) Isolate::ExceptionScope::ExceptionScope(Isolate* isolate)
@ -103,12 +103,12 @@ Isolate::ExceptionScope::~ExceptionScope() {
isolate_->set_pending_exception(*pending_exception_); isolate_->set_pending_exception(*pending_exception_);
} }
#define NATIVE_CONTEXT_FIELD_ACCESSOR(index, type, name) \ #define NATIVE_CONTEXT_FIELD_ACCESSOR(index, type, name) \
Handle<type> Isolate::name() { \ Handle<type> Isolate::name() { \
return Handle<type>(raw_native_context()->name(), this); \ return Handle<type>(raw_native_context().name(), this); \
} \ } \
bool Isolate::is_##name(type value) { \ bool Isolate::is_##name(type value) { \
return raw_native_context()->is_##name(value); \ return raw_native_context().is_##name(value); \
} }
NATIVE_CONTEXT_FIELDS(NATIVE_CONTEXT_FIELD_ACCESSOR) NATIVE_CONTEXT_FIELDS(NATIVE_CONTEXT_FIELD_ACCESSOR)
#undef NATIVE_CONTEXT_FIELD_ACCESSOR #undef NATIVE_CONTEXT_FIELD_ACCESSOR
@ -116,7 +116,7 @@ NATIVE_CONTEXT_FIELDS(NATIVE_CONTEXT_FIELD_ACCESSOR)
bool Isolate::IsArrayConstructorIntact() { bool Isolate::IsArrayConstructorIntact() {
Cell array_constructor_cell = Cell array_constructor_cell =
Cell::cast(root(RootIndex::kArrayConstructorProtector)); Cell::cast(root(RootIndex::kArrayConstructorProtector));
return array_constructor_cell->value() == Smi::FromInt(kProtectorValid); return array_constructor_cell.value() == Smi::FromInt(kProtectorValid);
} }
bool Isolate::IsArraySpeciesLookupChainIntact() { bool Isolate::IsArraySpeciesLookupChainIntact() {
@ -134,64 +134,64 @@ bool Isolate::IsArraySpeciesLookupChainIntact() {
PropertyCell species_cell = PropertyCell species_cell =
PropertyCell::cast(root(RootIndex::kArraySpeciesProtector)); PropertyCell::cast(root(RootIndex::kArraySpeciesProtector));
return species_cell->value()->IsSmi() && return species_cell.value().IsSmi() &&
Smi::ToInt(species_cell->value()) == kProtectorValid; Smi::ToInt(species_cell.value()) == kProtectorValid;
} }
bool Isolate::IsTypedArraySpeciesLookupChainIntact() { bool Isolate::IsTypedArraySpeciesLookupChainIntact() {
PropertyCell species_cell = PropertyCell species_cell =
PropertyCell::cast(root(RootIndex::kTypedArraySpeciesProtector)); PropertyCell::cast(root(RootIndex::kTypedArraySpeciesProtector));
return species_cell->value()->IsSmi() && return species_cell.value().IsSmi() &&
Smi::ToInt(species_cell->value()) == kProtectorValid; Smi::ToInt(species_cell.value()) == kProtectorValid;
} }
bool Isolate::IsRegExpSpeciesLookupChainIntact() { bool Isolate::IsRegExpSpeciesLookupChainIntact() {
PropertyCell species_cell = PropertyCell species_cell =
PropertyCell::cast(root(RootIndex::kRegExpSpeciesProtector)); PropertyCell::cast(root(RootIndex::kRegExpSpeciesProtector));
return species_cell->value()->IsSmi() && return species_cell.value().IsSmi() &&
Smi::ToInt(species_cell->value()) == kProtectorValid; Smi::ToInt(species_cell.value()) == kProtectorValid;
} }
bool Isolate::IsPromiseSpeciesLookupChainIntact() { bool Isolate::IsPromiseSpeciesLookupChainIntact() {
PropertyCell species_cell = PropertyCell species_cell =
PropertyCell::cast(root(RootIndex::kPromiseSpeciesProtector)); PropertyCell::cast(root(RootIndex::kPromiseSpeciesProtector));
return species_cell->value()->IsSmi() && return species_cell.value().IsSmi() &&
Smi::ToInt(species_cell->value()) == kProtectorValid; Smi::ToInt(species_cell.value()) == kProtectorValid;
} }
bool Isolate::IsStringLengthOverflowIntact() { bool Isolate::IsStringLengthOverflowIntact() {
Cell string_length_cell = Cell::cast(root(RootIndex::kStringLengthProtector)); Cell string_length_cell = Cell::cast(root(RootIndex::kStringLengthProtector));
return string_length_cell->value() == Smi::FromInt(kProtectorValid); return string_length_cell.value() == Smi::FromInt(kProtectorValid);
} }
bool Isolate::IsArrayBufferDetachingIntact() { bool Isolate::IsArrayBufferDetachingIntact() {
PropertyCell buffer_detaching = PropertyCell buffer_detaching =
PropertyCell::cast(root(RootIndex::kArrayBufferDetachingProtector)); PropertyCell::cast(root(RootIndex::kArrayBufferDetachingProtector));
return buffer_detaching->value() == Smi::FromInt(kProtectorValid); return buffer_detaching.value() == Smi::FromInt(kProtectorValid);
} }
bool Isolate::IsArrayIteratorLookupChainIntact() { bool Isolate::IsArrayIteratorLookupChainIntact() {
PropertyCell array_iterator_cell = PropertyCell array_iterator_cell =
PropertyCell::cast(root(RootIndex::kArrayIteratorProtector)); PropertyCell::cast(root(RootIndex::kArrayIteratorProtector));
return array_iterator_cell->value() == Smi::FromInt(kProtectorValid); return array_iterator_cell.value() == Smi::FromInt(kProtectorValid);
} }
bool Isolate::IsMapIteratorLookupChainIntact() { bool Isolate::IsMapIteratorLookupChainIntact() {
PropertyCell map_iterator_cell = PropertyCell map_iterator_cell =
PropertyCell::cast(root(RootIndex::kMapIteratorProtector)); PropertyCell::cast(root(RootIndex::kMapIteratorProtector));
return map_iterator_cell->value() == Smi::FromInt(kProtectorValid); return map_iterator_cell.value() == Smi::FromInt(kProtectorValid);
} }
bool Isolate::IsSetIteratorLookupChainIntact() { bool Isolate::IsSetIteratorLookupChainIntact() {
PropertyCell set_iterator_cell = PropertyCell set_iterator_cell =
PropertyCell::cast(root(RootIndex::kSetIteratorProtector)); PropertyCell::cast(root(RootIndex::kSetIteratorProtector));
return set_iterator_cell->value() == Smi::FromInt(kProtectorValid); return set_iterator_cell.value() == Smi::FromInt(kProtectorValid);
} }
bool Isolate::IsStringIteratorLookupChainIntact() { bool Isolate::IsStringIteratorLookupChainIntact() {
PropertyCell string_iterator_cell = PropertyCell string_iterator_cell =
PropertyCell::cast(root(RootIndex::kStringIteratorProtector)); PropertyCell::cast(root(RootIndex::kStringIteratorProtector));
return string_iterator_cell->value() == Smi::FromInt(kProtectorValid); return string_iterator_cell.value() == Smi::FromInt(kProtectorValid);
} }
} // namespace internal } // namespace internal

View File

@ -295,7 +295,7 @@ size_t Isolate::HashIsolateForEmbeddedBlob() {
// The builtins constants table is also tightly tied to embedded builtins. // The builtins constants table is also tightly tied to embedded builtins.
hash = base::hash_combine( hash = base::hash_combine(
hash, static_cast<size_t>(heap_.builtins_constants_table()->length())); hash, static_cast<size_t>(heap_.builtins_constants_table().length()));
return hash; return hash;
} }
@ -602,7 +602,7 @@ class FrameArrayBuilder {
Handle<Object> receiver(generator_object->receiver(), isolate_); Handle<Object> receiver(generator_object->receiver(), isolate_);
Handle<AbstractCode> code( Handle<AbstractCode> code(
AbstractCode::cast(function->shared()->GetBytecodeArray()), isolate_); AbstractCode::cast(function->shared().GetBytecodeArray()), isolate_);
int offset = Smi::ToInt(generator_object->input_or_debug_pos()); int offset = Smi::ToInt(generator_object->input_or_debug_pos());
// The stored bytecode offset is relative to a different base than what // The stored bytecode offset is relative to a different base than what
// is used in the source position table, hence the subtraction. // is used in the source position table, hence the subtraction.
@ -610,11 +610,10 @@ class FrameArrayBuilder {
Handle<FixedArray> parameters = isolate_->factory()->empty_fixed_array(); Handle<FixedArray> parameters = isolate_->factory()->empty_fixed_array();
if (V8_UNLIKELY(FLAG_detailed_error_stack_trace)) { if (V8_UNLIKELY(FLAG_detailed_error_stack_trace)) {
int param_count = function->shared()->internal_formal_parameter_count(); int param_count = function->shared().internal_formal_parameter_count();
parameters = isolate_->factory()->NewFixedArray(param_count); parameters = isolate_->factory()->NewFixedArray(param_count);
for (int i = 0; i < param_count; i++) { for (int i = 0; i < param_count; i++) {
parameters->set(i, parameters->set(i, generator_object->parameters_and_registers().get(i));
generator_object->parameters_and_registers()->get(i));
} }
} }
@ -669,7 +668,7 @@ class FrameArrayBuilder {
if (summary.code()->kind() != wasm::WasmCode::kFunction) return; if (summary.code()->kind() != wasm::WasmCode::kFunction) return;
Handle<WasmInstanceObject> instance = summary.wasm_instance(); Handle<WasmInstanceObject> instance = summary.wasm_instance();
int flags = 0; int flags = 0;
if (instance->module_object()->is_asm_js()) { if (instance->module_object().is_asm_js()) {
flags |= FrameArray::kIsAsmJsWasmFrame; flags |= FrameArray::kIsAsmJsWasmFrame;
if (summary.at_to_number_conversion()) { if (summary.at_to_number_conversion()) {
flags |= FrameArray::kAsmJsAtNumberConversion; flags |= FrameArray::kAsmJsAtNumberConversion;
@ -687,7 +686,7 @@ class FrameArrayBuilder {
FrameSummary::WasmInterpretedFrameSummary const& summary) { FrameSummary::WasmInterpretedFrameSummary const& summary) {
Handle<WasmInstanceObject> instance = summary.wasm_instance(); Handle<WasmInstanceObject> instance = summary.wasm_instance();
int flags = FrameArray::kIsWasmInterpretedFrame; int flags = FrameArray::kIsWasmInterpretedFrame;
DCHECK(!instance->module_object()->is_asm_js()); DCHECK(!instance->module_object().is_asm_js());
elements_ = FrameArray::AppendWasmFrame(elements_, instance, elements_ = FrameArray::AppendWasmFrame(elements_, instance,
summary.function_index(), {}, summary.function_index(), {},
summary.byte_offset(), flags); summary.byte_offset(), flags);
@ -702,7 +701,7 @@ class FrameArrayBuilder {
// TODO(szuend): Remove this check once the flag is enabled // TODO(szuend): Remove this check once the flag is enabled
// by default. // by default.
if (!FLAG_experimental_stack_trace_frames && if (!FLAG_experimental_stack_trace_frames &&
function->shared()->IsApiFunction()) { function->shared().IsApiFunction()) {
return; return;
} }
@ -778,7 +777,7 @@ class FrameArrayBuilder {
bool IsStrictFrame(Handle<JSFunction> function) { bool IsStrictFrame(Handle<JSFunction> function) {
if (!encountered_strict_function_) { if (!encountered_strict_function_) {
encountered_strict_function_ = encountered_strict_function_ =
is_strict(function->shared()->language_mode()); is_strict(function->shared().language_mode());
} }
return encountered_strict_function_; return encountered_strict_function_;
} }
@ -818,16 +817,15 @@ class FrameArrayBuilder {
// The --builtins-in-stack-traces command line flag allows including // The --builtins-in-stack-traces command line flag allows including
// internal call sites in the stack trace for debugging purposes. // internal call sites in the stack trace for debugging purposes.
if (!FLAG_builtins_in_stack_traces && if (!FLAG_builtins_in_stack_traces &&
!function->shared()->IsUserJavaScript()) { !function->shared().IsUserJavaScript()) {
return function->shared()->native() || return function->shared().native() || function->shared().IsApiFunction();
function->shared()->IsApiFunction();
} }
return true; return true;
} }
bool IsInSameSecurityContext(Handle<JSFunction> function) { bool IsInSameSecurityContext(Handle<JSFunction> function) {
if (!check_security_context_) return true; if (!check_security_context_) return true;
return isolate_->context()->HasSameSecurityTokenAs(function->context()); return isolate_->context().HasSameSecurityTokenAs(function->context());
} }
// TODO(jgruber): Fix all cases in which frames give us a hole value (e.g. the // TODO(jgruber): Fix all cases in which frames give us a hole value (e.g. the
@ -869,9 +867,9 @@ bool NoExtension(const v8::FunctionCallbackInfo<v8::Value>&) { return false; }
bool IsBuiltinFunction(Isolate* isolate, HeapObject object, bool IsBuiltinFunction(Isolate* isolate, HeapObject object,
Builtins::Name builtin_index) { Builtins::Name builtin_index) {
if (!object->IsJSFunction()) return false; if (!object.IsJSFunction()) return false;
JSFunction const function = JSFunction::cast(object); JSFunction const function = JSFunction::cast(object);
return function->code() == isolate->builtins()->builtin(builtin_index); return function.code() == isolate->builtins()->builtin(builtin_index);
} }
void CaptureAsyncStackTrace(Isolate* isolate, Handle<JSPromise> promise, void CaptureAsyncStackTrace(Isolate* isolate, Handle<JSPromise> promise,
@ -881,10 +879,10 @@ void CaptureAsyncStackTrace(Isolate* isolate, Handle<JSPromise> promise,
if (promise->status() != Promise::kPending) return; if (promise->status() != Promise::kPending) return;
// Check that we have exactly one PromiseReaction on the {promise}. // Check that we have exactly one PromiseReaction on the {promise}.
if (!promise->reactions()->IsPromiseReaction()) return; if (!promise->reactions().IsPromiseReaction()) return;
Handle<PromiseReaction> reaction( Handle<PromiseReaction> reaction(
PromiseReaction::cast(promise->reactions()), isolate); PromiseReaction::cast(promise->reactions()), isolate);
if (!reaction->next()->IsSmi()) return; if (!reaction->next().IsSmi()) return;
// Check if the {reaction} has one of the known async function or // Check if the {reaction} has one of the known async function or
// async generator continuations as its fulfill handler. // async generator continuations as its fulfill handler.
@ -897,7 +895,7 @@ void CaptureAsyncStackTrace(Isolate* isolate, Handle<JSPromise> promise,
// Now peak into the handlers' AwaitContext to get to // Now peak into the handlers' AwaitContext to get to
// the JSGeneratorObject for the async function. // the JSGeneratorObject for the async function.
Handle<Context> context( Handle<Context> context(
JSFunction::cast(reaction->fulfill_handler())->context(), isolate); JSFunction::cast(reaction->fulfill_handler()).context(), isolate);
Handle<JSGeneratorObject> generator_object( Handle<JSGeneratorObject> generator_object(
JSGeneratorObject::cast(context->extension()), isolate); JSGeneratorObject::cast(context->extension()), isolate);
CHECK(generator_object->is_suspended()); CHECK(generator_object->is_suspended());
@ -913,7 +911,7 @@ void CaptureAsyncStackTrace(Isolate* isolate, Handle<JSPromise> promise,
} else { } else {
Handle<JSAsyncGeneratorObject> async_generator_object = Handle<JSAsyncGeneratorObject> async_generator_object =
Handle<JSAsyncGeneratorObject>::cast(generator_object); Handle<JSAsyncGeneratorObject>::cast(generator_object);
if (async_generator_object->queue()->IsUndefined(isolate)) return; if (async_generator_object->queue().IsUndefined(isolate)) return;
Handle<AsyncGeneratorRequest> async_generator_request( Handle<AsyncGeneratorRequest> async_generator_request(
AsyncGeneratorRequest::cast(async_generator_object->queue()), AsyncGeneratorRequest::cast(async_generator_object->queue()),
isolate); isolate);
@ -938,7 +936,7 @@ void CaptureAsyncStackTrace(Isolate* isolate, Handle<JSPromise> promise,
PromiseBuiltins::kPromiseAllResolveElementCapabilitySlot; PromiseBuiltins::kPromiseAllResolveElementCapabilitySlot;
Handle<PromiseCapability> capability( Handle<PromiseCapability> capability(
PromiseCapability::cast(context->get(index)), isolate); PromiseCapability::cast(context->get(index)), isolate);
if (!capability->promise()->IsJSPromise()) return; if (!capability->promise().IsJSPromise()) return;
promise = handle(JSPromise::cast(capability->promise()), isolate); promise = handle(JSPromise::cast(capability->promise()), isolate);
} else { } else {
// We have some generic promise chain here, so try to // We have some generic promise chain here, so try to
@ -951,7 +949,7 @@ void CaptureAsyncStackTrace(Isolate* isolate, Handle<JSPromise> promise,
} else if (promise_or_capability->IsPromiseCapability()) { } else if (promise_or_capability->IsPromiseCapability()) {
Handle<PromiseCapability> capability = Handle<PromiseCapability> capability =
Handle<PromiseCapability>::cast(promise_or_capability); Handle<PromiseCapability>::cast(promise_or_capability);
if (!capability->promise()->IsJSPromise()) return; if (!capability->promise().IsJSPromise()) return;
promise = handle(JSPromise::cast(capability->promise()), isolate); promise = handle(JSPromise::cast(capability->promise()), isolate);
} else { } else {
// Otherwise the {promise_or_capability} must be undefined here. // Otherwise the {promise_or_capability} must be undefined here.
@ -1068,7 +1066,7 @@ Handle<Object> CaptureStackTrace(Isolate* isolate, Handle<Object> caller,
// Now peak into the handlers' AwaitContext to get to // Now peak into the handlers' AwaitContext to get to
// the JSGeneratorObject for the async function. // the JSGeneratorObject for the async function.
Handle<Context> context( Handle<Context> context(
JSFunction::cast(promise_reaction_job_task->handler())->context(), JSFunction::cast(promise_reaction_job_task->handler()).context(),
isolate); isolate);
Handle<JSGeneratorObject> generator_object( Handle<JSGeneratorObject> generator_object(
JSGeneratorObject::cast(context->extension()), isolate); JSGeneratorObject::cast(context->extension()), isolate);
@ -1186,12 +1184,12 @@ Address Isolate::GetAbstractPC(int* line, int* column) {
JavaScriptFrame* frame = it.frame(); JavaScriptFrame* frame = it.frame();
DCHECK(!frame->is_builtin()); DCHECK(!frame->is_builtin());
Handle<SharedFunctionInfo> shared = handle(frame->function()->shared(), this); Handle<SharedFunctionInfo> shared = handle(frame->function().shared(), this);
SharedFunctionInfo::EnsureSourcePositionsAvailable(this, shared); SharedFunctionInfo::EnsureSourcePositionsAvailable(this, shared);
int position = frame->position(); int position = frame->position();
Object maybe_script = frame->function()->shared()->script(); Object maybe_script = frame->function().shared().script();
if (maybe_script->IsScript()) { if (maybe_script.IsScript()) {
Handle<Script> script(Script::cast(maybe_script), this); Handle<Script> script(Script::cast(maybe_script), this);
Script::PositionInfo info; Script::PositionInfo info;
Script::GetPositionInfo(script, position, &info, Script::WITH_OFFSET); Script::GetPositionInfo(script, position, &info, Script::WITH_OFFSET);
@ -1205,7 +1203,7 @@ Address Isolate::GetAbstractPC(int* line, int* column) {
if (frame->is_interpreted()) { if (frame->is_interpreted()) {
InterpretedFrame* iframe = static_cast<InterpretedFrame*>(frame); InterpretedFrame* iframe = static_cast<InterpretedFrame*>(frame);
Address bytecode_start = Address bytecode_start =
iframe->GetBytecodeArray()->GetFirstBytecodeAddress(); iframe->GetBytecodeArray().GetFirstBytecodeAddress();
return bytecode_start + iframe->GetBytecodeOffset(); return bytecode_start + iframe->GetBytecodeOffset();
} }
@ -1305,7 +1303,7 @@ void Isolate::ReportFailedAccessCheck(Handle<JSObject> receiver) {
return ScheduleThrow( return ScheduleThrow(
*factory()->NewTypeError(MessageTemplate::kNoAccess)); *factory()->NewTypeError(MessageTemplate::kNoAccess));
} }
data = handle(access_check_info->data(), this); data = handle(access_check_info.data(), this);
} }
// Leaving JavaScript. // Leaving JavaScript.
@ -1327,18 +1325,17 @@ bool Isolate::MayAccess(Handle<Context> accessing_context,
DisallowHeapAllocation no_gc; DisallowHeapAllocation no_gc;
if (receiver->IsJSGlobalProxy()) { if (receiver->IsJSGlobalProxy()) {
Object receiver_context = Object receiver_context = JSGlobalProxy::cast(*receiver).native_context();
JSGlobalProxy::cast(*receiver)->native_context(); if (!receiver_context.IsContext()) return false;
if (!receiver_context->IsContext()) return false;
// Get the native context of current top context. // Get the native context of current top context.
// avoid using Isolate::native_context() because it uses Handle. // avoid using Isolate::native_context() because it uses Handle.
Context native_context = Context native_context =
accessing_context->global_object()->native_context(); accessing_context->global_object().native_context();
if (receiver_context == native_context) return true; if (receiver_context == native_context) return true;
if (Context::cast(receiver_context)->security_token() == if (Context::cast(receiver_context).security_token() ==
native_context->security_token()) native_context.security_token())
return true; return true;
} }
} }
@ -1350,9 +1347,9 @@ bool Isolate::MayAccess(Handle<Context> accessing_context,
DisallowHeapAllocation no_gc; DisallowHeapAllocation no_gc;
AccessCheckInfo access_check_info = AccessCheckInfo::Get(this, receiver); AccessCheckInfo access_check_info = AccessCheckInfo::Get(this, receiver);
if (access_check_info.is_null()) return false; if (access_check_info.is_null()) return false;
Object fun_obj = access_check_info->callback(); Object fun_obj = access_check_info.callback();
callback = v8::ToCData<v8::AccessCheckCallback>(fun_obj); callback = v8::ToCData<v8::AccessCheckCallback>(fun_obj);
data = handle(access_check_info->data(), this); data = handle(access_check_info.data(), this);
} }
LOG(this, ApiSecurityCheck()); LOG(this, ApiSecurityCheck());
@ -1449,27 +1446,27 @@ void ReportBootstrappingException(Handle<Object> exception,
// to the console for easier debugging. // to the console for easier debugging.
int line_number = int line_number =
location->script()->GetLineNumber(location->start_pos()) + 1; location->script()->GetLineNumber(location->start_pos()) + 1;
if (exception->IsString() && location->script()->name()->IsString()) { if (exception->IsString() && location->script()->name().IsString()) {
base::OS::PrintError( base::OS::PrintError(
"Extension or internal compilation error: %s in %s at line %d.\n", "Extension or internal compilation error: %s in %s at line %d.\n",
String::cast(*exception)->ToCString().get(), String::cast(*exception).ToCString().get(),
String::cast(location->script()->name())->ToCString().get(), String::cast(location->script()->name()).ToCString().get(),
line_number); line_number);
} else if (location->script()->name()->IsString()) { } else if (location->script()->name().IsString()) {
base::OS::PrintError( base::OS::PrintError(
"Extension or internal compilation error in %s at line %d.\n", "Extension or internal compilation error in %s at line %d.\n",
String::cast(location->script()->name())->ToCString().get(), String::cast(location->script()->name()).ToCString().get(),
line_number); line_number);
} else if (exception->IsString()) { } else if (exception->IsString()) {
base::OS::PrintError("Extension or internal compilation error: %s.\n", base::OS::PrintError("Extension or internal compilation error: %s.\n",
String::cast(*exception)->ToCString().get()); String::cast(*exception).ToCString().get());
} else { } else {
base::OS::PrintError("Extension or internal compilation error.\n"); base::OS::PrintError("Extension or internal compilation error.\n");
} }
#ifdef OBJECT_PRINT #ifdef OBJECT_PRINT
// Since comments and empty lines have been stripped from the source of // Since comments and empty lines have been stripped from the source of
// builtins, print the actual source here so that line numbers match. // builtins, print the actual source here so that line numbers match.
if (location->script()->source()->IsString()) { if (location->script()->source().IsString()) {
Handle<String> src(String::cast(location->script()->source()), Handle<String> src(String::cast(location->script()->source()),
location->script()->GetIsolate()); location->script()->GetIsolate());
PrintF("Failing script:"); PrintF("Failing script:");
@ -1506,8 +1503,8 @@ Object Isolate::Throw(Object raw_exception, MessageLocation* location) {
Handle<Script> script = location->script(); Handle<Script> script = location->script();
Handle<Object> name(script->GetNameOrSourceURL(), this); Handle<Object> name(script->GetNameOrSourceURL(), this);
printf("at "); printf("at ");
if (name->IsString() && String::cast(*name)->length() > 0) if (name->IsString() && String::cast(*name).length() > 0)
String::cast(*name)->PrintOn(stdout); String::cast(*name).PrintOn(stdout);
else else
printf("<anonymous>"); printf("<anonymous>");
// Script::GetLineNumber and Script::GetColumnNumber can allocate on the heap to // Script::GetLineNumber and Script::GetColumnNumber can allocate on the heap to
@ -1528,7 +1525,7 @@ Object Isolate::Throw(Object raw_exception, MessageLocation* location) {
printf(", line %d\n", script->GetLineNumber(location->start_pos()) + 1); printf(", line %d\n", script->GetLineNumber(location->start_pos()) + 1);
} }
} }
raw_exception->Print(); raw_exception.Print();
printf("Stack Trace:\n"); printf("Stack Trace:\n");
PrintStack(stdout); PrintStack(stdout);
printf("=========================================================\n"); printf("=========================================================\n");
@ -1653,8 +1650,8 @@ Object Isolate::UnwindAndFindHandler() {
// Gather information from the handler. // Gather information from the handler.
Code code = frame->LookupCode(); Code code = frame->LookupCode();
HandlerTable table(code); HandlerTable table(code);
return FoundHandler(Context(), code->InstructionStart(), return FoundHandler(Context(), code.InstructionStart(),
table.LookupReturn(0), code->constant_pool(), table.LookupReturn(0), code.constant_pool(),
handler->address() + StackHandlerConstants::kSize, handler->address() + StackHandlerConstants::kSize,
0); 0);
} }
@ -1720,17 +1717,17 @@ Object Isolate::UnwindAndFindHandler() {
// TODO(bmeurer): Turbofanned BUILTIN frames appear as OPTIMIZED, // TODO(bmeurer): Turbofanned BUILTIN frames appear as OPTIMIZED,
// but do not have a code kind of OPTIMIZED_FUNCTION. // but do not have a code kind of OPTIMIZED_FUNCTION.
if (code->kind() == Code::OPTIMIZED_FUNCTION && if (code.kind() == Code::OPTIMIZED_FUNCTION &&
code->marked_for_deoptimization()) { code.marked_for_deoptimization()) {
// If the target code is lazy deoptimized, we jump to the original // If the target code is lazy deoptimized, we jump to the original
// return address, but we make a note that we are throwing, so // return address, but we make a note that we are throwing, so
// that the deoptimizer can do the right thing. // that the deoptimizer can do the right thing.
offset = static_cast<int>(frame->pc() - code->entry()); offset = static_cast<int>(frame->pc() - code.entry());
set_deoptimizer_lazy_throw(true); set_deoptimizer_lazy_throw(true);
} }
return FoundHandler(Context(), code->InstructionStart(), offset, return FoundHandler(Context(), code.InstructionStart(), offset,
code->constant_pool(), return_sp, frame->fp()); code.constant_pool(), return_sp, frame->fp());
} }
case StackFrame::STUB: { case StackFrame::STUB: {
@ -1748,8 +1745,8 @@ Object Isolate::UnwindAndFindHandler() {
break; break;
} }
Code code = stub_frame->LookupCode(); Code code = stub_frame->LookupCode();
if (!code->IsCode() || code->kind() != Code::BUILTIN || if (!code.IsCode() || code.kind() != Code::BUILTIN ||
!code->has_handler_table() || !code->is_turbofanned()) { !code.has_handler_table() || !code.is_turbofanned()) {
break; break;
} }
@ -1763,8 +1760,8 @@ Object Isolate::UnwindAndFindHandler() {
StandardFrameConstants::kFixedFrameSizeAboveFp - StandardFrameConstants::kFixedFrameSizeAboveFp -
stack_slots * kSystemPointerSize; stack_slots * kSystemPointerSize;
return FoundHandler(Context(), code->InstructionStart(), offset, return FoundHandler(Context(), code.InstructionStart(), offset,
code->constant_pool(), return_sp, frame->fp()); code.constant_pool(), return_sp, frame->fp());
} }
case StackFrame::INTERPRETED: { case StackFrame::INTERPRETED: {
@ -1772,7 +1769,7 @@ Object Isolate::UnwindAndFindHandler() {
if (!catchable_by_js) break; if (!catchable_by_js) break;
InterpretedFrame* js_frame = static_cast<InterpretedFrame*>(frame); InterpretedFrame* js_frame = static_cast<InterpretedFrame*>(frame);
int register_slots = InterpreterFrameConstants::RegisterStackSlotCount( int register_slots = InterpreterFrameConstants::RegisterStackSlotCount(
js_frame->GetBytecodeArray()->register_count()); js_frame->GetBytecodeArray().register_count());
int context_reg = 0; // Will contain register index holding context. int context_reg = 0; // Will contain register index holding context.
int offset = int offset =
js_frame->LookupExceptionHandlerInTable(&context_reg, nullptr); js_frame->LookupExceptionHandlerInTable(&context_reg, nullptr);
@ -1796,8 +1793,8 @@ Object Isolate::UnwindAndFindHandler() {
Code code = Code code =
builtins()->builtin(Builtins::kInterpreterEnterBytecodeDispatch); builtins()->builtin(Builtins::kInterpreterEnterBytecodeDispatch);
return FoundHandler(context, code->InstructionStart(), 0, return FoundHandler(context, code.InstructionStart(), 0,
code->constant_pool(), return_sp, frame->fp()); code.constant_pool(), return_sp, frame->fp());
} }
case StackFrame::BUILTIN: case StackFrame::BUILTIN:
@ -1825,8 +1822,8 @@ Object Isolate::UnwindAndFindHandler() {
// Reconstruct the stack pointer from the frame pointer. // Reconstruct the stack pointer from the frame pointer.
Address return_sp = js_frame->fp() - js_frame->GetSPToFPDelta(); Address return_sp = js_frame->fp() - js_frame->GetSPToFPDelta();
Code code = js_frame->LookupCode(); Code code = js_frame->LookupCode();
return FoundHandler(Context(), code->InstructionStart(), 0, return FoundHandler(Context(), code.InstructionStart(), 0,
code->constant_pool(), return_sp, frame->fp()); code.constant_pool(), return_sp, frame->fp());
} break; } break;
default: default:
@ -1840,7 +1837,7 @@ Object Isolate::UnwindAndFindHandler() {
USE(removed); USE(removed);
// If there were any materialized objects, the code should be // If there were any materialized objects, the code should be
// marked for deopt. // marked for deopt.
DCHECK_IMPLIES(removed, frame->LookupCode()->marked_for_deoptimization()); DCHECK_IMPLIES(removed, frame->LookupCode().marked_for_deoptimization());
} }
} }
@ -1861,7 +1858,7 @@ HandlerTable::CatchPrediction PredictException(JavaScriptFrame* frame) {
const FrameSummary& summary = summaries[i - 1]; const FrameSummary& summary = summaries[i - 1];
Handle<AbstractCode> code = summary.AsJavaScript().abstract_code(); Handle<AbstractCode> code = summary.AsJavaScript().abstract_code();
if (code->IsCode() && code->kind() == AbstractCode::BUILTIN) { if (code->IsCode() && code->kind() == AbstractCode::BUILTIN) {
prediction = code->GetCode()->GetBuiltinCatchPrediction(); prediction = code->GetCode().GetBuiltinCatchPrediction();
if (prediction == HandlerTable::UNCAUGHT) continue; if (prediction == HandlerTable::UNCAUGHT) continue;
return prediction; return prediction;
} }
@ -1983,7 +1980,7 @@ void Isolate::RestorePendingMessageFromTryCatch(v8::TryCatch* handler) {
DCHECK(handler->rethrow_); DCHECK(handler->rethrow_);
DCHECK(handler->capture_message_); DCHECK(handler->capture_message_);
Object message(reinterpret_cast<Address>(handler->message_obj_)); Object message(reinterpret_cast<Address>(handler->message_obj_));
DCHECK(message->IsJSMessageObject() || message->IsTheHole(this)); DCHECK(message.IsJSMessageObject() || message.IsTheHole(this));
thread_local_top()->pending_message_obj_ = message; thread_local_top()->pending_message_obj_ = message;
} }
@ -2064,7 +2061,7 @@ bool Isolate::ComputeLocation(MessageLocation* target) {
Handle<SharedFunctionInfo> shared; Handle<SharedFunctionInfo> shared;
Handle<Object> script = summary.script(); Handle<Object> script = summary.script();
if (!script->IsScript() || if (!script->IsScript() ||
(Script::cast(*script)->source()->IsUndefined(this))) { (Script::cast(*script).source().IsUndefined(this))) {
return false; return false;
} }
@ -2123,15 +2120,15 @@ bool Isolate::ComputeLocationFromStackTrace(MessageLocation* target,
if (elements->IsWasmFrame(i) || elements->IsAsmJsWasmFrame(i)) { if (elements->IsWasmFrame(i) || elements->IsAsmJsWasmFrame(i)) {
Handle<WasmInstanceObject> instance(elements->WasmInstance(i), this); Handle<WasmInstanceObject> instance(elements->WasmInstance(i), this);
uint32_t func_index = uint32_t func_index =
static_cast<uint32_t>(elements->WasmFunctionIndex(i)->value()); static_cast<uint32_t>(elements->WasmFunctionIndex(i).value());
int code_offset = elements->Offset(i)->value(); int code_offset = elements->Offset(i).value();
bool is_at_number_conversion = bool is_at_number_conversion =
elements->IsAsmJsWasmFrame(i) && elements->IsAsmJsWasmFrame(i) &&
elements->Flags(i)->value() & FrameArray::kAsmJsAtNumberConversion; elements->Flags(i).value() & FrameArray::kAsmJsAtNumberConversion;
// WasmCode* held alive by the {GlobalWasmCodeRef}. // WasmCode* held alive by the {GlobalWasmCodeRef}.
wasm::WasmCode* code = wasm::WasmCode* code =
Managed<wasm::GlobalWasmCodeRef>::cast(elements->WasmCodeObject(i)) Managed<wasm::GlobalWasmCodeRef>::cast(elements->WasmCodeObject(i))
->get() .get()
->code(); ->code();
int byte_offset = int byte_offset =
FrameSummary::WasmCompiledFrameSummary::GetWasmSourcePosition( FrameSummary::WasmCompiledFrameSummary::GetWasmSourcePosition(
@ -2139,26 +2136,26 @@ bool Isolate::ComputeLocationFromStackTrace(MessageLocation* target,
int pos = WasmModuleObject::GetSourcePosition( int pos = WasmModuleObject::GetSourcePosition(
handle(instance->module_object(), this), func_index, byte_offset, handle(instance->module_object(), this), func_index, byte_offset,
is_at_number_conversion); is_at_number_conversion);
Handle<Script> script(instance->module_object()->script(), this); Handle<Script> script(instance->module_object().script(), this);
*target = MessageLocation(script, pos, pos + 1); *target = MessageLocation(script, pos, pos + 1);
return true; return true;
} }
Handle<JSFunction> fun = handle(elements->Function(i), this); Handle<JSFunction> fun = handle(elements->Function(i), this);
if (!fun->shared()->IsSubjectToDebugging()) continue; if (!fun->shared().IsSubjectToDebugging()) continue;
Object script = fun->shared()->script(); Object script = fun->shared().script();
if (script->IsScript() && if (script.IsScript() &&
!(Script::cast(script)->source()->IsUndefined(this))) { !(Script::cast(script).source().IsUndefined(this))) {
Handle<SharedFunctionInfo> shared = handle(fun->shared(), this); Handle<SharedFunctionInfo> shared = handle(fun->shared(), this);
AbstractCode abstract_code = elements->Code(i); AbstractCode abstract_code = elements->Code(i);
const int code_offset = elements->Offset(i)->value(); const int code_offset = elements->Offset(i).value();
Handle<Script> casted_script(Script::cast(script), this); Handle<Script> casted_script(Script::cast(script), this);
if (shared->HasBytecodeArray() && if (shared->HasBytecodeArray() &&
shared->GetBytecodeArray()->HasSourcePositionTable()) { shared->GetBytecodeArray().HasSourcePositionTable()) {
int pos = abstract_code->SourcePosition(code_offset); int pos = abstract_code.SourcePosition(code_offset);
*target = MessageLocation(casted_script, pos, pos + 1, shared); *target = MessageLocation(casted_script, pos, pos + 1, shared);
} else { } else {
*target = MessageLocation(casted_script, shared, code_offset); *target = MessageLocation(casted_script, shared, code_offset);
@ -2274,7 +2271,7 @@ void Isolate::ReportPendingMessagesImpl(bool report_externally) {
} }
// Actually report the pending message to all message handlers. // Actually report the pending message to all message handlers.
if (!message_obj->IsTheHole(this) && should_report_exception) { if (!message_obj.IsTheHole(this) && should_report_exception) {
HandleScope scope(this); HandleScope scope(this);
Handle<JSMessageObject> message(JSMessageObject::cast(message_obj), this); Handle<JSMessageObject> message(JSMessageObject::cast(message_obj), this);
Handle<Script> script(message->script(), this); Handle<Script> script(message->script(), this);
@ -2350,13 +2347,13 @@ void Isolate::ReportPendingMessagesFromJavaScript() {
thread_local_top()->external_caught_exception_ = true; thread_local_top()->external_caught_exception_ = true;
v8::TryCatch* handler = try_catch_handler(); v8::TryCatch* handler = try_catch_handler();
DCHECK(thread_local_top()->pending_message_obj_->IsJSMessageObject() || DCHECK(thread_local_top()->pending_message_obj_.IsJSMessageObject() ||
thread_local_top()->pending_message_obj_->IsTheHole(this)); thread_local_top()->pending_message_obj_.IsTheHole(this));
handler->can_continue_ = true; handler->can_continue_ = true;
handler->has_terminated_ = false; handler->has_terminated_ = false;
handler->exception_ = reinterpret_cast<void*>(pending_exception().ptr()); handler->exception_ = reinterpret_cast<void*>(pending_exception().ptr());
// Propagate to the external try-catch only if we got an actual message. // Propagate to the external try-catch only if we got an actual message.
if (thread_local_top()->pending_message_obj_->IsTheHole(this)) return true; if (thread_local_top()->pending_message_obj_.IsTheHole(this)) return true;
handler->message_obj_ = handler->message_obj_ =
reinterpret_cast<void*>(thread_local_top()->pending_message_obj_.ptr()); reinterpret_cast<void*>(thread_local_top()->pending_message_obj_.ptr());
@ -2484,7 +2481,7 @@ bool InternalPromiseHasUserDefinedRejectHandler(Isolate* isolate,
: handle(Handle<PromiseCapability>::cast(promise_or_capability) : handle(Handle<PromiseCapability>::cast(promise_or_capability)
->promise(), ->promise(),
isolate)); isolate));
if (reaction->reject_handler()->IsUndefined(isolate)) { if (reaction->reject_handler().IsUndefined(isolate)) {
if (InternalPromiseHasUserDefinedRejectHandler(isolate, promise)) { if (InternalPromiseHasUserDefinedRejectHandler(isolate, promise)) {
return true; return true;
} }
@ -2529,11 +2526,11 @@ Handle<Object> Isolate::GetPromiseOnStackOnThrow() {
catch_prediction = PredictException(JavaScriptFrame::cast(frame)); catch_prediction = PredictException(JavaScriptFrame::cast(frame));
} else if (frame->type() == StackFrame::STUB) { } else if (frame->type() == StackFrame::STUB) {
Code code = frame->LookupCode(); Code code = frame->LookupCode();
if (!code->IsCode() || code->kind() != Code::BUILTIN || if (!code.IsCode() || code.kind() != Code::BUILTIN ||
!code->has_handler_table() || !code->is_turbofanned()) { !code.has_handler_table() || !code.is_turbofanned()) {
continue; continue;
} }
catch_prediction = code->GetBuiltinCatchPrediction(); catch_prediction = code.GetBuiltinCatchPrediction();
} else { } else {
continue; continue;
} }
@ -2611,7 +2608,7 @@ Handle<Context> Isolate::GetIncumbentContext() {
if (!it.done() && if (!it.done() &&
(!top_backup_incumbent || it.frame()->sp() < top_backup_incumbent)) { (!top_backup_incumbent || it.frame()->sp() < top_backup_incumbent)) {
Context context = Context::cast(it.frame()->context()); Context context = Context::cast(it.frame()->context());
return Handle<Context>(context->native_context(), this); return Handle<Context>(context.native_context(), this);
} }
// 2nd candidate: the last Context::Scope's incumbent context if any. // 2nd candidate: the last Context::Scope's incumbent context if any.
@ -2647,7 +2644,7 @@ char* Isolate::RestoreThread(char* from) {
#ifdef USE_SIMULATOR #ifdef USE_SIMULATOR
thread_local_top()->simulator_ = Simulator::current(this); thread_local_top()->simulator_ = Simulator::current(this);
#endif #endif
DCHECK(context().is_null() || context()->IsContext()); DCHECK(context().is_null() || context().IsContext());
return from + sizeof(ThreadLocalTop); return from + sizeof(ThreadLocalTop);
} }
@ -3144,13 +3141,13 @@ bool Isolate::PropagatePendingExceptionToExternalTryCatch() {
SetTerminationOnExternalTryCatch(); SetTerminationOnExternalTryCatch();
} else { } else {
v8::TryCatch* handler = try_catch_handler(); v8::TryCatch* handler = try_catch_handler();
DCHECK(thread_local_top()->pending_message_obj_->IsJSMessageObject() || DCHECK(thread_local_top()->pending_message_obj_.IsJSMessageObject() ||
thread_local_top()->pending_message_obj_->IsTheHole(this)); thread_local_top()->pending_message_obj_.IsTheHole(this));
handler->can_continue_ = true; handler->can_continue_ = true;
handler->has_terminated_ = false; handler->has_terminated_ = false;
handler->exception_ = reinterpret_cast<void*>(pending_exception().ptr()); handler->exception_ = reinterpret_cast<void*>(pending_exception().ptr());
// Propagate to the external try-catch only if we got an actual message. // Propagate to the external try-catch only if we got an actual message.
if (thread_local_top()->pending_message_obj_->IsTheHole(this)) return true; if (thread_local_top()->pending_message_obj_.IsTheHole(this)) return true;
handler->message_obj_ = handler->message_obj_ =
reinterpret_cast<void*>(thread_local_top()->pending_message_obj_.ptr()); reinterpret_cast<void*>(thread_local_top()->pending_message_obj_.ptr());
@ -3478,7 +3475,7 @@ bool Isolate::Init(ReadOnlyDeserializer* read_only_deserializer,
#ifndef V8_TARGET_ARCH_ARM #ifndef V8_TARGET_ARCH_ARM
// The IET for profiling should always be a full on-heap Code object. // The IET for profiling should always be a full on-heap Code object.
DCHECK(!Code::cast(heap_.interpreter_entry_trampoline_for_profiling()) DCHECK(!Code::cast(heap_.interpreter_entry_trampoline_for_profiling())
->is_off_heap_trampoline()); .is_off_heap_trampoline());
#endif // V8_TARGET_ARCH_ARM #endif // V8_TARGET_ARCH_ARM
if (FLAG_print_builtin_code) builtins()->PrintBuiltinCode(); if (FLAG_print_builtin_code) builtins()->PrintBuiltinCode();
@ -3686,14 +3683,14 @@ bool Isolate::NeedsSourcePositionsForProfiling() const {
} }
void Isolate::SetFeedbackVectorsForProfilingTools(Object value) { void Isolate::SetFeedbackVectorsForProfilingTools(Object value) {
DCHECK(value->IsUndefined(this) || value->IsArrayList()); DCHECK(value.IsUndefined(this) || value.IsArrayList());
heap()->set_feedback_vectors_for_profiling_tools(value); heap()->set_feedback_vectors_for_profiling_tools(value);
} }
void Isolate::MaybeInitializeVectorListFromHeap() { void Isolate::MaybeInitializeVectorListFromHeap() {
if (!heap()->feedback_vectors_for_profiling_tools()->IsUndefined(this)) { if (!heap()->feedback_vectors_for_profiling_tools().IsUndefined(this)) {
// Already initialized, return early. // Already initialized, return early.
DCHECK(heap()->feedback_vectors_for_profiling_tools()->IsArrayList()); DCHECK(heap()->feedback_vectors_for_profiling_tools().IsArrayList());
return; return;
} }
@ -3704,13 +3701,13 @@ void Isolate::MaybeInitializeVectorListFromHeap() {
HeapIterator heap_iterator(heap()); HeapIterator heap_iterator(heap());
for (HeapObject current_obj = heap_iterator.next(); !current_obj.is_null(); for (HeapObject current_obj = heap_iterator.next(); !current_obj.is_null();
current_obj = heap_iterator.next()) { current_obj = heap_iterator.next()) {
if (!current_obj->IsFeedbackVector()) continue; if (!current_obj.IsFeedbackVector()) continue;
FeedbackVector vector = FeedbackVector::cast(current_obj); FeedbackVector vector = FeedbackVector::cast(current_obj);
SharedFunctionInfo shared = vector->shared_function_info(); SharedFunctionInfo shared = vector.shared_function_info();
// No need to preserve the feedback vector for non-user-visible functions. // No need to preserve the feedback vector for non-user-visible functions.
if (!shared->IsSubjectToDebugging()) continue; if (!shared.IsSubjectToDebugging()) continue;
vectors.emplace_back(vector, this); vectors.emplace_back(vector, this);
} }
@ -3732,14 +3729,14 @@ void Isolate::set_date_cache(DateCache* date_cache) {
bool Isolate::IsArrayOrObjectOrStringPrototype(Object object) { bool Isolate::IsArrayOrObjectOrStringPrototype(Object object) {
Object context = heap()->native_contexts_list(); Object context = heap()->native_contexts_list();
while (!context->IsUndefined(this)) { while (!context.IsUndefined(this)) {
Context current_context = Context::cast(context); Context current_context = Context::cast(context);
if (current_context->initial_object_prototype() == object || if (current_context.initial_object_prototype() == object ||
current_context->initial_array_prototype() == object || current_context.initial_array_prototype() == object ||
current_context->initial_string_prototype() == object) { current_context.initial_string_prototype() == object) {
return true; return true;
} }
context = current_context->next_context_link(); context = current_context.next_context_link();
} }
return false; return false;
} }
@ -3747,12 +3744,12 @@ bool Isolate::IsArrayOrObjectOrStringPrototype(Object object) {
bool Isolate::IsInAnyContext(Object object, uint32_t index) { bool Isolate::IsInAnyContext(Object object, uint32_t index) {
DisallowHeapAllocation no_gc; DisallowHeapAllocation no_gc;
Object context = heap()->native_contexts_list(); Object context = heap()->native_contexts_list();
while (!context->IsUndefined(this)) { while (!context.IsUndefined(this)) {
Context current_context = Context::cast(context); Context current_context = Context::cast(context);
if (current_context->get(index) == object) { if (current_context.get(index) == object) {
return true; return true;
} }
context = current_context->next_context_link(); context = current_context.next_context_link();
} }
return false; return false;
} }
@ -3760,20 +3757,20 @@ bool Isolate::IsInAnyContext(Object object, uint32_t index) {
bool Isolate::IsNoElementsProtectorIntact(Context context) { bool Isolate::IsNoElementsProtectorIntact(Context context) {
PropertyCell no_elements_cell = heap()->no_elements_protector(); PropertyCell no_elements_cell = heap()->no_elements_protector();
bool cell_reports_intact = bool cell_reports_intact =
no_elements_cell->value()->IsSmi() && no_elements_cell.value().IsSmi() &&
Smi::ToInt(no_elements_cell->value()) == kProtectorValid; Smi::ToInt(no_elements_cell.value()) == kProtectorValid;
#ifdef DEBUG #ifdef DEBUG
Context native_context = context->native_context(); Context native_context = context.native_context();
Map root_array_map = Map root_array_map =
native_context->GetInitialJSArrayMap(GetInitialFastElementsKind()); native_context.GetInitialJSArrayMap(GetInitialFastElementsKind());
JSObject initial_array_proto = JSObject::cast( JSObject initial_array_proto = JSObject::cast(
native_context->get(Context::INITIAL_ARRAY_PROTOTYPE_INDEX)); native_context.get(Context::INITIAL_ARRAY_PROTOTYPE_INDEX));
JSObject initial_object_proto = JSObject::cast( JSObject initial_object_proto = JSObject::cast(
native_context->get(Context::INITIAL_OBJECT_PROTOTYPE_INDEX)); native_context.get(Context::INITIAL_OBJECT_PROTOTYPE_INDEX));
JSObject initial_string_proto = JSObject::cast( JSObject initial_string_proto = JSObject::cast(
native_context->get(Context::INITIAL_STRING_PROTOTYPE_INDEX)); native_context.get(Context::INITIAL_STRING_PROTOTYPE_INDEX));
if (root_array_map.is_null() || initial_array_proto == initial_object_proto) { if (root_array_map.is_null() || initial_array_proto == initial_object_proto) {
// We are in the bootstrapping process, and the entire check sequence // We are in the bootstrapping process, and the entire check sequence
@ -3782,12 +3779,12 @@ bool Isolate::IsNoElementsProtectorIntact(Context context) {
} }
// Check that the array prototype hasn't been altered WRT empty elements. // Check that the array prototype hasn't been altered WRT empty elements.
if (root_array_map->prototype() != initial_array_proto) { if (root_array_map.prototype() != initial_array_proto) {
DCHECK_EQ(false, cell_reports_intact); DCHECK_EQ(false, cell_reports_intact);
return cell_reports_intact; return cell_reports_intact;
} }
FixedArrayBase elements = initial_array_proto->elements(); FixedArrayBase elements = initial_array_proto.elements();
ReadOnlyRoots roots(heap()); ReadOnlyRoots roots(heap());
if (elements != roots.empty_fixed_array() && if (elements != roots.empty_fixed_array() &&
elements != roots.empty_slow_element_dictionary()) { elements != roots.empty_slow_element_dictionary()) {
@ -3796,7 +3793,7 @@ bool Isolate::IsNoElementsProtectorIntact(Context context) {
} }
// Check that the Object.prototype hasn't been altered WRT empty elements. // Check that the Object.prototype hasn't been altered WRT empty elements.
elements = initial_object_proto->elements(); elements = initial_object_proto.elements();
if (elements != roots.empty_fixed_array() && if (elements != roots.empty_fixed_array() &&
elements != roots.empty_slow_element_dictionary()) { elements != roots.empty_slow_element_dictionary()) {
DCHECK_EQ(false, cell_reports_intact); DCHECK_EQ(false, cell_reports_intact);
@ -3820,7 +3817,7 @@ bool Isolate::IsNoElementsProtectorIntact(Context context) {
DCHECK(!has_pending_exception()); DCHECK(!has_pending_exception());
// Check that the String.prototype hasn't been altered WRT empty elements. // Check that the String.prototype hasn't been altered WRT empty elements.
elements = initial_string_proto->elements(); elements = initial_string_proto.elements();
if (elements != roots.empty_fixed_array() && if (elements != roots.empty_fixed_array() &&
elements != roots.empty_slow_element_dictionary()) { elements != roots.empty_slow_element_dictionary()) {
DCHECK_EQ(false, cell_reports_intact); DCHECK_EQ(false, cell_reports_intact);
@ -3829,7 +3826,7 @@ bool Isolate::IsNoElementsProtectorIntact(Context context) {
// Check that the String.prototype has the Object.prototype // Check that the String.prototype has the Object.prototype
// as its [[Prototype]] still. // as its [[Prototype]] still.
if (initial_string_proto->map()->prototype() != initial_object_proto) { if (initial_string_proto.map().prototype() != initial_object_proto) {
DCHECK_EQ(false, cell_reports_intact); DCHECK_EQ(false, cell_reports_intact);
return cell_reports_intact; return cell_reports_intact;
} }
@ -3845,10 +3842,10 @@ bool Isolate::IsNoElementsProtectorIntact() {
bool Isolate::IsIsConcatSpreadableLookupChainIntact() { bool Isolate::IsIsConcatSpreadableLookupChainIntact() {
Cell is_concat_spreadable_cell = heap()->is_concat_spreadable_protector(); Cell is_concat_spreadable_cell = heap()->is_concat_spreadable_protector();
bool is_is_concat_spreadable_set = bool is_is_concat_spreadable_set =
Smi::ToInt(is_concat_spreadable_cell->value()) == kProtectorInvalid; Smi::ToInt(is_concat_spreadable_cell.value()) == kProtectorInvalid;
#ifdef DEBUG #ifdef DEBUG
Map root_array_map = Map root_array_map =
raw_native_context()->GetInitialJSArrayMap(GetInitialFastElementsKind()); raw_native_context().GetInitialJSArrayMap(GetInitialFastElementsKind());
if (root_array_map.is_null()) { if (root_array_map.is_null()) {
// Ignore the value of is_concat_spreadable during bootstrap. // Ignore the value of is_concat_spreadable during bootstrap.
return !is_is_concat_spreadable_set; return !is_is_concat_spreadable_set;
@ -3871,13 +3868,13 @@ bool Isolate::IsIsConcatSpreadableLookupChainIntact() {
bool Isolate::IsIsConcatSpreadableLookupChainIntact(JSReceiver receiver) { bool Isolate::IsIsConcatSpreadableLookupChainIntact(JSReceiver receiver) {
if (!IsIsConcatSpreadableLookupChainIntact()) return false; if (!IsIsConcatSpreadableLookupChainIntact()) return false;
return !receiver->HasProxyInPrototype(this); return !receiver.HasProxyInPrototype(this);
} }
bool Isolate::IsPromiseHookProtectorIntact() { bool Isolate::IsPromiseHookProtectorIntact() {
PropertyCell promise_hook_cell = heap()->promise_hook_protector(); PropertyCell promise_hook_cell = heap()->promise_hook_protector();
bool is_promise_hook_protector_intact = bool is_promise_hook_protector_intact =
Smi::ToInt(promise_hook_cell->value()) == kProtectorValid; Smi::ToInt(promise_hook_cell.value()) == kProtectorValid;
DCHECK_IMPLIES(is_promise_hook_protector_intact, DCHECK_IMPLIES(is_promise_hook_protector_intact,
!promise_hook_or_async_event_delegate_); !promise_hook_or_async_event_delegate_);
DCHECK_IMPLIES(is_promise_hook_protector_intact, DCHECK_IMPLIES(is_promise_hook_protector_intact,
@ -3888,21 +3885,21 @@ bool Isolate::IsPromiseHookProtectorIntact() {
bool Isolate::IsPromiseResolveLookupChainIntact() { bool Isolate::IsPromiseResolveLookupChainIntact() {
Cell promise_resolve_cell = heap()->promise_resolve_protector(); Cell promise_resolve_cell = heap()->promise_resolve_protector();
bool is_promise_resolve_protector_intact = bool is_promise_resolve_protector_intact =
Smi::ToInt(promise_resolve_cell->value()) == kProtectorValid; Smi::ToInt(promise_resolve_cell.value()) == kProtectorValid;
return is_promise_resolve_protector_intact; return is_promise_resolve_protector_intact;
} }
bool Isolate::IsPromiseThenLookupChainIntact() { bool Isolate::IsPromiseThenLookupChainIntact() {
PropertyCell promise_then_cell = heap()->promise_then_protector(); PropertyCell promise_then_cell = heap()->promise_then_protector();
bool is_promise_then_protector_intact = bool is_promise_then_protector_intact =
Smi::ToInt(promise_then_cell->value()) == kProtectorValid; Smi::ToInt(promise_then_cell.value()) == kProtectorValid;
return is_promise_then_protector_intact; return is_promise_then_protector_intact;
} }
bool Isolate::IsPromiseThenLookupChainIntact(Handle<JSReceiver> receiver) { bool Isolate::IsPromiseThenLookupChainIntact(Handle<JSReceiver> receiver) {
DisallowHeapAllocation no_gc; DisallowHeapAllocation no_gc;
if (!receiver->IsJSPromise()) return false; if (!receiver->IsJSPromise()) return false;
if (!IsInAnyContext(receiver->map()->prototype(), if (!IsInAnyContext(receiver->map().prototype(),
Context::PROMISE_PROTOTYPE_INDEX)) { Context::PROMISE_PROTOTYPE_INDEX)) {
return false; return false;
} }
@ -3911,7 +3908,7 @@ bool Isolate::IsPromiseThenLookupChainIntact(Handle<JSReceiver> receiver) {
void Isolate::UpdateNoElementsProtectorOnSetElement(Handle<JSObject> object) { void Isolate::UpdateNoElementsProtectorOnSetElement(Handle<JSObject> object) {
DisallowHeapAllocation no_gc; DisallowHeapAllocation no_gc;
if (!object->map()->is_prototype_map()) return; if (!object->map().is_prototype_map()) return;
if (!IsNoElementsProtectorIntact()) return; if (!IsNoElementsProtectorIntact()) return;
if (!IsArrayOrObjectOrStringPrototype(*object)) return; if (!IsArrayOrObjectOrStringPrototype(*object)) return;
PropertyCell::SetValueWithInvalidation( PropertyCell::SetValueWithInvalidation(
@ -3920,7 +3917,7 @@ void Isolate::UpdateNoElementsProtectorOnSetElement(Handle<JSObject> object) {
} }
void Isolate::InvalidateIsConcatSpreadableProtector() { void Isolate::InvalidateIsConcatSpreadableProtector() {
DCHECK(factory()->is_concat_spreadable_protector()->value()->IsSmi()); DCHECK(factory()->is_concat_spreadable_protector()->value().IsSmi());
DCHECK(IsIsConcatSpreadableLookupChainIntact()); DCHECK(IsIsConcatSpreadableLookupChainIntact());
factory()->is_concat_spreadable_protector()->set_value( factory()->is_concat_spreadable_protector()->set_value(
Smi::FromInt(kProtectorInvalid)); Smi::FromInt(kProtectorInvalid));
@ -3928,7 +3925,7 @@ void Isolate::InvalidateIsConcatSpreadableProtector() {
} }
void Isolate::InvalidateArrayConstructorProtector() { void Isolate::InvalidateArrayConstructorProtector() {
DCHECK(factory()->array_constructor_protector()->value()->IsSmi()); DCHECK(factory()->array_constructor_protector()->value().IsSmi());
DCHECK(IsArrayConstructorIntact()); DCHECK(IsArrayConstructorIntact());
factory()->array_constructor_protector()->set_value( factory()->array_constructor_protector()->set_value(
Smi::FromInt(kProtectorInvalid)); Smi::FromInt(kProtectorInvalid));
@ -3936,7 +3933,7 @@ void Isolate::InvalidateArrayConstructorProtector() {
} }
void Isolate::InvalidateArraySpeciesProtector() { void Isolate::InvalidateArraySpeciesProtector() {
DCHECK(factory()->array_species_protector()->value()->IsSmi()); DCHECK(factory()->array_species_protector()->value().IsSmi());
DCHECK(IsArraySpeciesLookupChainIntact()); DCHECK(IsArraySpeciesLookupChainIntact());
PropertyCell::SetValueWithInvalidation( PropertyCell::SetValueWithInvalidation(
this, factory()->array_species_protector(), this, factory()->array_species_protector(),
@ -3945,7 +3942,7 @@ void Isolate::InvalidateArraySpeciesProtector() {
} }
void Isolate::InvalidateTypedArraySpeciesProtector() { void Isolate::InvalidateTypedArraySpeciesProtector() {
DCHECK(factory()->typed_array_species_protector()->value()->IsSmi()); DCHECK(factory()->typed_array_species_protector()->value().IsSmi());
DCHECK(IsTypedArraySpeciesLookupChainIntact()); DCHECK(IsTypedArraySpeciesLookupChainIntact());
PropertyCell::SetValueWithInvalidation( PropertyCell::SetValueWithInvalidation(
this, factory()->typed_array_species_protector(), this, factory()->typed_array_species_protector(),
@ -3954,7 +3951,7 @@ void Isolate::InvalidateTypedArraySpeciesProtector() {
} }
void Isolate::InvalidateRegExpSpeciesProtector() { void Isolate::InvalidateRegExpSpeciesProtector() {
DCHECK(factory()->regexp_species_protector()->value()->IsSmi()); DCHECK(factory()->regexp_species_protector()->value().IsSmi());
DCHECK(IsRegExpSpeciesLookupChainIntact()); DCHECK(IsRegExpSpeciesLookupChainIntact());
PropertyCell::SetValueWithInvalidation( PropertyCell::SetValueWithInvalidation(
this, factory()->regexp_species_protector(), this, factory()->regexp_species_protector(),
@ -3963,7 +3960,7 @@ void Isolate::InvalidateRegExpSpeciesProtector() {
} }
void Isolate::InvalidatePromiseSpeciesProtector() { void Isolate::InvalidatePromiseSpeciesProtector() {
DCHECK(factory()->promise_species_protector()->value()->IsSmi()); DCHECK(factory()->promise_species_protector()->value().IsSmi());
DCHECK(IsPromiseSpeciesLookupChainIntact()); DCHECK(IsPromiseSpeciesLookupChainIntact());
PropertyCell::SetValueWithInvalidation( PropertyCell::SetValueWithInvalidation(
this, factory()->promise_species_protector(), this, factory()->promise_species_protector(),
@ -3972,7 +3969,7 @@ void Isolate::InvalidatePromiseSpeciesProtector() {
} }
void Isolate::InvalidateStringLengthOverflowProtector() { void Isolate::InvalidateStringLengthOverflowProtector() {
DCHECK(factory()->string_length_protector()->value()->IsSmi()); DCHECK(factory()->string_length_protector()->value().IsSmi());
DCHECK(IsStringLengthOverflowIntact()); DCHECK(IsStringLengthOverflowIntact());
factory()->string_length_protector()->set_value( factory()->string_length_protector()->set_value(
Smi::FromInt(kProtectorInvalid)); Smi::FromInt(kProtectorInvalid));
@ -3980,7 +3977,7 @@ void Isolate::InvalidateStringLengthOverflowProtector() {
} }
void Isolate::InvalidateArrayIteratorProtector() { void Isolate::InvalidateArrayIteratorProtector() {
DCHECK(factory()->array_iterator_protector()->value()->IsSmi()); DCHECK(factory()->array_iterator_protector()->value().IsSmi());
DCHECK(IsArrayIteratorLookupChainIntact()); DCHECK(IsArrayIteratorLookupChainIntact());
PropertyCell::SetValueWithInvalidation( PropertyCell::SetValueWithInvalidation(
this, factory()->array_iterator_protector(), this, factory()->array_iterator_protector(),
@ -3989,7 +3986,7 @@ void Isolate::InvalidateArrayIteratorProtector() {
} }
void Isolate::InvalidateMapIteratorProtector() { void Isolate::InvalidateMapIteratorProtector() {
DCHECK(factory()->map_iterator_protector()->value()->IsSmi()); DCHECK(factory()->map_iterator_protector()->value().IsSmi());
DCHECK(IsMapIteratorLookupChainIntact()); DCHECK(IsMapIteratorLookupChainIntact());
PropertyCell::SetValueWithInvalidation( PropertyCell::SetValueWithInvalidation(
this, factory()->map_iterator_protector(), this, factory()->map_iterator_protector(),
@ -3998,7 +3995,7 @@ void Isolate::InvalidateMapIteratorProtector() {
} }
void Isolate::InvalidateSetIteratorProtector() { void Isolate::InvalidateSetIteratorProtector() {
DCHECK(factory()->set_iterator_protector()->value()->IsSmi()); DCHECK(factory()->set_iterator_protector()->value().IsSmi());
DCHECK(IsSetIteratorLookupChainIntact()); DCHECK(IsSetIteratorLookupChainIntact());
PropertyCell::SetValueWithInvalidation( PropertyCell::SetValueWithInvalidation(
this, factory()->set_iterator_protector(), this, factory()->set_iterator_protector(),
@ -4007,7 +4004,7 @@ void Isolate::InvalidateSetIteratorProtector() {
} }
void Isolate::InvalidateStringIteratorProtector() { void Isolate::InvalidateStringIteratorProtector() {
DCHECK(factory()->string_iterator_protector()->value()->IsSmi()); DCHECK(factory()->string_iterator_protector()->value().IsSmi());
DCHECK(IsStringIteratorLookupChainIntact()); DCHECK(IsStringIteratorLookupChainIntact());
PropertyCell::SetValueWithInvalidation( PropertyCell::SetValueWithInvalidation(
this, factory()->string_iterator_protector(), this, factory()->string_iterator_protector(),
@ -4016,7 +4013,7 @@ void Isolate::InvalidateStringIteratorProtector() {
} }
void Isolate::InvalidateArrayBufferDetachingProtector() { void Isolate::InvalidateArrayBufferDetachingProtector() {
DCHECK(factory()->array_buffer_detaching_protector()->value()->IsSmi()); DCHECK(factory()->array_buffer_detaching_protector()->value().IsSmi());
DCHECK(IsArrayBufferDetachingIntact()); DCHECK(IsArrayBufferDetachingIntact());
PropertyCell::SetValueWithInvalidation( PropertyCell::SetValueWithInvalidation(
this, factory()->array_buffer_detaching_protector(), this, factory()->array_buffer_detaching_protector(),
@ -4025,7 +4022,7 @@ void Isolate::InvalidateArrayBufferDetachingProtector() {
} }
void Isolate::InvalidatePromiseHookProtector() { void Isolate::InvalidatePromiseHookProtector() {
DCHECK(factory()->promise_hook_protector()->value()->IsSmi()); DCHECK(factory()->promise_hook_protector()->value().IsSmi());
DCHECK(IsPromiseHookProtectorIntact()); DCHECK(IsPromiseHookProtectorIntact());
PropertyCell::SetValueWithInvalidation( PropertyCell::SetValueWithInvalidation(
this, factory()->promise_hook_protector(), this, factory()->promise_hook_protector(),
@ -4034,7 +4031,7 @@ void Isolate::InvalidatePromiseHookProtector() {
} }
void Isolate::InvalidatePromiseResolveProtector() { void Isolate::InvalidatePromiseResolveProtector() {
DCHECK(factory()->promise_resolve_protector()->value()->IsSmi()); DCHECK(factory()->promise_resolve_protector()->value().IsSmi());
DCHECK(IsPromiseResolveLookupChainIntact()); DCHECK(IsPromiseResolveLookupChainIntact());
factory()->promise_resolve_protector()->set_value( factory()->promise_resolve_protector()->set_value(
Smi::FromInt(kProtectorInvalid)); Smi::FromInt(kProtectorInvalid));
@ -4042,7 +4039,7 @@ void Isolate::InvalidatePromiseResolveProtector() {
} }
void Isolate::InvalidatePromiseThenProtector() { void Isolate::InvalidatePromiseThenProtector() {
DCHECK(factory()->promise_then_protector()->value()->IsSmi()); DCHECK(factory()->promise_then_protector()->value().IsSmi());
DCHECK(IsPromiseThenLookupChainIntact()); DCHECK(IsPromiseThenLookupChainIntact());
PropertyCell::SetValueWithInvalidation( PropertyCell::SetValueWithInvalidation(
this, factory()->promise_then_protector(), this, factory()->promise_then_protector(),

View File

@ -118,7 +118,7 @@ void MessageHandler::ReportMessage(Isolate* isolate, const MessageLocation* loc,
isolate->set_external_caught_exception(false); isolate->set_external_caught_exception(false);
// Turn the exception on the message into a string if it is an object. // Turn the exception on the message into a string if it is an object.
if (message->argument()->IsJSObject()) { if (message->argument().IsJSObject()) {
HandleScope scope(isolate); HandleScope scope(isolate);
Handle<Object> argument(message->argument(), isolate); Handle<Object> argument(message->argument(), isolate);
@ -169,17 +169,17 @@ void MessageHandler::ReportMessageNoExceptions(
} else { } else {
for (int i = 0; i < global_length; i++) { for (int i = 0; i < global_length; i++) {
HandleScope scope(isolate); HandleScope scope(isolate);
if (global_listeners->get(i)->IsUndefined(isolate)) continue; if (global_listeners->get(i).IsUndefined(isolate)) continue;
FixedArray listener = FixedArray::cast(global_listeners->get(i)); FixedArray listener = FixedArray::cast(global_listeners->get(i));
Foreign callback_obj = Foreign::cast(listener->get(0)); Foreign callback_obj = Foreign::cast(listener.get(0));
int32_t message_levels = int32_t message_levels =
static_cast<int32_t>(Smi::ToInt(listener->get(2))); static_cast<int32_t>(Smi::ToInt(listener.get(2)));
if (!(message_levels & error_level)) { if (!(message_levels & error_level)) {
continue; continue;
} }
v8::MessageCallback callback = v8::MessageCallback callback =
FUNCTION_CAST<v8::MessageCallback>(callback_obj->foreign_address()); FUNCTION_CAST<v8::MessageCallback>(callback_obj.foreign_address());
Handle<Object> callback_data(listener->get(1), isolate); Handle<Object> callback_data(listener.get(1), isolate);
{ {
RuntimeCallTimerScope timer( RuntimeCallTimerScope timer(
isolate, RuntimeCallCounterId::kMessageListenerCallback); isolate, RuntimeCallCounterId::kMessageListenerCallback);
@ -218,7 +218,7 @@ Object EvalFromFunctionName(Isolate* isolate, Handle<Script> script) {
Handle<SharedFunctionInfo> shared(script->eval_from_shared(), isolate); Handle<SharedFunctionInfo> shared(script->eval_from_shared(), isolate);
// Find the name of the function calling eval. // Find the name of the function calling eval.
if (shared->Name()->BooleanValue(isolate)) { if (shared->Name().BooleanValue(isolate)) {
return shared->Name(); return shared->Name();
} }
@ -250,7 +250,7 @@ MaybeHandle<String> FormatEvalOrigin(Isolate* isolate, Handle<Script> script) {
if (script->has_eval_from_shared()) { if (script->has_eval_from_shared()) {
Handle<SharedFunctionInfo> eval_from_shared(script->eval_from_shared(), Handle<SharedFunctionInfo> eval_from_shared(script->eval_from_shared(),
isolate); isolate);
if (eval_from_shared->script()->IsScript()) { if (eval_from_shared->script().IsScript()) {
Handle<Script> eval_from_script = Handle<Script> eval_from_script =
handle(Script::cast(eval_from_shared->script()), isolate); handle(Script::cast(eval_from_shared->script()), isolate);
builder.AppendCString(" ("); builder.AppendCString(" (");
@ -266,7 +266,7 @@ MaybeHandle<String> FormatEvalOrigin(Isolate* isolate, Handle<Script> script) {
Script::COMPILATION_TYPE_EVAL); Script::COMPILATION_TYPE_EVAL);
// eval script originated from "real" source. // eval script originated from "real" source.
Handle<Object> name_obj = handle(eval_from_script->name(), isolate); Handle<Object> name_obj = handle(eval_from_script->name(), isolate);
if (eval_from_script->name()->IsString()) { if (eval_from_script->name().IsString()) {
builder.AppendString(Handle<String>::cast(name_obj)); builder.AppendString(Handle<String>::cast(name_obj));
Script::PositionInfo info; Script::PositionInfo info;
@ -287,7 +287,7 @@ MaybeHandle<String> FormatEvalOrigin(Isolate* isolate, Handle<Script> script) {
builder.AppendString(str); builder.AppendString(str);
} }
} else { } else {
DCHECK(!eval_from_script->name()->IsString()); DCHECK(!eval_from_script->name().IsString());
builder.AppendCString("unknown source"); builder.AppendCString("unknown source");
} }
} }
@ -330,9 +330,9 @@ void JSStackFrame::FromFrameArray(Isolate* isolate, Handle<FrameArray> array,
receiver_ = handle(array->Receiver(frame_ix), isolate); receiver_ = handle(array->Receiver(frame_ix), isolate);
function_ = handle(array->Function(frame_ix), isolate); function_ = handle(array->Function(frame_ix), isolate);
code_ = handle(array->Code(frame_ix), isolate); code_ = handle(array->Code(frame_ix), isolate);
offset_ = array->Offset(frame_ix)->value(); offset_ = array->Offset(frame_ix).value();
const int flags = array->Flags(frame_ix)->value(); const int flags = array->Flags(frame_ix).value();
is_constructor_ = (flags & FrameArray::kIsConstructor) != 0; is_constructor_ = (flags & FrameArray::kIsConstructor) != 0;
is_strict_ = (flags & FrameArray::kIsStrict) != 0; is_strict_ = (flags & FrameArray::kIsStrict) != 0;
is_async_ = (flags & FrameArray::kIsAsync) != 0; is_async_ = (flags & FrameArray::kIsAsync) != 0;
@ -392,7 +392,7 @@ bool CheckMethodName(Isolate* isolate, Handle<JSReceiver> receiver,
Handle<Object> ScriptNameOrSourceUrl(Handle<Script> script, Isolate* isolate) { Handle<Object> ScriptNameOrSourceUrl(Handle<Script> script, Isolate* isolate) {
Object name_or_url = script->source_url(); Object name_or_url = script->source_url();
if (!name_or_url->IsString()) name_or_url = script->name(); if (!name_or_url.IsString()) name_or_url = script->name();
return handle(name_or_url, isolate); return handle(name_or_url, isolate);
} }
@ -416,7 +416,7 @@ Handle<Object> JSStackFrame::GetMethodName() {
return isolate_->factory()->null_value(); return isolate_->factory()->null_value();
} }
Handle<String> name(function_->shared()->Name(), isolate_); Handle<String> name(function_->shared().Name(), isolate_);
name = String::Flatten(isolate_, name); name = String::Flatten(isolate_, name);
// The static initializer function is not a method, so don't add a // The static initializer function is not a method, so don't add a
@ -448,7 +448,7 @@ Handle<Object> JSStackFrame::GetMethodName() {
KeyAccumulator::GetOwnEnumPropertyKeys(isolate_, current_obj); KeyAccumulator::GetOwnEnumPropertyKeys(isolate_, current_obj);
for (int i = 0; i < keys->length(); i++) { for (int i = 0; i < keys->length(); i++) {
HandleScope inner_scope(isolate_); HandleScope inner_scope(isolate_);
if (!keys->get(i)->IsName()) continue; if (!keys->get(i).IsName()) continue;
Handle<Name> name_key(Name::cast(keys->get(i)), isolate_); Handle<Name> name_key(Name::cast(keys->get(i)), isolate_);
if (!CheckMethodName(isolate_, current_obj, name_key, function_, if (!CheckMethodName(isolate_, current_obj, name_key, function_,
LookupIterator::OWN_SKIP_INTERCEPTOR)) LookupIterator::OWN_SKIP_INTERCEPTOR))
@ -513,7 +513,7 @@ bool JSStackFrame::IsToplevel() {
namespace { namespace {
bool IsNonEmptyString(Handle<Object> object) { bool IsNonEmptyString(Handle<Object> object) {
return (object->IsString() && String::cast(*object)->length() > 0); return (object->IsString() && String::cast(*object).length() > 0);
} }
void AppendFileLocation(Isolate* isolate, StackFrameBase* call_site, void AppendFileLocation(Isolate* isolate, StackFrameBase* call_site,
@ -688,11 +688,11 @@ int JSStackFrame::GetPosition() const {
} }
bool JSStackFrame::HasScript() const { bool JSStackFrame::HasScript() const {
return function_->shared()->script()->IsScript(); return function_->shared().script().IsScript();
} }
Handle<Script> JSStackFrame::GetScript() const { Handle<Script> JSStackFrame::GetScript() const {
return handle(Script::cast(function_->shared()->script()), isolate_); return handle(Script::cast(function_->shared().script()), isolate_);
} }
void WasmStackFrame::FromFrameArray(Isolate* isolate, Handle<FrameArray> array, void WasmStackFrame::FromFrameArray(Isolate* isolate, Handle<FrameArray> array,
@ -704,16 +704,16 @@ void WasmStackFrame::FromFrameArray(Isolate* isolate, Handle<FrameArray> array,
array->IsAsmJsWasmFrame(frame_ix)); array->IsAsmJsWasmFrame(frame_ix));
isolate_ = isolate; isolate_ = isolate;
wasm_instance_ = handle(array->WasmInstance(frame_ix), isolate); wasm_instance_ = handle(array->WasmInstance(frame_ix), isolate);
wasm_func_index_ = array->WasmFunctionIndex(frame_ix)->value(); wasm_func_index_ = array->WasmFunctionIndex(frame_ix).value();
if (array->IsWasmInterpretedFrame(frame_ix)) { if (array->IsWasmInterpretedFrame(frame_ix)) {
code_ = nullptr; code_ = nullptr;
} else { } else {
// The {WasmCode*} is held alive by the {GlobalWasmCodeRef}. // The {WasmCode*} is held alive by the {GlobalWasmCodeRef}.
auto global_wasm_code_ref = auto global_wasm_code_ref =
Managed<wasm::GlobalWasmCodeRef>::cast(array->WasmCodeObject(frame_ix)); Managed<wasm::GlobalWasmCodeRef>::cast(array->WasmCodeObject(frame_ix));
code_ = global_wasm_code_ref->get()->code(); code_ = global_wasm_code_ref.get()->code();
} }
offset_ = array->Offset(frame_ix)->value(); offset_ = array->Offset(frame_ix).value();
} }
Handle<Object> WasmStackFrame::GetReceiver() const { return wasm_instance_; } Handle<Object> WasmStackFrame::GetReceiver() const { return wasm_instance_; }
@ -783,7 +783,7 @@ Handle<Object> WasmStackFrame::Null() const {
bool WasmStackFrame::HasScript() const { return true; } bool WasmStackFrame::HasScript() const { return true; }
Handle<Script> WasmStackFrame::GetScript() const { Handle<Script> WasmStackFrame::GetScript() const {
return handle(wasm_instance_->module_object()->script(), isolate_); return handle(wasm_instance_->module_object().script(), isolate_);
} }
void AsmJsWasmStackFrame::FromFrameArray(Isolate* isolate, void AsmJsWasmStackFrame::FromFrameArray(Isolate* isolate,
@ -792,7 +792,7 @@ void AsmJsWasmStackFrame::FromFrameArray(Isolate* isolate,
DCHECK(array->IsAsmJsWasmFrame(frame_ix)); DCHECK(array->IsAsmJsWasmFrame(frame_ix));
WasmStackFrame::FromFrameArray(isolate, array, frame_ix); WasmStackFrame::FromFrameArray(isolate, array, frame_ix);
is_at_number_conversion_ = is_at_number_conversion_ =
array->Flags(frame_ix)->value() & FrameArray::kAsmJsAtNumberConversion; array->Flags(frame_ix).value() & FrameArray::kAsmJsAtNumberConversion;
} }
Handle<Object> AsmJsWasmStackFrame::GetReceiver() const { Handle<Object> AsmJsWasmStackFrame::GetReceiver() const {
@ -805,13 +805,13 @@ Handle<Object> AsmJsWasmStackFrame::GetFunction() const {
} }
Handle<Object> AsmJsWasmStackFrame::GetFileName() { Handle<Object> AsmJsWasmStackFrame::GetFileName() {
Handle<Script> script(wasm_instance_->module_object()->script(), isolate_); Handle<Script> script(wasm_instance_->module_object().script(), isolate_);
DCHECK(script->IsUserJavaScript()); DCHECK(script->IsUserJavaScript());
return handle(script->name(), isolate_); return handle(script->name(), isolate_);
} }
Handle<Object> AsmJsWasmStackFrame::GetScriptNameOrSourceUrl() { Handle<Object> AsmJsWasmStackFrame::GetScriptNameOrSourceUrl() {
Handle<Script> script(wasm_instance_->module_object()->script(), isolate_); Handle<Script> script(wasm_instance_->module_object().script(), isolate_);
DCHECK_EQ(Script::TYPE_NORMAL, script->type()); DCHECK_EQ(Script::TYPE_NORMAL, script->type());
return ScriptNameOrSourceUrl(script, isolate_); return ScriptNameOrSourceUrl(script, isolate_);
} }
@ -831,14 +831,14 @@ int AsmJsWasmStackFrame::GetPosition() const {
int AsmJsWasmStackFrame::GetLineNumber() { int AsmJsWasmStackFrame::GetLineNumber() {
DCHECK_LE(0, GetPosition()); DCHECK_LE(0, GetPosition());
Handle<Script> script(wasm_instance_->module_object()->script(), isolate_); Handle<Script> script(wasm_instance_->module_object().script(), isolate_);
DCHECK(script->IsUserJavaScript()); DCHECK(script->IsUserJavaScript());
return Script::GetLineNumber(script, GetPosition()) + 1; return Script::GetLineNumber(script, GetPosition()) + 1;
} }
int AsmJsWasmStackFrame::GetColumnNumber() { int AsmJsWasmStackFrame::GetColumnNumber() {
DCHECK_LE(0, GetPosition()); DCHECK_LE(0, GetPosition());
Handle<Script> script(wasm_instance_->module_object()->script(), isolate_); Handle<Script> script(wasm_instance_->module_object().script(), isolate_);
DCHECK(script->IsUserJavaScript()); DCHECK(script->IsUserJavaScript());
return Script::GetColumnNumber(script, GetPosition()) + 1; return Script::GetColumnNumber(script, GetPosition()) + 1;
} }
@ -873,7 +873,7 @@ void FrameArrayIterator::Advance() { frame_ix_++; }
StackFrameBase* FrameArrayIterator::Frame() { StackFrameBase* FrameArrayIterator::Frame() {
DCHECK(HasFrame()); DCHECK(HasFrame());
const int flags = array_->Flags(frame_ix_)->value(); const int flags = array_->Flags(frame_ix_).value();
int flag_mask = FrameArray::kIsWasmFrame | int flag_mask = FrameArray::kIsWasmFrame |
FrameArray::kIsWasmInterpretedFrame | FrameArray::kIsWasmInterpretedFrame |
FrameArray::kIsAsmJsWasmFrame; FrameArray::kIsAsmJsWasmFrame;

View File

@ -71,7 +71,7 @@ static void TraceRecompile(JSFunction function, const char* reason,
const char* type) { const char* type) {
if (FLAG_trace_opt) { if (FLAG_trace_opt) {
PrintF("[marking "); PrintF("[marking ");
function->ShortPrint(); function.ShortPrint();
PrintF(" for %s recompilation, reason: %s", type, reason); PrintF(" for %s recompilation, reason: %s", type, reason);
PrintF("]\n"); PrintF("]\n");
} }
@ -80,41 +80,41 @@ static void TraceRecompile(JSFunction function, const char* reason,
void RuntimeProfiler::Optimize(JSFunction function, OptimizationReason reason) { void RuntimeProfiler::Optimize(JSFunction function, OptimizationReason reason) {
DCHECK_NE(reason, OptimizationReason::kDoNotOptimize); DCHECK_NE(reason, OptimizationReason::kDoNotOptimize);
TraceRecompile(function, OptimizationReasonToString(reason), "optimized"); TraceRecompile(function, OptimizationReasonToString(reason), "optimized");
function->MarkForOptimization(ConcurrencyMode::kConcurrent); function.MarkForOptimization(ConcurrencyMode::kConcurrent);
} }
void RuntimeProfiler::AttemptOnStackReplacement(InterpretedFrame* frame, void RuntimeProfiler::AttemptOnStackReplacement(InterpretedFrame* frame,
int loop_nesting_levels) { int loop_nesting_levels) {
JSFunction function = frame->function(); JSFunction function = frame->function();
SharedFunctionInfo shared = function->shared(); SharedFunctionInfo shared = function.shared();
if (!FLAG_use_osr || !shared->IsUserJavaScript()) { if (!FLAG_use_osr || !shared.IsUserJavaScript()) {
return; return;
} }
// If the code is not optimizable, don't try OSR. // If the code is not optimizable, don't try OSR.
if (shared->optimization_disabled()) return; if (shared.optimization_disabled()) return;
// We're using on-stack replacement: Store new loop nesting level in // We're using on-stack replacement: Store new loop nesting level in
// BytecodeArray header so that certain back edges in any interpreter frame // BytecodeArray header so that certain back edges in any interpreter frame
// for this bytecode will trigger on-stack replacement for that frame. // for this bytecode will trigger on-stack replacement for that frame.
if (FLAG_trace_osr) { if (FLAG_trace_osr) {
PrintF("[OSR - arming back edges in "); PrintF("[OSR - arming back edges in ");
function->PrintName(); function.PrintName();
PrintF("]\n"); PrintF("]\n");
} }
DCHECK_EQ(StackFrame::INTERPRETED, frame->type()); DCHECK_EQ(StackFrame::INTERPRETED, frame->type());
int level = frame->GetBytecodeArray()->osr_loop_nesting_level(); int level = frame->GetBytecodeArray().osr_loop_nesting_level();
frame->GetBytecodeArray()->set_osr_loop_nesting_level( frame->GetBytecodeArray().set_osr_loop_nesting_level(
Min(level + loop_nesting_levels, AbstractCode::kMaxLoopNestingMarker)); Min(level + loop_nesting_levels, AbstractCode::kMaxLoopNestingMarker));
} }
void RuntimeProfiler::MaybeOptimize(JSFunction function, void RuntimeProfiler::MaybeOptimize(JSFunction function,
InterpretedFrame* frame) { InterpretedFrame* frame) {
if (function->IsInOptimizationQueue()) { if (function.IsInOptimizationQueue()) {
if (FLAG_trace_opt_verbose) { if (FLAG_trace_opt_verbose) {
PrintF("[function "); PrintF("[function ");
function->PrintName(); function.PrintName();
PrintF(" is already in optimization queue]\n"); PrintF(" is already in optimization queue]\n");
} }
return; return;
@ -127,10 +127,10 @@ void RuntimeProfiler::MaybeOptimize(JSFunction function,
return; return;
} }
if (function->shared()->optimization_disabled()) return; if (function.shared().optimization_disabled()) return;
OptimizationReason reason = OptimizationReason reason =
ShouldOptimize(function, function->shared()->GetBytecodeArray()); ShouldOptimize(function, function.shared().GetBytecodeArray());
if (reason != OptimizationReason::kDoNotOptimize) { if (reason != OptimizationReason::kDoNotOptimize) {
Optimize(function, reason); Optimize(function, reason);
@ -138,19 +138,19 @@ void RuntimeProfiler::MaybeOptimize(JSFunction function,
} }
bool RuntimeProfiler::MaybeOSR(JSFunction function, InterpretedFrame* frame) { bool RuntimeProfiler::MaybeOSR(JSFunction function, InterpretedFrame* frame) {
int ticks = function->feedback_vector()->profiler_ticks(); int ticks = function.feedback_vector().profiler_ticks();
// TODO(rmcilroy): Also ensure we only OSR top-level code if it is smaller // TODO(rmcilroy): Also ensure we only OSR top-level code if it is smaller
// than kMaxToplevelSourceSize. // than kMaxToplevelSourceSize.
if (function->IsMarkedForOptimization() || if (function.IsMarkedForOptimization() ||
function->IsMarkedForConcurrentOptimization() || function.IsMarkedForConcurrentOptimization() ||
function->HasOptimizedCode()) { function.HasOptimizedCode()) {
// Attempt OSR if we are still running interpreted code even though the // Attempt OSR if we are still running interpreted code even though the
// the function has long been marked or even already been optimized. // the function has long been marked or even already been optimized.
int64_t allowance = int64_t allowance =
kOSRBytecodeSizeAllowanceBase + kOSRBytecodeSizeAllowanceBase +
static_cast<int64_t>(ticks) * kOSRBytecodeSizeAllowancePerTick; static_cast<int64_t>(ticks) * kOSRBytecodeSizeAllowancePerTick;
if (function->shared()->GetBytecodeArray()->length() <= allowance) { if (function.shared().GetBytecodeArray().length() <= allowance) {
AttemptOnStackReplacement(frame); AttemptOnStackReplacement(frame);
} }
return true; return true;
@ -160,27 +160,27 @@ bool RuntimeProfiler::MaybeOSR(JSFunction function, InterpretedFrame* frame) {
OptimizationReason RuntimeProfiler::ShouldOptimize(JSFunction function, OptimizationReason RuntimeProfiler::ShouldOptimize(JSFunction function,
BytecodeArray bytecode) { BytecodeArray bytecode) {
int ticks = function->feedback_vector()->profiler_ticks(); int ticks = function.feedback_vector().profiler_ticks();
int ticks_for_optimization = int ticks_for_optimization =
kProfilerTicksBeforeOptimization + kProfilerTicksBeforeOptimization +
(bytecode->length() / kBytecodeSizeAllowancePerTick); (bytecode.length() / kBytecodeSizeAllowancePerTick);
if (ticks >= ticks_for_optimization) { if (ticks >= ticks_for_optimization) {
return OptimizationReason::kHotAndStable; return OptimizationReason::kHotAndStable;
} else if (!any_ic_changed_ && } else if (!any_ic_changed_ &&
bytecode->length() < kMaxBytecodeSizeForEarlyOpt) { bytecode.length() < kMaxBytecodeSizeForEarlyOpt) {
// If no IC was patched since the last tick and this function is very // If no IC was patched since the last tick and this function is very
// small, optimistically optimize it now. // small, optimistically optimize it now.
return OptimizationReason::kSmallFunction; return OptimizationReason::kSmallFunction;
} else if (FLAG_trace_opt_verbose) { } else if (FLAG_trace_opt_verbose) {
PrintF("[not yet optimizing "); PrintF("[not yet optimizing ");
function->PrintName(); function.PrintName();
PrintF(", not enough ticks: %d/%d and ", ticks, PrintF(", not enough ticks: %d/%d and ", ticks,
kProfilerTicksBeforeOptimization); kProfilerTicksBeforeOptimization);
if (any_ic_changed_) { if (any_ic_changed_) {
PrintF("ICs changed]\n"); PrintF("ICs changed]\n");
} else { } else {
PrintF(" too large for small function optimization: %d/%d]\n", PrintF(" too large for small function optimization: %d/%d]\n",
bytecode->length(), kMaxBytecodeSizeForEarlyOpt); bytecode.length(), kMaxBytecodeSizeForEarlyOpt);
} }
} }
return OptimizationReason::kDoNotOptimize; return OptimizationReason::kDoNotOptimize;
@ -206,18 +206,18 @@ void RuntimeProfiler::MarkCandidatesForOptimization() {
if (!frame->is_interpreted()) continue; if (!frame->is_interpreted()) continue;
JSFunction function = frame->function(); JSFunction function = frame->function();
DCHECK(function->shared()->is_compiled()); DCHECK(function.shared().is_compiled());
if (!function->shared()->IsInterpreted()) continue; if (!function.shared().IsInterpreted()) continue;
if (!function->has_feedback_vector()) continue; if (!function.has_feedback_vector()) continue;
MaybeOptimize(function, InterpretedFrame::cast(frame)); MaybeOptimize(function, InterpretedFrame::cast(frame));
// TODO(leszeks): Move this increment to before the maybe optimize checks, // TODO(leszeks): Move this increment to before the maybe optimize checks,
// and update the tests to assume the increment has already happened. // and update the tests to assume the increment has already happened.
int ticks = function->feedback_vector()->profiler_ticks(); int ticks = function.feedback_vector().profiler_ticks();
if (ticks < Smi::kMaxValue) { if (ticks < Smi::kMaxValue) {
function->feedback_vector()->set_profiler_ticks(ticks + 1); function.feedback_vector().set_profiler_ticks(ticks + 1);
} }
} }
any_ic_changed_ = false; any_ic_changed_ = false;

View File

@ -109,7 +109,7 @@ class GeneratedCode {
} }
static GeneratedCode FromCode(Code code) { static GeneratedCode FromCode(Code code) {
return FromAddress(code->GetIsolate(), code->entry()); return FromAddress(code.GetIsolate(), code.entry());
} }
#ifdef USE_SIMULATOR #ifdef USE_SIMULATOR

View File

@ -129,16 +129,16 @@ void StatisticsExtension::GetCounters(
int source_position_table_total = 0; int source_position_table_total = 0;
for (HeapObject obj = iterator.next(); !obj.is_null(); for (HeapObject obj = iterator.next(); !obj.is_null();
obj = iterator.next()) { obj = iterator.next()) {
if (obj->IsCode()) { if (obj.IsCode()) {
Code code = Code::cast(obj); Code code = Code::cast(obj);
reloc_info_total += code->relocation_info()->Size(); reloc_info_total += code.relocation_info().Size();
ByteArray source_position_table = code->SourcePositionTable(); ByteArray source_position_table = code.SourcePositionTable();
if (source_position_table->length() > 0) { if (source_position_table.length() > 0) {
source_position_table_total += code->SourcePositionTable()->Size(); source_position_table_total += code.SourcePositionTable().Size();
} }
} else if (obj->IsBytecodeArray()) { } else if (obj.IsBytecodeArray()) {
source_position_table_total += source_position_table_total +=
BytecodeArray::cast(obj)->SourcePositionTable()->Size(); BytecodeArray::cast(obj).SourcePositionTable().Size();
} }
} }

View File

@ -639,7 +639,7 @@ FUNCTION_REFERENCE(orderedhashmap_gethash_raw, OrderedHashMap::GetHash)
Address GetOrCreateHash(Isolate* isolate, Address raw_key) { Address GetOrCreateHash(Isolate* isolate, Address raw_key) {
DisallowHeapAllocation no_gc; DisallowHeapAllocation no_gc;
return Object(raw_key)->GetOrCreateHash(isolate).ptr(); return Object(raw_key).GetOrCreateHash(isolate).ptr();
} }
FUNCTION_REFERENCE(get_or_create_hash_raw, GetOrCreateHash) FUNCTION_REFERENCE(get_or_create_hash_raw, GetOrCreateHash)

Some files were not shown because too many files have changed in this diff Show More