Reviewers: rossberg,
Description:
Move runtime healper for JSSet and JSMap onto objects.
[email protected]
Please review this at https://codereview.chromium.org/1312413002/
Base URL: https://chromium.googlesource.com/v8/v8.git@master
Affected files (+42, -49 lines):
M src/api.cc
M src/factory.cc
M src/objects.h
M src/objects.cc
M src/runtime/runtime.h
M src/runtime/runtime-collections.cc
M src/runtime/runtime-typedarray.cc
Index: src/api.cc
diff --git a/src/api.cc b/src/api.cc
index
c73860f70688608df90cdea913ebe7d14513da69..22b9dafa4b1a07c739cda5b7ddc80756ce8c74bc
100644
--- a/src/api.cc
+++ b/src/api.cc
@@ -6153,7 +6153,7 @@ void Map::Clear() {
i::Isolate* isolate = self->GetIsolate();
LOG_API(isolate, "Map::Clear");
ENTER_V8(isolate);
- i::Runtime::JSMapClear(isolate, self);
+ i::JSMap::Clear(self);
}
@@ -6269,7 +6269,7 @@ void Set::Clear() {
i::Isolate* isolate = self->GetIsolate();
LOG_API(isolate, "Set::Clear");
ENTER_V8(isolate);
- i::Runtime::JSSetClear(isolate, self);
+ i::JSSet::Clear(self);
}
@@ -6535,7 +6535,7 @@ void v8::ArrayBuffer::Neuter() {
"Only neuterable ArrayBuffers can be neutered");
LOG_API(obj->GetIsolate(), "v8::ArrayBuffer::Neuter()");
ENTER_V8(isolate);
- i::Runtime::NeuterArrayBuffer(obj);
+ obj->Neuter();
}
Index: src/factory.cc
diff --git a/src/factory.cc b/src/factory.cc
index
34dfb2925ec47b9d99095d0ebf1e4dc3719b3edf..c73c9676e6398f18aceba570ea28da40ceb4251a
100644
--- a/src/factory.cc
+++ b/src/factory.cc
@@ -1633,7 +1633,7 @@ Handle<JSDataView> Factory::NewJSDataView() {
Handle<JSMap> Factory::NewJSMap() {
Handle<Map> map(isolate()->native_context()->js_map_map());
Handle<JSMap> js_map = Handle<JSMap>::cast(NewJSObjectFromMap(map));
- Runtime::JSMapInitialize(isolate(), js_map);
+ JSMap::Initialize(js_map, isolate());
return js_map;
}
@@ -1641,7 +1641,7 @@ Handle<JSMap> Factory::NewJSMap() {
Handle<JSSet> Factory::NewJSSet() {
Handle<Map> map(isolate()->native_context()->js_set_map());
Handle<JSSet> js_set = Handle<JSSet>::cast(NewJSObjectFromMap(map));
- Runtime::JSSetInitialize(isolate(), js_set);
+ JSSet::Initialize(js_set, isolate());
return js_set;
}
Index: src/objects.cc
diff --git a/src/objects.cc b/src/objects.cc
index
c9ce20e681963c98ea866d7732730a3530a4d1b9..ab32fbee15126afc589f971fba88a333190d0694
100644
--- a/src/objects.cc
+++ b/src/objects.cc
@@ -15127,6 +15127,32 @@ template void
OrderedHashTableIterator<JSMapIterator, OrderedHashMap>::Transition();
+void JSSet::Initialize(Handle<JSSet> set, Isolate* isolate) {
+ Handle<OrderedHashSet> table = isolate->factory()->NewOrderedHashSet();
+ set->set_table(*table);
+}
+
+
+void JSSet::Clear(Handle<JSSet> set) {
+ Handle<OrderedHashSet> table(OrderedHashSet::cast(set->table()));
+ table = OrderedHashSet::Clear(table);
+ set->set_table(*table);
+}
+
+
+void JSMap::Initialize(Handle<JSMap> map, Isolate* isolate) {
+ Handle<OrderedHashMap> table = isolate->factory()->NewOrderedHashMap();
+ map->set_table(*table);
+}
+
+
+void JSMap::Clear(Handle<JSMap> map) {
+ Handle<OrderedHashMap> table(OrderedHashMap::cast(map->table()));
+ table = OrderedHashMap::Clear(table);
+ map->set_table(*table);
+}
+
+
// Check if there is a break point at this code position.
bool DebugInfo::HasBreakPoint(int code_position) {
// Get the break point info object for this code position.
Index: src/objects.h
diff --git a/src/objects.h b/src/objects.h
index
f1b9219d6a90aaafb3a67a421ecd2654e7c60886..6d547ef67ac4632056cd84871b183f39cae90ffb
100644
--- a/src/objects.h
+++ b/src/objects.h
@@ -9301,6 +9301,9 @@ class JSSet : public JSCollection {
public:
DECLARE_CAST(JSSet)
+ static void Initialize(Handle<JSSet> set, Isolate* isolate);
+ static void Clear(Handle<JSSet> set);
+
// Dispatched behavior.
DECLARE_PRINTER(JSSet)
DECLARE_VERIFIER(JSSet)
@@ -9315,6 +9318,9 @@ class JSMap : public JSCollection {
public:
DECLARE_CAST(JSMap)
+ static void Initialize(Handle<JSMap> map, Isolate* isolate);
+ static void Clear(Handle<JSMap> map);
+
// Dispatched behavior.
DECLARE_PRINTER(JSMap)
DECLARE_VERIFIER(JSMap)
Index: src/runtime/runtime-collections.cc
diff --git a/src/runtime/runtime-collections.cc
b/src/runtime/runtime-collections.cc
index
3450fca0e2541f13b96442d6781aee80e4ad5138..0dfa1ee30464acef28d31d2f28d6613dbb55c1d7
100644
--- a/src/runtime/runtime-collections.cc
+++ b/src/runtime/runtime-collections.cc
@@ -45,17 +45,11 @@ RUNTIME_FUNCTION(Runtime_GenericHash) {
}
-void Runtime::JSSetInitialize(Isolate* isolate, Handle<JSSet> set) {
- Handle<OrderedHashSet> table = isolate->factory()->NewOrderedHashSet();
- set->set_table(*table);
-}
-
-
RUNTIME_FUNCTION(Runtime_SetInitialize) {
HandleScope scope(isolate);
DCHECK(args.length() == 1);
CONVERT_ARG_HANDLE_CHECKED(JSSet, holder, 0);
- Runtime::JSSetInitialize(isolate, holder);
+ JSSet::Initialize(holder, isolate);
return *holder;
}
@@ -82,18 +76,11 @@ RUNTIME_FUNCTION(Runtime_SetShrink) {
}
-void Runtime::JSSetClear(Isolate* isolate, Handle<JSSet> set) {
- Handle<OrderedHashSet> table(OrderedHashSet::cast(set->table()));
- table = OrderedHashSet::Clear(table);
- set->set_table(*table);
-}
-
-
RUNTIME_FUNCTION(Runtime_SetClear) {
HandleScope scope(isolate);
DCHECK(args.length() == 1);
CONVERT_ARG_HANDLE_CHECKED(JSSet, holder, 0);
- Runtime::JSSetClear(isolate, holder);
+ JSSet::Clear(holder);
return isolate->heap()->undefined_value();
}
@@ -153,17 +140,11 @@ RUNTIME_FUNCTION(Runtime_SetIteratorDetails) {
}
-void Runtime::JSMapInitialize(Isolate* isolate, Handle<JSMap> map) {
- Handle<OrderedHashMap> table = isolate->factory()->NewOrderedHashMap();
- map->set_table(*table);
-}
-
-
RUNTIME_FUNCTION(Runtime_MapInitialize) {
HandleScope scope(isolate);
DCHECK(args.length() == 1);
CONVERT_ARG_HANDLE_CHECKED(JSMap, holder, 0);
- Runtime::JSMapInitialize(isolate, holder);
+ JSMap::Initialize(holder, isolate);
return *holder;
}
@@ -179,18 +160,11 @@ RUNTIME_FUNCTION(Runtime_MapShrink) {
}
-void Runtime::JSMapClear(Isolate* isolate, Handle<JSMap> map) {
- Handle<OrderedHashMap> table(OrderedHashMap::cast(map->table()));
- table = OrderedHashMap::Clear(table);
- map->set_table(*table);
-}
-
-
RUNTIME_FUNCTION(Runtime_MapClear) {
HandleScope scope(isolate);
DCHECK(args.length() == 1);
CONVERT_ARG_HANDLE_CHECKED(JSMap, holder, 0);
- Runtime::JSMapClear(isolate, holder);
+ JSMap::Clear(holder);
return isolate->heap()->undefined_value();
}
Index: src/runtime/runtime-typedarray.cc
diff --git a/src/runtime/runtime-typedarray.cc
b/src/runtime/runtime-typedarray.cc
index
ffa412090367f530291059b737f8203b537cdd69..4acdba3fc6e1b52fd8ae258d05ae4ce68c0120a3
100644
--- a/src/runtime/runtime-typedarray.cc
+++ b/src/runtime/runtime-typedarray.cc
@@ -67,11 +67,6 @@ bool Runtime::SetupArrayBufferAllocatingData(Isolate*
isolate,
}
-void Runtime::NeuterArrayBuffer(Handle<JSArrayBuffer> array_buffer) {
- array_buffer->Neuter();
-}
-
-
RUNTIME_FUNCTION(Runtime_ArrayBufferInitialize) {
HandleScope scope(isolate);
DCHECK(args.length() == 3);
@@ -150,7 +145,7 @@ RUNTIME_FUNCTION(Runtime_ArrayBufferNeuter) {
void* backing_store = array_buffer->backing_store();
size_t byte_length = NumberToSize(isolate, array_buffer->byte_length());
array_buffer->set_is_external(true);
- Runtime::NeuterArrayBuffer(array_buffer);
+ array_buffer->Neuter();
isolate->heap()->UnregisterArrayBuffer(
isolate->heap()->InNewSpace(*array_buffer), backing_store);
isolate->array_buffer_allocator()->Free(backing_store, byte_length);
Index: src/runtime/runtime.h
diff --git a/src/runtime/runtime.h b/src/runtime/runtime.h
index
8e2bba61c3a1a0a1edc312feaba8324692bda4d7..f0a3d452d92f13a2199d83693b046fed626da148
100644
--- a/src/runtime/runtime.h
+++ b/src/runtime/runtime.h
@@ -1167,8 +1167,6 @@ class Runtime : public AllStatic {
size_t allocated_length, bool initialize = true,
SharedFlag shared = SharedFlag::kNotShared);
- static void NeuterArrayBuffer(Handle<JSArrayBuffer> array_buffer);
-
enum TypedArrayId {
// arrayIds below should be synchromized with typedarray.js natives.
ARRAY_ID_UINT8 = 1,
@@ -1193,12 +1191,6 @@ class Runtime : public AllStatic {
Isolate* isolate, Handle<FixedArray> literals,
Handle<FixedArray> elements, bool is_strong);
-
- static void JSMapInitialize(Isolate* isolate, Handle<JSMap> map);
- static void JSMapClear(Isolate* isolate, Handle<JSMap> map);
- static void JSSetInitialize(Isolate* isolate, Handle<JSSet> set);
- static void JSSetClear(Isolate* isolate, Handle<JSSet> set);
-
static void WeakCollectionInitialize(
Isolate* isolate, Handle<JSWeakCollection> weak_collection);
static void WeakCollectionSet(Handle<JSWeakCollection> weak_collection,
--
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
---
You received this message because you are subscribed to the Google Groups "v8-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.