Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(245)

Unified Diff: src/objects.cc

Issue 950283002: Move Maps' back pointers from "transitions" to "constructor" field (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: fix stupidity on arm64 Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/objects.h ('k') | src/objects-inl.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/objects.cc
diff --git a/src/objects.cc b/src/objects.cc
index a4bcc7986b2accc4cd575ba4886e733a260b7fad..bf657a2254be64bd731ff861ab85d546758d91da 100644
--- a/src/objects.cc
+++ b/src/objects.cc
@@ -219,7 +219,7 @@ bool FunctionTemplateInfo::IsTemplateFor(Map* map) {
// There is a constraint on the object; check.
if (!map->IsJSObjectMap()) return false;
// Fetch the constructor function of the object.
- Object* cons_obj = map->constructor();
+ Object* cons_obj = map->GetConstructor();
if (!cons_obj->IsJSFunction()) return false;
JSFunction* fun = JSFunction::cast(cons_obj);
// Iterate through the chain of inheriting function templates to
@@ -1208,7 +1208,7 @@ void JSObject::JSObjectShortPrint(StringStream* accumulator) {
default: {
Map* map_of_this = map();
Heap* heap = GetHeap();
- Object* constructor = map_of_this->constructor();
+ Object* constructor = map_of_this->GetConstructor();
bool printed = false;
if (constructor->IsHeapObject() &&
!heap->Contains(HeapObject::cast(constructor))) {
@@ -1671,8 +1671,9 @@ String* JSReceiver::class_name() {
if (IsJSFunction() || IsJSFunctionProxy()) {
return GetHeap()->Function_string();
}
- if (map()->constructor()->IsJSFunction()) {
- JSFunction* constructor = JSFunction::cast(map()->constructor());
+ Object* maybe_constructor = map()->GetConstructor();
+ if (maybe_constructor->IsJSFunction()) {
+ JSFunction* constructor = JSFunction::cast(maybe_constructor);
return String::cast(constructor->shared()->instance_class_name());
}
// If the constructor is not present, return "Object".
@@ -1681,8 +1682,9 @@ String* JSReceiver::class_name() {
String* Map::constructor_name() {
- if (constructor()->IsJSFunction()) {
- JSFunction* constructor = JSFunction::cast(this->constructor());
+ Object* maybe_constructor = GetConstructor();
+ if (maybe_constructor->IsJSFunction()) {
+ JSFunction* constructor = JSFunction::cast(maybe_constructor);
String* name = String::cast(constructor->shared()->name());
if (name->length() > 0) return name;
String* inferred_name = constructor->shared()->inferred_name();
@@ -1784,7 +1786,7 @@ void JSObject::AddSlowProperty(Handle<JSObject> object,
Context* JSObject::GetCreationContext() {
- Object* constructor = this->map()->constructor();
+ Object* constructor = this->map()->GetConstructor();
JSFunction* function;
if (!constructor->IsJSFunction()) {
// Functions have null as a constructor,
@@ -5445,7 +5447,7 @@ bool JSObject::ReferencesObject(Object* obj) {
DisallowHeapAllocation no_allocation;
// Is the object the constructor for this object?
- if (map_of_this->constructor() == obj) {
+ if (map_of_this->GetConstructor() == obj) {
return true;
}
@@ -5509,7 +5511,7 @@ bool JSObject::ReferencesObject(Object* obj) {
Map* arguments_map =
heap->isolate()->context()->native_context()->sloppy_arguments_map();
JSFunction* arguments_function =
- JSFunction::cast(arguments_map->constructor());
+ JSFunction::cast(arguments_map->GetConstructor());
// Get the context and don't check if it is the native context.
JSFunction* f = JSFunction::cast(this);
@@ -5524,7 +5526,7 @@ bool JSObject::ReferencesObject(Object* obj) {
if (context->get(i)->IsJSObject()) {
JSObject* ctxobj = JSObject::cast(context->get(i));
// If it is an arguments array check the content.
- if (ctxobj->map()->constructor() == arguments_function) {
+ if (ctxobj->map()->GetConstructor() == arguments_function) {
if (ctxobj->ReferencesObject(obj)) {
return true;
}
@@ -6248,7 +6250,7 @@ MaybeHandle<FixedArray> JSReceiver::GetKeys(Handle<JSReceiver> object,
Isolate* isolate = object->GetIsolate();
Handle<FixedArray> content = isolate->factory()->empty_fixed_array();
Handle<JSFunction> arguments_function(
- JSFunction::cast(isolate->sloppy_arguments_map()->constructor()));
+ JSFunction::cast(isolate->sloppy_arguments_map()->GetConstructor()));
// Only collect keys if access is permitted.
for (PrototypeIterator iter(isolate, object,
@@ -6321,11 +6323,9 @@ MaybeHandle<FixedArray> JSReceiver::GetKeys(Handle<JSReceiver> object,
// array or dictionary. So the fast inline test for whether to
// use the cache says yes, so we should not create a cache.
bool cache_enum_keys =
- ((current->map()->constructor() != *arguments_function) &&
- !current->IsJSValue() &&
- !current->IsAccessCheckNeeded() &&
- !current->HasNamedInterceptor() &&
- !current->HasIndexedInterceptor());
+ ((current->map()->GetConstructor() != *arguments_function) &&
+ !current->IsJSValue() && !current->IsAccessCheckNeeded() &&
+ !current->HasNamedInterceptor() && !current->HasIndexedInterceptor());
// Compute the property keys and cache them if possible.
ASSIGN_RETURN_ON_EXCEPTION(
isolate, content,
@@ -6841,7 +6841,7 @@ Handle<Map> Map::RawCopy(Handle<Map> map, int instance_size) {
Handle<Map> result = map->GetIsolate()->factory()->NewMap(
map->instance_type(), instance_size);
result->SetPrototype(handle(map->prototype(), map->GetIsolate()));
- result->set_constructor(map->constructor());
+ result->set_constructor_or_backpointer(map->GetConstructor());
result->set_bit_field(map->bit_field());
result->set_bit_field2(map->bit_field2());
int new_bit_field3 = map->bit_field3();
@@ -9555,7 +9555,7 @@ int Map::Hash() {
// addresses.
// Shift away the tag.
- int hash = ObjectAddressForHashing(constructor()) >> 2;
+ int hash = ObjectAddressForHashing(GetConstructor()) >> 2;
// XOR-ing the prototype and constructor directly yields too many zero bits
// when the two pointers are close (which is fairly common).
@@ -9567,7 +9567,7 @@ int Map::Hash() {
static bool CheckEquivalent(Map* first, Map* second) {
- return first->constructor() == second->constructor() &&
+ return first->GetConstructor() == second->GetConstructor() &&
first->prototype() == second->prototype() &&
first->instance_type() == second->instance_type() &&
first->bit_field() == second->bit_field() &&
@@ -9929,8 +9929,9 @@ void JSObject::OptimizeAsPrototype(Handle<JSObject> object,
Handle<Map> new_map = Map::Copy(handle(object->map()), "CopyAsPrototype");
JSObject::MigrateToMap(object, new_map);
}
- if (object->map()->constructor()->IsJSFunction()) {
- JSFunction* constructor = JSFunction::cast(object->map()->constructor());
+ Object* maybe_constructor = object->map()->GetConstructor();
+ if (maybe_constructor->IsJSFunction()) {
+ JSFunction* constructor = JSFunction::cast(maybe_constructor);
// Replace the pointer to the exact constructor with the Object function
// from the same context if undetectable from JS. This is to avoid keeping
// memory alive unnecessarily.
@@ -9939,7 +9940,7 @@ void JSObject::OptimizeAsPrototype(Handle<JSObject> object,
object->GetIsolate()->heap()->Object_string()) {
Context* context = constructor->context()->native_context();
JSFunction* object_function = context->object_function();
- object->map()->set_constructor(object_function);
+ object->map()->SetConstructor(object_function);
}
}
object->map()->set_is_prototype_map(true);
@@ -10126,7 +10127,7 @@ void JSFunction::SetPrototype(Handle<JSFunction> function,
Handle<Map> new_map = Map::Copy(handle(function->map()), "SetPrototype");
JSObject::MigrateToMap(function, new_map);
- new_map->set_constructor(*value);
+ new_map->SetConstructor(*value);
new_map->set_non_instance_prototype(true);
Isolate* isolate = new_map->GetIsolate();
construct_prototype = handle(
@@ -10169,7 +10170,7 @@ void JSFunction::SetInitialMap(Handle<JSFunction> function, Handle<Map> map,
map->SetPrototype(prototype, FAST_PROTOTYPE);
}
function->set_prototype_or_initial_map(*map);
- map->set_constructor(*function);
+ map->SetConstructor(*function);
#if TRACE_MAPS
if (FLAG_trace_maps) {
PrintF("[TraceMaps: InitialMap map= %p SFI= %d_%s ]\n",
@@ -13819,7 +13820,7 @@ void Dictionary<Derived, Shape, Key>::CopyValuesTo(FixedArray* elements) {
InterceptorInfo* JSObject::GetNamedInterceptor() {
DCHECK(map()->has_named_interceptor());
- JSFunction* constructor = JSFunction::cast(map()->constructor());
+ JSFunction* constructor = JSFunction::cast(map()->GetConstructor());
DCHECK(constructor->shared()->IsApiFunction());
Object* result =
constructor->shared()->get_api_func_data()->named_property_handler();
@@ -13829,7 +13830,7 @@ InterceptorInfo* JSObject::GetNamedInterceptor() {
InterceptorInfo* JSObject::GetIndexedInterceptor() {
DCHECK(map()->has_indexed_interceptor());
- JSFunction* constructor = JSFunction::cast(map()->constructor());
+ JSFunction* constructor = JSFunction::cast(map()->GetConstructor());
DCHECK(constructor->shared()->IsApiFunction());
Object* result =
constructor->shared()->get_api_func_data()->indexed_property_handler();
« no previous file with comments | « src/objects.h ('k') | src/objects-inl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698