Commit 41fe0f2c authored by Dan Elphick's avatar Dan Elphick Committed by Commit Bot

[explicit isolates] Remove GetIsolate from LayoutDescriptor

Pass Isolate directly into several LayoutDescriptor methods so they
don't call GetIsolate on unsafe objects.

Also marks DebugInfo as non-read-only (so our GetIsolate removal tools
stop trying to change BreakIterator::isolate() to call itself).

Bug: v8:7786
Change-Id: I626a83d603ab74f648c72eb50d027b3866cedceb
Reviewed-on: https://chromium-review.googlesource.com/1138326
Commit-Queue: Dan Elphick <delphick@chromium.org>
Reviewed-by: 's avatarLeszek Swirski <leszeks@chromium.org>
Cr-Commit-Position: refs/heads/master@{#54490}
parent b2b2583d
......@@ -14,8 +14,8 @@ namespace v8 {
namespace internal {
Handle<LayoutDescriptor> LayoutDescriptor::New(
Handle<Map> map, Handle<DescriptorArray> descriptors, int num_descriptors) {
Isolate* isolate = descriptors->GetIsolate();
Isolate* isolate, Handle<Map> map, Handle<DescriptorArray> descriptors,
int num_descriptors) {
if (!FLAG_unbox_double_fields) return handle(FastPointerLayout(), isolate);
int layout_descriptor_length =
......@@ -37,11 +37,9 @@ Handle<LayoutDescriptor> LayoutDescriptor::New(
return handle(layout_descriptor, isolate);
}
Handle<LayoutDescriptor> LayoutDescriptor::ShareAppend(
Handle<Map> map, PropertyDetails details) {
Isolate* isolate, Handle<Map> map, PropertyDetails details) {
DCHECK(map->owns_descriptors());
Isolate* isolate = map->GetIsolate();
Handle<LayoutDescriptor> layout_descriptor(map->GetLayoutDescriptor(),
isolate);
......@@ -63,9 +61,8 @@ Handle<LayoutDescriptor> LayoutDescriptor::ShareAppend(
return handle(layout_desc, isolate);
}
Handle<LayoutDescriptor> LayoutDescriptor::AppendIfFastOrUseFull(
Handle<Map> map, PropertyDetails details,
Isolate* isolate, Handle<Map> map, PropertyDetails details,
Handle<LayoutDescriptor> full_layout_descriptor) {
DisallowHeapAllocation no_allocation;
LayoutDescriptor* layout_descriptor = map->layout_descriptor();
......@@ -75,7 +72,7 @@ Handle<LayoutDescriptor> LayoutDescriptor::AppendIfFastOrUseFull(
if (!InobjectUnboxedField(map->GetInObjectProperties(), details)) {
DCHECK(details.location() != kField ||
layout_descriptor->IsTagged(details.field_index()));
return handle(layout_descriptor, map->GetIsolate());
return handle(layout_descriptor, isolate);
}
int field_index = details.field_index();
int new_capacity = field_index + details.field_width_in_words();
......@@ -89,7 +86,7 @@ Handle<LayoutDescriptor> LayoutDescriptor::AppendIfFastOrUseFull(
if (details.field_width_in_words() > 1) {
layout_descriptor = layout_descriptor->SetRawData(field_index + 1);
}
return handle(layout_descriptor, map->GetIsolate());
return handle(layout_descriptor, isolate);
}
......
......@@ -51,20 +51,20 @@ class LayoutDescriptor : public ByteArray {
// Builds layout descriptor optimized for given |map| by |num_descriptors|
// elements of given descriptors array. The |map|'s descriptors could be
// different.
static Handle<LayoutDescriptor> New(Handle<Map> map,
static Handle<LayoutDescriptor> New(Isolate* isolate, Handle<Map> map,
Handle<DescriptorArray> descriptors,
int num_descriptors);
// Modifies |map|'s layout descriptor or creates a new one if necessary by
// appending property with |details| to it.
static Handle<LayoutDescriptor> ShareAppend(Handle<Map> map,
static Handle<LayoutDescriptor> ShareAppend(Isolate* isolate, Handle<Map> map,
PropertyDetails details);
// Creates new layout descriptor by appending property with |details| to
// |map|'s layout descriptor and if it is still fast then returns it.
// Otherwise the |full_layout_descriptor| is returned.
static Handle<LayoutDescriptor> AppendIfFastOrUseFull(
Handle<Map> map, PropertyDetails details,
Isolate* isolate, Handle<Map> map, PropertyDetails details,
Handle<LayoutDescriptor> full_layout_descriptor);
// Layout descriptor that corresponds to an object all fields of which are
......
......@@ -689,7 +689,7 @@ MapUpdater::State MapUpdater::ConstructNewMap() {
}
Handle<LayoutDescriptor> new_layout_descriptor =
LayoutDescriptor::New(split_map, new_descriptors, old_nof_);
LayoutDescriptor::New(isolate_, split_map, new_descriptors, old_nof_);
Handle<Map> new_map = Map::AddMissingTransitions(
isolate_, split_map, new_descriptors, new_layout_descriptor);
......
......@@ -6545,7 +6545,7 @@ void JSObject::MigrateSlowToFast(Handle<JSObject> object,
descriptors->Sort();
Handle<LayoutDescriptor> layout_descriptor = LayoutDescriptor::New(
new_map, descriptors, descriptors->number_of_descriptors());
isolate, new_map, descriptors, descriptors->number_of_descriptors());
DisallowHeapAllocation no_gc;
new_map->InitializeDescriptors(*descriptors, *layout_descriptor);
......@@ -9455,7 +9455,8 @@ Handle<Map> Map::ShareDescriptor(Isolate* isolate, Handle<Map> map,
Handle<LayoutDescriptor> layout_descriptor =
FLAG_unbox_double_fields
? LayoutDescriptor::ShareAppend(map, descriptor->GetDetails())
? LayoutDescriptor::ShareAppend(isolate, map,
descriptor->GetDetails())
: handle(LayoutDescriptor::FastPointerLayout(), isolate);
{
......@@ -9616,7 +9617,7 @@ void Map::InstallDescriptors(Isolate* isolate, Handle<Map> parent,
if (FLAG_unbox_double_fields) {
Handle<LayoutDescriptor> layout_descriptor =
LayoutDescriptor::AppendIfFastOrUseFull(parent, details,
LayoutDescriptor::AppendIfFastOrUseFull(isolate, parent, details,
full_layout_descriptor);
child->set_layout_descriptor(*layout_descriptor);
#ifdef VERIFY_HEAP
......@@ -10118,7 +10119,7 @@ Handle<Map> Map::CopyAddDescriptor(Isolate* isolate, Handle<Map> map,
Handle<LayoutDescriptor> new_layout_descriptor =
FLAG_unbox_double_fields
? LayoutDescriptor::New(map, new_descriptors, nof + 1)
? LayoutDescriptor::New(isolate, map, new_descriptors, nof + 1)
: handle(LayoutDescriptor::FastPointerLayout(), isolate);
return CopyReplaceDescriptors(
......@@ -10226,7 +10227,7 @@ Handle<Map> Map::CopyReplaceDescriptor(Isolate* isolate, Handle<Map> map,
new_descriptors->Replace(insertion_index, descriptor);
Handle<LayoutDescriptor> new_layout_descriptor = LayoutDescriptor::New(
map, new_descriptors, new_descriptors->number_of_descriptors());
isolate, map, new_descriptors, new_descriptors->number_of_descriptors());
SimpleTransitionFlag simple_flag =
(insertion_index == descriptors->number_of_descriptors() - 1)
......
......@@ -19,8 +19,11 @@ class BytecodeArray;
// The DebugInfo class holds additional information for a function being
// debugged.
class DebugInfo : public Struct {
class DebugInfo : public Struct, public NeverReadOnlySpaceObject {
public:
using NeverReadOnlySpaceObject::GetHeap;
using NeverReadOnlySpaceObject::GetIsolate;
enum Flag {
kNone = 0,
kHasBreakInfo = 1 << 0,
......
......@@ -192,7 +192,8 @@ TEST(LayoutDescriptorBasicSlow) {
Handle<Map> map = Map::Create(isolate, kPropsCount);
layout_descriptor = LayoutDescriptor::New(map, descriptors, kPropsCount);
layout_descriptor =
LayoutDescriptor::New(isolate, map, descriptors, kPropsCount);
CHECK_EQ(LayoutDescriptor::FastPointerLayout(), *layout_descriptor);
CHECK_EQ(kBitsInSmiLayout, layout_descriptor->capacity());
InitializeVerifiedMapDescriptors(*map, *descriptors, *layout_descriptor);
......@@ -209,7 +210,8 @@ TEST(LayoutDescriptorBasicSlow) {
Handle<Map> map = Map::Create(isolate, inobject_properties);
// Should be fast as the only double property is the first one.
layout_descriptor = LayoutDescriptor::New(map, descriptors, kPropsCount);
layout_descriptor =
LayoutDescriptor::New(isolate, map, descriptors, kPropsCount);
CHECK_NE(LayoutDescriptor::FastPointerLayout(), *layout_descriptor);
CHECK(!layout_descriptor->IsSlowLayout());
CHECK(!layout_descriptor->IsFastPointerLayout());
......@@ -225,7 +227,8 @@ TEST(LayoutDescriptorBasicSlow) {
int inobject_properties = kPropsCount;
Handle<Map> map = Map::Create(isolate, inobject_properties);
layout_descriptor = LayoutDescriptor::New(map, descriptors, kPropsCount);
layout_descriptor =
LayoutDescriptor::New(isolate, map, descriptors, kPropsCount);
CHECK_NE(LayoutDescriptor::FastPointerLayout(), *layout_descriptor);
CHECK(layout_descriptor->IsSlowLayout());
CHECK(!layout_descriptor->IsFastPointerLayout());
......@@ -514,21 +517,24 @@ TEST(LayoutDescriptorCreateNewFast) {
{
Handle<Map> map = Map::Create(isolate, 0);
layout_descriptor = LayoutDescriptor::New(map, descriptors, kPropsCount);
layout_descriptor =
LayoutDescriptor::New(isolate, map, descriptors, kPropsCount);
CHECK_EQ(LayoutDescriptor::FastPointerLayout(), *layout_descriptor);
InitializeVerifiedMapDescriptors(*map, *descriptors, *layout_descriptor);
}
{
Handle<Map> map = Map::Create(isolate, 1);
layout_descriptor = LayoutDescriptor::New(map, descriptors, kPropsCount);
layout_descriptor =
LayoutDescriptor::New(isolate, map, descriptors, kPropsCount);
CHECK_EQ(LayoutDescriptor::FastPointerLayout(), *layout_descriptor);
InitializeVerifiedMapDescriptors(*map, *descriptors, *layout_descriptor);
}
{
Handle<Map> map = Map::Create(isolate, 2);
layout_descriptor = LayoutDescriptor::New(map, descriptors, kPropsCount);
layout_descriptor =
LayoutDescriptor::New(isolate, map, descriptors, kPropsCount);
CHECK_NE(LayoutDescriptor::FastPointerLayout(), *layout_descriptor);
CHECK(!layout_descriptor->IsSlowLayout());
CHECK(layout_descriptor->IsTagged(0));
......@@ -557,21 +563,24 @@ TEST(LayoutDescriptorCreateNewSlow) {
{
Handle<Map> map = Map::Create(isolate, 0);
layout_descriptor = LayoutDescriptor::New(map, descriptors, kPropsCount);
layout_descriptor =
LayoutDescriptor::New(isolate, map, descriptors, kPropsCount);
CHECK_EQ(LayoutDescriptor::FastPointerLayout(), *layout_descriptor);
InitializeVerifiedMapDescriptors(*map, *descriptors, *layout_descriptor);
}
{
Handle<Map> map = Map::Create(isolate, 1);
layout_descriptor = LayoutDescriptor::New(map, descriptors, kPropsCount);
layout_descriptor =
LayoutDescriptor::New(isolate, map, descriptors, kPropsCount);
CHECK_EQ(LayoutDescriptor::FastPointerLayout(), *layout_descriptor);
InitializeVerifiedMapDescriptors(*map, *descriptors, *layout_descriptor);
}
{
Handle<Map> map = Map::Create(isolate, 2);
layout_descriptor = LayoutDescriptor::New(map, descriptors, kPropsCount);
layout_descriptor =
LayoutDescriptor::New(isolate, map, descriptors, kPropsCount);
CHECK_NE(LayoutDescriptor::FastPointerLayout(), *layout_descriptor);
CHECK(!layout_descriptor->IsSlowLayout());
CHECK(layout_descriptor->IsTagged(0));
......@@ -584,7 +593,8 @@ TEST(LayoutDescriptorCreateNewSlow) {
{
int inobject_properties = kPropsCount / 2;
Handle<Map> map = Map::Create(isolate, inobject_properties);
layout_descriptor = LayoutDescriptor::New(map, descriptors, kPropsCount);
layout_descriptor =
LayoutDescriptor::New(isolate, map, descriptors, kPropsCount);
CHECK_NE(LayoutDescriptor::FastPointerLayout(), *layout_descriptor);
CHECK(layout_descriptor->IsSlowLayout());
for (int i = 0; i < inobject_properties; i++) {
......@@ -600,7 +610,7 @@ TEST(LayoutDescriptorCreateNewSlow) {
// Now test LayoutDescriptor::cast_gc_safe().
Handle<LayoutDescriptor> layout_descriptor_copy =
LayoutDescriptor::New(map, descriptors, kPropsCount);
LayoutDescriptor::New(isolate, map, descriptors, kPropsCount);
LayoutDescriptor* layout_desc = *layout_descriptor;
CHECK_EQ(layout_desc, LayoutDescriptor::cast(layout_desc));
......@@ -652,7 +662,7 @@ static Handle<LayoutDescriptor> TestLayoutDescriptorAppend(
representations[kind]);
}
PropertyDetails details = d.GetDetails();
layout_descriptor = LayoutDescriptor::ShareAppend(map, details);
layout_descriptor = LayoutDescriptor::ShareAppend(isolate, map, details);
descriptors->Append(&d);
if (details.location() == kField) {
int field_width_in_words = details.field_width_in_words();
......@@ -763,7 +773,7 @@ static Handle<LayoutDescriptor> TestLayoutDescriptorAppendIfFastOrUseFull(
Handle<Map> initial_map = Map::Create(isolate, inobject_properties);
Handle<LayoutDescriptor> full_layout_descriptor = LayoutDescriptor::New(
initial_map, descriptors, descriptors->number_of_descriptors());
isolate, initial_map, descriptors, descriptors->number_of_descriptors());
int nof = 0;
bool switched_to_slow_mode = false;
......@@ -933,7 +943,7 @@ TEST(Regress436816) {
Handle<Map> map = Map::Create(isolate, kPropsCount);
Handle<LayoutDescriptor> layout_descriptor =
LayoutDescriptor::New(map, descriptors, kPropsCount);
LayoutDescriptor::New(isolate, map, descriptors, kPropsCount);
map->InitializeDescriptors(*descriptors, *layout_descriptor);
Handle<JSObject> object = factory->NewJSObjectFromMap(map, TENURED);
......@@ -1215,7 +1225,7 @@ static void TestLayoutDescriptorHelper(Isolate* isolate,
Handle<Map> map = Map::Create(isolate, inobject_properties);
Handle<LayoutDescriptor> layout_descriptor = LayoutDescriptor::New(
map, descriptors, descriptors->number_of_descriptors());
isolate, map, descriptors, descriptors->number_of_descriptors());
InitializeVerifiedMapDescriptors(*map, *descriptors, *layout_descriptor);
LayoutDescriptorHelper helper(*map);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment