Commit 4ce2adc3 authored by Dan Elphick's avatar Dan Elphick Committed by Commit Bot

[explicit isolates] Eliminate GetIsolate from transitions.cc

Removes all explicit calls to GetIsolate() in transitions.cc by passing
it through calling functions and implicit calls via the single argument
Handle constructor and handle function.

Unfortunately in the interests of making these changes vaguely
manageable, I've also pushed some new GetIsolates down into
objects-debug.cc, objects-printer.cc and objects.cc.

Bug: v8:7786
Change-Id: I1f98530dec6c004e17dc3336f3cef09fbb446bae
Reviewed-on: https://chromium-review.googlesource.com/1085451
Commit-Queue: Dan Elphick <delphick@chromium.org>
Reviewed-by: 's avatarMichael Starzinger <mstarzinger@chromium.org>
Cr-Commit-Position: refs/heads/master@{#53518}
parent 5eaa03b2
...@@ -663,7 +663,7 @@ bool AccessInfoFactory::LookupTransition(Handle<Map> map, Handle<Name> name, ...@@ -663,7 +663,7 @@ bool AccessInfoFactory::LookupTransition(Handle<Map> map, Handle<Name> name,
PropertyAccessInfo* access_info) { PropertyAccessInfo* access_info) {
// Check if the {map} has a data transition with the given {name}. // Check if the {map} has a data transition with the given {name}.
Map* transition = Map* transition =
TransitionsAccessor(map).SearchTransition(*name, kData, NONE); TransitionsAccessor(isolate_, map).SearchTransition(*name, kData, NONE);
if (transition == nullptr) return false; if (transition == nullptr) return false;
Handle<Map> transition_map(transition); Handle<Map> transition_map(transition);
......
...@@ -1708,7 +1708,7 @@ void MarkCompactCollector::ClearPotentialSimpleMapTransition(Map* dead_target) { ...@@ -1708,7 +1708,7 @@ void MarkCompactCollector::ClearPotentialSimpleMapTransition(Map* dead_target) {
Map* parent = Map::cast(potential_parent); Map* parent = Map::cast(potential_parent);
DisallowHeapAllocation no_gc_obviously; DisallowHeapAllocation no_gc_obviously;
if (non_atomic_marking_state()->IsBlackOrGrey(parent) && if (non_atomic_marking_state()->IsBlackOrGrey(parent) &&
TransitionsAccessor(parent, &no_gc_obviously) TransitionsAccessor(isolate(), parent, &no_gc_obviously)
.HasSimpleTransitionTo(dead_target)) { .HasSimpleTransitionTo(dead_target)) {
ClearPotentialSimpleMapTransition(parent, dead_target); ClearPotentialSimpleMapTransition(parent, dead_target);
} }
......
...@@ -404,7 +404,7 @@ Handle<Object> JsonParser<seq_one_byte>::ParseJsonObject() { ...@@ -404,7 +404,7 @@ Handle<Object> JsonParser<seq_one_byte>::ParseJsonObject() {
Handle<Map> target; Handle<Map> target;
if (seq_one_byte) { if (seq_one_byte) {
DisallowHeapAllocation no_gc; DisallowHeapAllocation no_gc;
TransitionsAccessor transitions(*map, &no_gc); TransitionsAccessor transitions(isolate(), *map, &no_gc);
key = transitions.ExpectedTransitionKey(); key = transitions.ExpectedTransitionKey();
follow_expected = !key.is_null() && ParseJsonString(key); follow_expected = !key.is_null() && ParseJsonString(key);
// If the expected transition hits, follow it. // If the expected transition hits, follow it.
...@@ -419,9 +419,9 @@ Handle<Object> JsonParser<seq_one_byte>::ParseJsonObject() { ...@@ -419,9 +419,9 @@ Handle<Object> JsonParser<seq_one_byte>::ParseJsonObject() {
if (key.is_null()) return ReportUnexpectedCharacter(); if (key.is_null()) return ReportUnexpectedCharacter();
// If a transition was found, follow it and continue. // If a transition was found, follow it and continue.
transitioning = transitioning = TransitionsAccessor(isolate(), map)
TransitionsAccessor(map).FindTransitionToField(key).ToHandle( .FindTransitionToField(key)
&target); .ToHandle(&target);
} }
if (c0_ != ':') return ReportUnexpectedCharacter(); if (c0_ != ':') return ReportUnexpectedCharacter();
......
...@@ -307,7 +307,7 @@ MapUpdater::State MapUpdater::FindTargetMap() { ...@@ -307,7 +307,7 @@ MapUpdater::State MapUpdater::FindTargetMap() {
int root_nof = root_map_->NumberOfOwnDescriptors(); int root_nof = root_map_->NumberOfOwnDescriptors();
for (int i = root_nof; i < old_nof_; ++i) { for (int i = root_nof; i < old_nof_; ++i) {
PropertyDetails old_details = GetDetails(i); PropertyDetails old_details = GetDetails(i);
Map* transition = TransitionsAccessor(target_map_) Map* transition = TransitionsAccessor(isolate_, target_map_)
.SearchTransition(GetKey(i), old_details.kind(), .SearchTransition(GetKey(i), old_details.kind(),
old_details.attributes()); old_details.attributes());
if (transition == nullptr) break; if (transition == nullptr) break;
...@@ -393,7 +393,7 @@ MapUpdater::State MapUpdater::FindTargetMap() { ...@@ -393,7 +393,7 @@ MapUpdater::State MapUpdater::FindTargetMap() {
// Find the last compatible target map in the transition tree. // Find the last compatible target map in the transition tree.
for (int i = target_nof; i < old_nof_; ++i) { for (int i = target_nof; i < old_nof_; ++i) {
PropertyDetails old_details = GetDetails(i); PropertyDetails old_details = GetDetails(i);
Map* transition = TransitionsAccessor(target_map_) Map* transition = TransitionsAccessor(isolate_, target_map_)
.SearchTransition(GetKey(i), old_details.kind(), .SearchTransition(GetKey(i), old_details.kind(),
old_details.attributes()); old_details.attributes());
if (transition == nullptr) break; if (transition == nullptr) break;
...@@ -603,7 +603,7 @@ Handle<Map> MapUpdater::FindSplitMap(Handle<DescriptorArray> descriptors) { ...@@ -603,7 +603,7 @@ Handle<Map> MapUpdater::FindSplitMap(Handle<DescriptorArray> descriptors) {
Name* name = descriptors->GetKey(i); Name* name = descriptors->GetKey(i);
PropertyDetails details = descriptors->GetDetails(i); PropertyDetails details = descriptors->GetDetails(i);
Map* next = Map* next =
TransitionsAccessor(current, &no_allocation) TransitionsAccessor(isolate_, current, &no_allocation)
.SearchTransition(name, details.kind(), details.attributes()); .SearchTransition(name, details.kind(), details.attributes());
if (next == nullptr) break; if (next == nullptr) break;
DescriptorArray* next_descriptors = next->instance_descriptors(); DescriptorArray* next_descriptors = next->instance_descriptors();
...@@ -639,7 +639,7 @@ MapUpdater::State MapUpdater::ConstructNewMap() { ...@@ -639,7 +639,7 @@ MapUpdater::State MapUpdater::ConstructNewMap() {
DCHECK_NE(old_nof_, split_nof); DCHECK_NE(old_nof_, split_nof);
PropertyDetails split_details = GetDetails(split_nof); PropertyDetails split_details = GetDetails(split_nof);
TransitionsAccessor transitions(split_map); TransitionsAccessor transitions(isolate_, split_map);
// Invalidate a transition target at |key|. // Invalidate a transition target at |key|.
Map* maybe_transition = transitions.SearchTransition( Map* maybe_transition = transitions.SearchTransition(
......
...@@ -542,7 +542,8 @@ void JSObject::JSObjectVerify() { ...@@ -542,7 +542,8 @@ void JSObject::JSObjectVerify() {
void Map::MapVerify() { void Map::MapVerify() {
Heap* heap = GetHeap(); Isolate* isolate = GetIsolate();
Heap* heap = isolate->heap();
CHECK(!heap->InNewSpace(this)); CHECK(!heap->InNewSpace(this));
CHECK(FIRST_TYPE <= instance_type() && instance_type() <= LAST_TYPE); CHECK(FIRST_TYPE <= instance_type() && instance_type() <= LAST_TYPE);
CHECK(instance_size() == kVariableSizeSentinel || CHECK(instance_size() == kVariableSizeSentinel ||
...@@ -554,8 +555,10 @@ void Map::MapVerify() { ...@@ -554,8 +555,10 @@ void Map::MapVerify() {
VerifyHeapPointer(instance_descriptors()); VerifyHeapPointer(instance_descriptors());
SLOW_DCHECK(instance_descriptors()->IsSortedNoDuplicates()); SLOW_DCHECK(instance_descriptors()->IsSortedNoDuplicates());
DisallowHeapAllocation no_gc; DisallowHeapAllocation no_gc;
SLOW_DCHECK(TransitionsAccessor(this, &no_gc).IsSortedNoDuplicates()); SLOW_DCHECK(
SLOW_DCHECK(TransitionsAccessor(this, &no_gc).IsConsistentWithBackPointers()); TransitionsAccessor(isolate, this, &no_gc).IsSortedNoDuplicates());
SLOW_DCHECK(TransitionsAccessor(isolate, this, &no_gc)
.IsConsistentWithBackPointers());
SLOW_DCHECK(!FLAG_unbox_double_fields || SLOW_DCHECK(!FLAG_unbox_double_fields ||
layout_descriptor()->IsConsistentWithMap(this)); layout_descriptor()->IsConsistentWithMap(this));
if (!may_have_interesting_symbols()) { if (!may_have_interesting_symbols()) {
...@@ -1966,15 +1969,16 @@ bool TransitionArray::IsSortedNoDuplicates(int valid_entries) { ...@@ -1966,15 +1969,16 @@ bool TransitionArray::IsSortedNoDuplicates(int valid_entries) {
PropertyKind prev_kind = kData; PropertyKind prev_kind = kData;
PropertyAttributes prev_attributes = NONE; PropertyAttributes prev_attributes = NONE;
uint32_t prev_hash = 0; uint32_t prev_hash = 0;
Isolate* isolate = GetIsolate();
for (int i = 0; i < number_of_transitions(); i++) { for (int i = 0; i < number_of_transitions(); i++) {
Name* key = GetSortedKey(i); Name* key = GetSortedKey(i);
uint32_t hash = key->Hash(); uint32_t hash = key->Hash();
PropertyKind kind = kData; PropertyKind kind = kData;
PropertyAttributes attributes = NONE; PropertyAttributes attributes = NONE;
if (!TransitionsAccessor::IsSpecialTransition(key)) { if (!TransitionsAccessor::IsSpecialTransition(isolate, key)) {
Map* target = GetTarget(i); Map* target = GetTarget(i);
PropertyDetails details = PropertyDetails details =
TransitionsAccessor::GetTargetDetails(key, target); TransitionsAccessor::GetTargetDetails(isolate, key, target);
kind = details.kind(); kind = details.kind();
attributes = details.attributes(); attributes = details.attributes();
} else { } else {
......
...@@ -769,7 +769,7 @@ void Map::MapPrint(std::ostream& os) { // NOLINT ...@@ -769,7 +769,7 @@ void Map::MapPrint(std::ostream& os) { // NOLINT
} }
{ {
DisallowHeapAllocation no_gc; DisallowHeapAllocation no_gc;
TransitionsAccessor transitions(this, &no_gc); TransitionsAccessor transitions(GetIsolate(), this, &no_gc);
int nof_transitions = transitions.NumberOfTransitions(); int nof_transitions = transitions.NumberOfTransitions();
if (nof_transitions > 0) { if (nof_transitions > 0) {
os << "\n - transitions #" << nof_transitions << ": "; os << "\n - transitions #" << nof_transitions << ": ";
...@@ -2237,7 +2237,7 @@ void TransitionsAccessor::PrintOneTransition(std::ostream& os, Name* key, ...@@ -2237,7 +2237,7 @@ void TransitionsAccessor::PrintOneTransition(std::ostream& os, Name* key,
} else if (key == heap->strict_function_transition_symbol()) { } else if (key == heap->strict_function_transition_symbol()) {
os << " (transition to strict function)"; os << " (transition to strict function)";
} else { } else {
DCHECK(!IsSpecialTransition(key)); DCHECK(!IsSpecialTransition(key->GetIsolate(), key));
os << "(transition to "; os << "(transition to ";
int descriptor = target->LastAdded(); int descriptor = target->LastAdded();
DescriptorArray* descriptors = target->instance_descriptors(); DescriptorArray* descriptors = target->instance_descriptors();
...@@ -2302,7 +2302,7 @@ void TransitionsAccessor::PrintTransitionTree(std::ostream& os, int level, ...@@ -2302,7 +2302,7 @@ void TransitionsAccessor::PrintTransitionTree(std::ostream& os, int level,
ss << Brief(target); ss << Brief(target);
os << std::left << std::setw(50) << ss.str() << ": "; os << std::left << std::setw(50) << ss.str() << ": ";
Heap* heap = key->GetHeap(); Heap* heap = isolate_->heap();
if (key == heap->nonextensible_symbol()) { if (key == heap->nonextensible_symbol()) {
os << "to non-extensible"; os << "to non-extensible";
} else if (key == heap->sealed_symbol()) { } else if (key == heap->sealed_symbol()) {
...@@ -2320,21 +2320,21 @@ void TransitionsAccessor::PrintTransitionTree(std::ostream& os, int level, ...@@ -2320,21 +2320,21 @@ void TransitionsAccessor::PrintTransitionTree(std::ostream& os, int level,
key->ShortPrint(os); key->ShortPrint(os);
#endif #endif
os << " "; os << " ";
DCHECK(!IsSpecialTransition(key)); DCHECK(!IsSpecialTransition(isolate_, key));
os << "to "; os << "to ";
int descriptor = target->LastAdded(); int descriptor = target->LastAdded();
DescriptorArray* descriptors = target->instance_descriptors(); DescriptorArray* descriptors = target->instance_descriptors();
descriptors->PrintDescriptorDetails(os, descriptor, descriptors->PrintDescriptorDetails(os, descriptor,
PropertyDetails::kForTransitions); PropertyDetails::kForTransitions);
} }
TransitionsAccessor transitions(target, no_gc); TransitionsAccessor transitions(isolate_, target, no_gc);
transitions.PrintTransitionTree(os, level + 1, no_gc); transitions.PrintTransitionTree(os, level + 1, no_gc);
} }
} }
void JSObject::PrintTransitions(std::ostream& os) { // NOLINT void JSObject::PrintTransitions(std::ostream& os) { // NOLINT
DisallowHeapAllocation no_gc; DisallowHeapAllocation no_gc;
TransitionsAccessor ta(map(), &no_gc); TransitionsAccessor ta(GetIsolate(), map(), &no_gc);
if (ta.NumberOfTransitions() == 0) return; if (ta.NumberOfTransitions() == 0) return;
os << "\n - transitions"; os << "\n - transitions";
ta.PrintTransitions(os); ta.PrintTransitions(os);
...@@ -2437,8 +2437,8 @@ extern void _v8_internal_Print_TransitionTree(void* object) { ...@@ -2437,8 +2437,8 @@ extern void _v8_internal_Print_TransitionTree(void* object) {
} else { } else {
#if defined(DEBUG) || defined(OBJECT_PRINT) #if defined(DEBUG) || defined(OBJECT_PRINT)
i::DisallowHeapAllocation no_gc; i::DisallowHeapAllocation no_gc;
i::TransitionsAccessor transitions(reinterpret_cast<i::Map*>(object), i::Map* map = reinterpret_cast<i::Map*>(object);
&no_gc); i::TransitionsAccessor transitions(map->GetIsolate(), map, &no_gc);
transitions.PrintTransitionTree(); transitions.PrintTransitionTree();
#endif #endif
} }
......
This diff is collapsed.
...@@ -636,7 +636,7 @@ Object* Map::GetBackPointer() const { ...@@ -636,7 +636,7 @@ Object* Map::GetBackPointer() const {
Map* Map::ElementsTransitionMap() { Map* Map::ElementsTransitionMap() {
DisallowHeapAllocation no_gc; DisallowHeapAllocation no_gc;
return TransitionsAccessor(this, &no_gc) return TransitionsAccessor(GetIsolate(), this, &no_gc)
.SearchSpecial(GetHeap()->elements_transition_symbol()); .SearchSpecial(GetHeap()->elements_transition_symbol());
} }
......
...@@ -89,8 +89,9 @@ HeapObjectReference** TransitionArray::GetTargetSlot(int transition_number) { ...@@ -89,8 +89,9 @@ HeapObjectReference** TransitionArray::GetTargetSlot(int transition_number) {
} }
// static // static
PropertyDetails TransitionsAccessor::GetTargetDetails(Name* name, Map* target) { PropertyDetails TransitionsAccessor::GetTargetDetails(Isolate* isolate,
DCHECK(!IsSpecialTransition(name)); Name* name, Map* target) {
DCHECK(!IsSpecialTransition(isolate, name));
int descriptor = target->LastAdded(); int descriptor = target->LastAdded();
DescriptorArray* descriptors = target->instance_descriptors(); DescriptorArray* descriptors = target->instance_descriptors();
// Transitions are allowed only for the last added property. // Transitions are allowed only for the last added property.
......
This diff is collapsed.
...@@ -37,11 +37,13 @@ namespace internal { ...@@ -37,11 +37,13 @@ namespace internal {
// cleared when the map they refer to is not otherwise reachable. // cleared when the map they refer to is not otherwise reachable.
class TransitionsAccessor { class TransitionsAccessor {
public: public:
TransitionsAccessor(Map* map, DisallowHeapAllocation* no_gc) : map_(map) { TransitionsAccessor(Isolate* isolate, Map* map, DisallowHeapAllocation* no_gc)
: isolate_(isolate), map_(map) {
Initialize(); Initialize();
USE(no_gc); USE(no_gc);
} }
explicit TransitionsAccessor(Handle<Map> map) : map_handle_(map), map_(*map) { TransitionsAccessor(Isolate* isolate, Handle<Map> map)
: isolate_(isolate), map_handle_(map), map_(*map) {
Initialize(); Initialize();
} }
...@@ -57,7 +59,7 @@ class TransitionsAccessor { ...@@ -57,7 +59,7 @@ class TransitionsAccessor {
Map* SearchSpecial(Symbol* name); Map* SearchSpecial(Symbol* name);
// Returns true for non-property transitions like elements kind, or // Returns true for non-property transitions like elements kind, or
// or frozen/sealed transitions. // or frozen/sealed transitions.
static bool IsSpecialTransition(Name* name); static bool IsSpecialTransition(Isolate* isolate, Name* name);
enum RequestedLocation { kAnyLocation, kFieldOnly }; enum RequestedLocation { kAnyLocation, kFieldOnly };
MaybeHandle<Map> FindTransitionToDataProperty( MaybeHandle<Map> FindTransitionToDataProperty(
...@@ -78,7 +80,8 @@ class TransitionsAccessor { ...@@ -78,7 +80,8 @@ class TransitionsAccessor {
bool CanHaveMoreTransitions(); bool CanHaveMoreTransitions();
inline Name* GetKey(int transition_number); inline Name* GetKey(int transition_number);
inline Map* GetTarget(int transition_number); inline Map* GetTarget(int transition_number);
static inline PropertyDetails GetTargetDetails(Name* name, Map* target); static inline PropertyDetails GetTargetDetails(Isolate* isolate, Name* name,
Map* target);
static bool IsMatchingMap(Map* target, Name* name, PropertyKind kind, static bool IsMatchingMap(Map* target, Name* name, PropertyKind kind,
PropertyAttributes attributes); PropertyAttributes attributes);
...@@ -177,6 +180,7 @@ class TransitionsAccessor { ...@@ -177,6 +180,7 @@ class TransitionsAccessor {
inline TransitionArray* transitions(); inline TransitionArray* transitions();
Isolate* isolate_;
Handle<Map> map_handle_; Handle<Map> map_handle_;
Map* map_; Map* map_;
MaybeObject* raw_transitions_; MaybeObject* raw_transitions_;
...@@ -230,7 +234,7 @@ class TransitionArray : public WeakFixedArray { ...@@ -230,7 +234,7 @@ class TransitionArray : public WeakFixedArray {
bool IsSortedNoDuplicates(int valid_entries = -1); bool IsSortedNoDuplicates(int valid_entries = -1);
#endif #endif
void Sort(); void Sort(Isolate* isolate);
#if defined(DEBUG) || defined(OBJECT_PRINT) #if defined(DEBUG) || defined(OBJECT_PRINT)
// For our gdb macros. // For our gdb macros.
...@@ -298,8 +302,8 @@ class TransitionArray : public WeakFixedArray { ...@@ -298,8 +302,8 @@ class TransitionArray : public WeakFixedArray {
} }
// Search a transition for a given kind, property name and attributes. // Search a transition for a given kind, property name and attributes.
int Search(PropertyKind kind, Name* name, PropertyAttributes attributes, int Search(Isolate* isolate, PropertyKind kind, Name* name,
int* out_insertion_index = nullptr); PropertyAttributes attributes, int* out_insertion_index = nullptr);
// Search a non-property transition (like elements kind, observe or frozen // Search a non-property transition (like elements kind, observe or frozen
// transitions). // transitions).
...@@ -308,12 +312,13 @@ class TransitionArray : public WeakFixedArray { ...@@ -308,12 +312,13 @@ class TransitionArray : public WeakFixedArray {
} }
// Search a first transition for a given property name. // Search a first transition for a given property name.
inline int SearchName(Name* name, int* out_insertion_index = nullptr); inline int SearchName(Name* name, int* out_insertion_index = nullptr);
int SearchDetails(int transition, PropertyKind kind, int SearchDetails(Isolate* isolate, int transition, PropertyKind kind,
PropertyAttributes attributes, int* out_insertion_index); PropertyAttributes attributes, int* out_insertion_index);
inline int number_of_transitions() const; inline int number_of_transitions() const;
static bool CompactPrototypeTransitionArray(WeakFixedArray* array); static bool CompactPrototypeTransitionArray(Isolate* isolate,
WeakFixedArray* array);
static Handle<WeakFixedArray> GrowPrototypeTransitionArray( static Handle<WeakFixedArray> GrowPrototypeTransitionArray(
Handle<WeakFixedArray> array, int new_capacity, Isolate* isolate); Handle<WeakFixedArray> array, int new_capacity, Isolate* isolate);
...@@ -339,7 +344,7 @@ class TransitionArray : public WeakFixedArray { ...@@ -339,7 +344,7 @@ class TransitionArray : public WeakFixedArray {
inline void Set(int transition_number, Name* key, MaybeObject* target); inline void Set(int transition_number, Name* key, MaybeObject* target);
void Zap(); void Zap(Isolate* isolate);
DISALLOW_IMPLICIT_CONSTRUCTORS(TransitionArray); DISALLOW_IMPLICIT_CONSTRUCTORS(TransitionArray);
}; };
......
...@@ -1904,7 +1904,7 @@ Maybe<uint32_t> ValueDeserializer::ReadJSObjectProperties( ...@@ -1904,7 +1904,7 @@ Maybe<uint32_t> ValueDeserializer::ReadJSObjectProperties(
// transition was found. // transition was found.
Handle<Object> key; Handle<Object> key;
Handle<Map> target; Handle<Map> target;
TransitionsAccessor transitions(map); TransitionsAccessor transitions(isolate_, map);
Handle<String> expected_key = transitions.ExpectedTransitionKey(); Handle<String> expected_key = transitions.ExpectedTransitionKey();
if (!expected_key.is_null() && ReadExpectedString(expected_key)) { if (!expected_key.is_null() && ReadExpectedString(expected_key)) {
key = expected_key; key = expected_key;
...@@ -1917,7 +1917,7 @@ Maybe<uint32_t> ValueDeserializer::ReadJSObjectProperties( ...@@ -1917,7 +1917,7 @@ Maybe<uint32_t> ValueDeserializer::ReadJSObjectProperties(
key = key =
isolate_->factory()->InternalizeString(Handle<String>::cast(key)); isolate_->factory()->InternalizeString(Handle<String>::cast(key));
// Don't reuse |transitions| because it could be stale. // Don't reuse |transitions| because it could be stale.
transitioning = TransitionsAccessor(map) transitioning = TransitionsAccessor(isolate_, map)
.FindTransitionToField(Handle<String>::cast(key)) .FindTransitionToField(Handle<String>::cast(key))
.ToHandle(&target); .ToHandle(&target);
} else { } else {
......
...@@ -2703,10 +2703,9 @@ TEST(OptimizedAllocationArrayLiterals) { ...@@ -2703,10 +2703,9 @@ TEST(OptimizedAllocationArrayLiterals) {
CHECK(CcTest::heap()->InNewSpace(o->elements())); CHECK(CcTest::heap()->InNewSpace(o->elements()));
} }
static int CountMapTransitions(i::Isolate* isolate, Map* map) {
static int CountMapTransitions(Map* map) {
DisallowHeapAllocation no_gc; DisallowHeapAllocation no_gc;
return TransitionsAccessor(map, &no_gc).NumberOfTransitions(); return TransitionsAccessor(isolate, map, &no_gc).NumberOfTransitions();
} }
...@@ -2720,8 +2719,10 @@ TEST(Regress1465) { ...@@ -2720,8 +2719,10 @@ TEST(Regress1465) {
FLAG_trace_incremental_marking = true; FLAG_trace_incremental_marking = true;
FLAG_retain_maps_for_n_gc = 0; FLAG_retain_maps_for_n_gc = 0;
CcTest::InitializeVM(); CcTest::InitializeVM();
v8::HandleScope scope(CcTest::isolate()); v8::Isolate* isolate = CcTest::isolate();
v8::Local<v8::Context> ctx = CcTest::isolate()->GetCurrentContext(); i::Isolate* i_isolate = CcTest::i_isolate();
v8::HandleScope scope(isolate);
v8::Local<v8::Context> ctx = isolate->GetCurrentContext();
static const int transitions_count = 256; static const int transitions_count = 256;
CompileRun("function F() {}"); CompileRun("function F() {}");
...@@ -2740,7 +2741,7 @@ TEST(Regress1465) { ...@@ -2740,7 +2741,7 @@ TEST(Regress1465) {
CcTest::global()->Get(ctx, v8_str("root")).ToLocalChecked())); CcTest::global()->Get(ctx, v8_str("root")).ToLocalChecked()));
// Count number of live transitions before marking. // Count number of live transitions before marking.
int transitions_before = CountMapTransitions(root->map()); int transitions_before = CountMapTransitions(i_isolate, root->map());
CompileRun("%DebugPrint(root);"); CompileRun("%DebugPrint(root);");
CHECK_EQ(transitions_count, transitions_before); CHECK_EQ(transitions_count, transitions_before);
...@@ -2749,7 +2750,7 @@ TEST(Regress1465) { ...@@ -2749,7 +2750,7 @@ TEST(Regress1465) {
// Count number of live transitions after marking. Note that one transition // Count number of live transitions after marking. Note that one transition
// is left, because 'o' still holds an instance of one transition target. // is left, because 'o' still holds an instance of one transition target.
int transitions_after = CountMapTransitions(root->map()); int transitions_after = CountMapTransitions(i_isolate, root->map());
CompileRun("%DebugPrint(root);"); CompileRun("%DebugPrint(root);");
CHECK_EQ(1, transitions_after); CHECK_EQ(1, transitions_after);
} }
...@@ -2796,6 +2797,7 @@ TEST(TransitionArrayShrinksDuringAllocToZero) { ...@@ -2796,6 +2797,7 @@ TEST(TransitionArrayShrinksDuringAllocToZero) {
FLAG_stress_incremental_marking = false; FLAG_stress_incremental_marking = false;
FLAG_allow_natives_syntax = true; FLAG_allow_natives_syntax = true;
CcTest::InitializeVM(); CcTest::InitializeVM();
i::Isolate* i_isolate = CcTest::i_isolate();
v8::HandleScope scope(CcTest::isolate()); v8::HandleScope scope(CcTest::isolate());
static const int transitions_count = 10; static const int transitions_count = 10;
CompileRun("function F() { }"); CompileRun("function F() { }");
...@@ -2804,7 +2806,7 @@ TEST(TransitionArrayShrinksDuringAllocToZero) { ...@@ -2804,7 +2806,7 @@ TEST(TransitionArrayShrinksDuringAllocToZero) {
Handle<JSObject> root = GetByName("root"); Handle<JSObject> root = GetByName("root");
// Count number of live transitions before marking. // Count number of live transitions before marking.
int transitions_before = CountMapTransitions(root->map()); int transitions_before = CountMapTransitions(i_isolate, root->map());
CHECK_EQ(transitions_count, transitions_before); CHECK_EQ(transitions_count, transitions_before);
// Get rid of o // Get rid of o
...@@ -2816,8 +2818,8 @@ TEST(TransitionArrayShrinksDuringAllocToZero) { ...@@ -2816,8 +2818,8 @@ TEST(TransitionArrayShrinksDuringAllocToZero) {
// Count number of live transitions after marking. Note that one transition // Count number of live transitions after marking. Note that one transition
// is left, because 'o' still holds an instance of one transition target. // is left, because 'o' still holds an instance of one transition target.
int transitions_after = CountMapTransitions( int transitions_after =
Map::cast(root->map()->GetBackPointer())); CountMapTransitions(i_isolate, Map::cast(root->map()->GetBackPointer()));
CHECK_EQ(1, transitions_after); CHECK_EQ(1, transitions_after);
} }
...@@ -2827,6 +2829,7 @@ TEST(TransitionArrayShrinksDuringAllocToOne) { ...@@ -2827,6 +2829,7 @@ TEST(TransitionArrayShrinksDuringAllocToOne) {
FLAG_stress_incremental_marking = false; FLAG_stress_incremental_marking = false;
FLAG_allow_natives_syntax = true; FLAG_allow_natives_syntax = true;
CcTest::InitializeVM(); CcTest::InitializeVM();
i::Isolate* i_isolate = CcTest::i_isolate();
v8::HandleScope scope(CcTest::isolate()); v8::HandleScope scope(CcTest::isolate());
static const int transitions_count = 10; static const int transitions_count = 10;
CompileRun("function F() {}"); CompileRun("function F() {}");
...@@ -2835,7 +2838,7 @@ TEST(TransitionArrayShrinksDuringAllocToOne) { ...@@ -2835,7 +2838,7 @@ TEST(TransitionArrayShrinksDuringAllocToOne) {
Handle<JSObject> root = GetByName("root"); Handle<JSObject> root = GetByName("root");
// Count number of live transitions before marking. // Count number of live transitions before marking.
int transitions_before = CountMapTransitions(root->map()); int transitions_before = CountMapTransitions(i_isolate, root->map());
CHECK_EQ(transitions_count, transitions_before); CHECK_EQ(transitions_count, transitions_before);
root = GetByName("root"); root = GetByName("root");
...@@ -2844,8 +2847,8 @@ TEST(TransitionArrayShrinksDuringAllocToOne) { ...@@ -2844,8 +2847,8 @@ TEST(TransitionArrayShrinksDuringAllocToOne) {
// Count number of live transitions after marking. Note that one transition // Count number of live transitions after marking. Note that one transition
// is left, because 'o' still holds an instance of one transition target. // is left, because 'o' still holds an instance of one transition target.
int transitions_after = CountMapTransitions( int transitions_after =
Map::cast(root->map()->GetBackPointer())); CountMapTransitions(i_isolate, Map::cast(root->map()->GetBackPointer()));
CHECK_EQ(2, transitions_after); CHECK_EQ(2, transitions_after);
} }
...@@ -2855,6 +2858,7 @@ TEST(TransitionArrayShrinksDuringAllocToOnePropertyFound) { ...@@ -2855,6 +2858,7 @@ TEST(TransitionArrayShrinksDuringAllocToOnePropertyFound) {
FLAG_stress_incremental_marking = false; FLAG_stress_incremental_marking = false;
FLAG_allow_natives_syntax = true; FLAG_allow_natives_syntax = true;
CcTest::InitializeVM(); CcTest::InitializeVM();
i::Isolate* i_isolate = CcTest::i_isolate();
v8::HandleScope scope(CcTest::isolate()); v8::HandleScope scope(CcTest::isolate());
static const int transitions_count = 10; static const int transitions_count = 10;
CompileRun("function F() {}"); CompileRun("function F() {}");
...@@ -2863,7 +2867,7 @@ TEST(TransitionArrayShrinksDuringAllocToOnePropertyFound) { ...@@ -2863,7 +2867,7 @@ TEST(TransitionArrayShrinksDuringAllocToOnePropertyFound) {
Handle<JSObject> root = GetByName("root"); Handle<JSObject> root = GetByName("root");
// Count number of live transitions before marking. // Count number of live transitions before marking.
int transitions_before = CountMapTransitions(root->map()); int transitions_before = CountMapTransitions(i_isolate, root->map());
CHECK_EQ(transitions_count, transitions_before); CHECK_EQ(transitions_count, transitions_before);
root = GetByName("root"); root = GetByName("root");
...@@ -2872,8 +2876,8 @@ TEST(TransitionArrayShrinksDuringAllocToOnePropertyFound) { ...@@ -2872,8 +2876,8 @@ TEST(TransitionArrayShrinksDuringAllocToOnePropertyFound) {
// Count number of live transitions after marking. Note that one transition // Count number of live transitions after marking. Note that one transition
// is left, because 'o' still holds an instance of one transition target. // is left, because 'o' still holds an instance of one transition target.
int transitions_after = CountMapTransitions( int transitions_after =
Map::cast(root->map()->GetBackPointer())); CountMapTransitions(i_isolate, Map::cast(root->map()->GetBackPointer()));
CHECK_EQ(1, transitions_after); CHECK_EQ(1, transitions_after);
} }
#endif // DEBUG #endif // DEBUG
......
...@@ -909,7 +909,7 @@ TEST(TransitionLookup) { ...@@ -909,7 +909,7 @@ TEST(TransitionLookup) {
// Ensure we didn't overflow transition array and therefore all the // Ensure we didn't overflow transition array and therefore all the
// combinations of cases are covered. // combinations of cases are covered.
CHECK(TransitionsAccessor(root_map).CanHaveMoreTransitions()); CHECK(TransitionsAccessor(isolate, root_map).CanHaveMoreTransitions());
// Now try querying keys. // Now try querying keys.
bool positive_lookup_tested = false; bool positive_lookup_tested = false;
......
...@@ -397,8 +397,8 @@ class Expectations { ...@@ -397,8 +397,8 @@ class Expectations {
heap_type); heap_type);
Handle<String> name = MakeName("prop", property_index); Handle<String> name = MakeName("prop", property_index);
Map* target = Map* target = TransitionsAccessor(isolate_, map)
TransitionsAccessor(map).SearchTransition(*name, kData, attributes); .SearchTransition(*name, kData, attributes);
CHECK_NOT_NULL(target); CHECK_NOT_NULL(target);
return handle(target); return handle(target);
} }
...@@ -2153,8 +2153,8 @@ TEST(ReconfigurePropertySplitMapTransitionsOverflow) { ...@@ -2153,8 +2153,8 @@ TEST(ReconfigurePropertySplitMapTransitionsOverflow) {
} }
Handle<String> name = MakeName("prop", i); Handle<String> name = MakeName("prop", i);
Map* target = Map* target = TransitionsAccessor(isolate, map2)
TransitionsAccessor(map2).SearchTransition(*name, kData, NONE); .SearchTransition(*name, kData, NONE);
CHECK_NOT_NULL(target); CHECK_NOT_NULL(target);
map2 = handle(target); map2 = handle(target);
} }
...@@ -2177,13 +2177,13 @@ TEST(ReconfigurePropertySplitMapTransitionsOverflow) { ...@@ -2177,13 +2177,13 @@ TEST(ReconfigurePropertySplitMapTransitionsOverflow) {
// Fill in transition tree of |map2| so that it can't have more transitions. // Fill in transition tree of |map2| so that it can't have more transitions.
for (int i = 0; i < TransitionsAccessor::kMaxNumberOfTransitions; i++) { for (int i = 0; i < TransitionsAccessor::kMaxNumberOfTransitions; i++) {
CHECK(TransitionsAccessor(map2).CanHaveMoreTransitions()); CHECK(TransitionsAccessor(isolate, map2).CanHaveMoreTransitions());
Handle<String> name = MakeName("foo", i); Handle<String> name = MakeName("foo", i);
Map::CopyWithField(map2, name, any_type, NONE, PropertyConstness::kMutable, Map::CopyWithField(map2, name, any_type, NONE, PropertyConstness::kMutable,
Representation::Smi(), INSERT_TRANSITION) Representation::Smi(), INSERT_TRANSITION)
.ToHandleChecked(); .ToHandleChecked();
} }
CHECK(!TransitionsAccessor(map2).CanHaveMoreTransitions()); CHECK(!TransitionsAccessor(isolate, map2).CanHaveMoreTransitions());
// Try to update |map|, since there is no place for propX transition at |map2| // Try to update |map|, since there is no place for propX transition at |map2|
// |map| should become "copy-generalized". // |map| should become "copy-generalized".
......
...@@ -45,11 +45,11 @@ TEST(TransitionArray_SimpleFieldTransitions) { ...@@ -45,11 +45,11 @@ TEST(TransitionArray_SimpleFieldTransitions) {
CHECK(map0->raw_transitions()->IsSmi()); CHECK(map0->raw_transitions()->IsSmi());
{ {
TestTransitionsAccessor transitions(map0); TestTransitionsAccessor transitions(isolate, map0);
transitions.Insert(name1, map1, SIMPLE_PROPERTY_TRANSITION); transitions.Insert(name1, map1, SIMPLE_PROPERTY_TRANSITION);
} }
{ {
TestTransitionsAccessor transitions(map0); TestTransitionsAccessor transitions(isolate, map0);
CHECK(transitions.IsWeakRefEncoding()); CHECK(transitions.IsWeakRefEncoding());
CHECK_EQ(*map1, transitions.SearchTransition(*name1, kData, attributes)); CHECK_EQ(*map1, transitions.SearchTransition(*name1, kData, attributes));
CHECK_EQ(1, transitions.NumberOfTransitions()); CHECK_EQ(1, transitions.NumberOfTransitions());
...@@ -59,7 +59,7 @@ TEST(TransitionArray_SimpleFieldTransitions) { ...@@ -59,7 +59,7 @@ TEST(TransitionArray_SimpleFieldTransitions) {
transitions.Insert(name2, map2, SIMPLE_PROPERTY_TRANSITION); transitions.Insert(name2, map2, SIMPLE_PROPERTY_TRANSITION);
} }
{ {
TestTransitionsAccessor transitions(map0); TestTransitionsAccessor transitions(isolate, map0);
CHECK(transitions.IsFullTransitionArrayEncoding()); CHECK(transitions.IsFullTransitionArrayEncoding());
CHECK_EQ(*map1, transitions.SearchTransition(*name1, kData, attributes)); CHECK_EQ(*map1, transitions.SearchTransition(*name1, kData, attributes));
...@@ -102,11 +102,11 @@ TEST(TransitionArray_FullFieldTransitions) { ...@@ -102,11 +102,11 @@ TEST(TransitionArray_FullFieldTransitions) {
CHECK(map0->raw_transitions()->IsSmi()); CHECK(map0->raw_transitions()->IsSmi());
{ {
TestTransitionsAccessor transitions(map0); TestTransitionsAccessor transitions(isolate, map0);
transitions.Insert(name1, map1, PROPERTY_TRANSITION); transitions.Insert(name1, map1, PROPERTY_TRANSITION);
} }
{ {
TestTransitionsAccessor transitions(map0); TestTransitionsAccessor transitions(isolate, map0);
CHECK(transitions.IsFullTransitionArrayEncoding()); CHECK(transitions.IsFullTransitionArrayEncoding());
CHECK_EQ(*map1, transitions.SearchTransition(*name1, kData, attributes)); CHECK_EQ(*map1, transitions.SearchTransition(*name1, kData, attributes));
CHECK_EQ(1, transitions.NumberOfTransitions()); CHECK_EQ(1, transitions.NumberOfTransitions());
...@@ -116,7 +116,7 @@ TEST(TransitionArray_FullFieldTransitions) { ...@@ -116,7 +116,7 @@ TEST(TransitionArray_FullFieldTransitions) {
transitions.Insert(name2, map2, PROPERTY_TRANSITION); transitions.Insert(name2, map2, PROPERTY_TRANSITION);
} }
{ {
TestTransitionsAccessor transitions(map0); TestTransitionsAccessor transitions(isolate, map0);
CHECK(transitions.IsFullTransitionArrayEncoding()); CHECK(transitions.IsFullTransitionArrayEncoding());
CHECK_EQ(*map1, transitions.SearchTransition(*name1, kData, attributes)); CHECK_EQ(*map1, transitions.SearchTransition(*name1, kData, attributes));
...@@ -160,10 +160,10 @@ TEST(TransitionArray_DifferentFieldNames) { ...@@ -160,10 +160,10 @@ TEST(TransitionArray_DifferentFieldNames) {
names[i] = name; names[i] = name;
maps[i] = map; maps[i] = map;
TransitionsAccessor(map0).Insert(name, map, PROPERTY_TRANSITION); TransitionsAccessor(isolate, map0).Insert(name, map, PROPERTY_TRANSITION);
} }
TransitionsAccessor transitions(map0); TransitionsAccessor transitions(isolate, map0);
for (int i = 0; i < PROPS_COUNT; i++) { for (int i = 0; i < PROPS_COUNT; i++) {
CHECK_EQ(*maps[i], CHECK_EQ(*maps[i],
transitions.SearchTransition(*names[i], kData, attributes)); transitions.SearchTransition(*names[i], kData, attributes));
...@@ -208,11 +208,11 @@ TEST(TransitionArray_SameFieldNamesDifferentAttributesSimple) { ...@@ -208,11 +208,11 @@ TEST(TransitionArray_SameFieldNamesDifferentAttributesSimple) {
.ToHandleChecked(); .ToHandleChecked();
attr_maps[i] = map; attr_maps[i] = map;
TransitionsAccessor(map0).Insert(name, map, PROPERTY_TRANSITION); TransitionsAccessor(isolate, map0).Insert(name, map, PROPERTY_TRANSITION);
} }
// Ensure that transitions for |name| field are valid. // Ensure that transitions for |name| field are valid.
TransitionsAccessor transitions(map0); TransitionsAccessor transitions(isolate, map0);
for (int i = 0; i < ATTRS_COUNT; i++) { for (int i = 0; i < ATTRS_COUNT; i++) {
PropertyAttributes attributes = static_cast<PropertyAttributes>(i); PropertyAttributes attributes = static_cast<PropertyAttributes>(i);
CHECK_EQ(*attr_maps[i], CHECK_EQ(*attr_maps[i],
...@@ -252,7 +252,7 @@ TEST(TransitionArray_SameFieldNamesDifferentAttributes) { ...@@ -252,7 +252,7 @@ TEST(TransitionArray_SameFieldNamesDifferentAttributes) {
names[i] = name; names[i] = name;
maps[i] = map; maps[i] = map;
TransitionsAccessor(map0).Insert(name, map, PROPERTY_TRANSITION); TransitionsAccessor(isolate, map0).Insert(name, map, PROPERTY_TRANSITION);
} }
const int ATTRS_COUNT = (READ_ONLY | DONT_ENUM | DONT_DELETE) + 1; const int ATTRS_COUNT = (READ_ONLY | DONT_ENUM | DONT_DELETE) + 1;
...@@ -271,11 +271,11 @@ TEST(TransitionArray_SameFieldNamesDifferentAttributes) { ...@@ -271,11 +271,11 @@ TEST(TransitionArray_SameFieldNamesDifferentAttributes) {
.ToHandleChecked(); .ToHandleChecked();
attr_maps[i] = map; attr_maps[i] = map;
TransitionsAccessor(map0).Insert(name, map, PROPERTY_TRANSITION); TransitionsAccessor(isolate, map0).Insert(name, map, PROPERTY_TRANSITION);
} }
// Ensure that transitions for |name| field are valid. // Ensure that transitions for |name| field are valid.
TransitionsAccessor transitions(map0); TransitionsAccessor transitions(isolate, map0);
for (int i = 0; i < ATTRS_COUNT; i++) { for (int i = 0; i < ATTRS_COUNT; i++) {
PropertyAttributes attr = static_cast<PropertyAttributes>(i); PropertyAttributes attr = static_cast<PropertyAttributes>(i);
CHECK_EQ(*attr_maps[i], transitions.SearchTransition(*name, kData, attr)); CHECK_EQ(*attr_maps[i], transitions.SearchTransition(*name, kData, attr));
......
...@@ -12,10 +12,11 @@ namespace internal { ...@@ -12,10 +12,11 @@ namespace internal {
class TestTransitionsAccessor : public TransitionsAccessor { class TestTransitionsAccessor : public TransitionsAccessor {
public: public:
TestTransitionsAccessor(Map* map, DisallowHeapAllocation* no_gc) TestTransitionsAccessor(Isolate* isolate, Map* map,
: TransitionsAccessor(map, no_gc) {} DisallowHeapAllocation* no_gc)
explicit TestTransitionsAccessor(Handle<Map> map) : TransitionsAccessor(isolate, map, no_gc) {}
: TransitionsAccessor(map) {} TestTransitionsAccessor(Isolate* isolate, Handle<Map> map)
: TransitionsAccessor(isolate, map) {}
// Expose internals for tests. // Expose internals for tests.
bool IsWeakRefEncoding() { return encoding() == kWeakRef; } bool IsWeakRefEncoding() { return encoding() == kWeakRef; }
......
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