Reviewers: danno,
Message:
PTAL
Description:
Allow objects with "" properties to stay fast.
Please review this at https://codereview.chromium.org/184453003/
SVN Base: https://v8.googlecode.com/svn/branches/bleeding_edge
Affected files (+28, -12 lines):
M include/v8.h
M src/heap.h
M src/heap.cc
M src/objects.cc
M src/runtime.h
M src/runtime.cc
M src/stub-cache.cc
A + test/mjsunit/test-hidden-string.js
Index: include/v8.h
diff --git a/include/v8.h b/include/v8.h
index
dd8f2685bc37115638f5332ddbefd42a79c16cea..1bbc68e4a0a9336cc3614355acc9aaab042b8b9b
100644
--- a/include/v8.h
+++ b/include/v8.h
@@ -5414,7 +5414,7 @@ class Internals {
static const int kNullValueRootIndex = 7;
static const int kTrueValueRootIndex = 8;
static const int kFalseValueRootIndex = 9;
- static const int kEmptyStringRootIndex = 141;
+ static const int kEmptyStringRootIndex = 142;
static const int kNodeClassIdOffset = 1 * kApiPointerSize;
static const int kNodeFlagsOffset = 1 * kApiPointerSize + 3;
Index: src/heap.cc
diff --git a/src/heap.cc b/src/heap.cc
index
42e56ca1eb9e2bb40498d9ea2d341c71a67f6b4e..8b94dbe0000893d49a8c0776fe05138a97ee4f0d
100644
--- a/src/heap.cc
+++ b/src/heap.cc
@@ -3307,6 +3307,12 @@ bool Heap::CreateInitialObjects() {
if (!maybe_obj->ToObject(&obj)) return false;
}
Symbol::cast(obj)->set_is_private(true);
+ set_nonexistent_symbol(Symbol::cast(obj));
+
+ { MaybeObject* maybe_obj = AllocateSymbol();
+ if (!maybe_obj->ToObject(&obj)) return false;
+ }
+ Symbol::cast(obj)->set_is_private(true);
set_elements_transition_symbol(Symbol::cast(obj));
{ MaybeObject* maybe_obj = SeededNumberDictionary::Allocate(this, 0,
TENURED);
Index: src/heap.h
diff --git a/src/heap.h b/src/heap.h
index
1ac4dfaa0808848947834983bd862aa0fc9f44d2..e2c42ddd5974f721b7f1c39876bf373dce950aa9
100644
--- a/src/heap.h
+++ b/src/heap.h
@@ -191,6 +191,7 @@ namespace internal {
V(JSObject, observation_state,
ObservationState) \
V(Map, external_map,
ExternalMap) \
V(Symbol, frozen_symbol,
FrozenSymbol) \
+ V(Symbol, nonexistent_symbol,
NonExistentSymbol) \
V(Symbol, elements_transition_symbol,
ElementsTransitionSymbol) \
V(SeededNumberDictionary,
empty_slow_element_dictionary, \
EmptySlowElementDictionary) \
Index: src/objects.cc
diff --git a/src/objects.cc b/src/objects.cc
index
aa6e2808b46d283c5178cbff07f05da6db8ebdbd..1e8bc0c7a1d3ffe9d8f7b7c6967a4d3d02bf296c
100644
--- a/src/objects.cc
+++ b/src/objects.cc
@@ -8237,7 +8237,7 @@ static bool IsIdentifier(UnicodeCache* cache, Name*
name) {
// Checks whether the buffer contains an identifier (no escape).
if (!name->IsString()) return false;
String* string = String::cast(name);
- if (string->length() == 0) return false;
+ if (string->length() == 0) return true;
ConsStringIteratorOp op;
StringCharacterStream stream(string, &op);
if (!cache->IsIdentifierStart(stream.GetNext())) {
@@ -8253,9 +8253,7 @@ static bool IsIdentifier(UnicodeCache* cache, Name*
name) {
bool Name::IsCacheable(Isolate* isolate) {
- return IsSymbol() ||
- IsIdentifier(isolate->unicode_cache(), this) ||
- this == isolate->heap()->hidden_string();
+ return IsSymbol() || IsIdentifier(isolate->unicode_cache(), this);
}
@@ -15719,7 +15717,6 @@ MaybeObject*
NameDictionary::TransformPropertiesToFastFor(
// instance descriptor.
MaybeObject* maybe_key = heap->InternalizeString(String::cast(k));
if (!maybe_key->To(&key)) return maybe_key;
- if (key->Equals(heap->empty_string())) return this;
}
PropertyDetails details = DetailsAt(i);
Index: src/runtime.cc
diff --git a/src/runtime.cc b/src/runtime.cc
index
0caaa47bd57f79ba52b8b46959a590c9fe918041..8e045584864014802ebbd8872df85318e967f6b7
100644
--- a/src/runtime.cc
+++ b/src/runtime.cc
@@ -5356,6 +5356,17 @@ MaybeObject* Runtime::DeleteObjectProperty(Isolate*
isolate,
}
+RUNTIME_FUNCTION(MaybeObject*, Runtime_SetHiddenProperty) {
+ HandleScope scope(isolate);
+ RUNTIME_ASSERT(args.length() == 3);
+
+ CONVERT_ARG_HANDLE_CHECKED(JSObject, object, 0);
+ CONVERT_ARG_HANDLE_CHECKED(String, key, 1);
+ CONVERT_ARG_HANDLE_CHECKED(Object, value, 2);
+ return *JSObject::SetHiddenProperty(object, key, value);
+}
+
+
RUNTIME_FUNCTION(MaybeObject*, Runtime_SetProperty) {
HandleScope scope(isolate);
RUNTIME_ASSERT(args.length() == 4 || args.length() == 5);
Index: src/runtime.h
diff --git a/src/runtime.h b/src/runtime.h
index
823285fd37661bad76a15483a06cc104b680512b..bd24c3b38e3be9a617c3fcdb7a9d7470f4e8ae2e
100644
--- a/src/runtime.h
+++ b/src/runtime.h
@@ -285,6 +285,7 @@ namespace internal {
F(DefineOrRedefineAccessorProperty, 5, 1) \
F(IgnoreAttributesAndSetProperty, -1 /* 3 or 4 */, 1) \
F(GetDataProperty, 2, 1) \
+ F(SetHiddenProperty, 3, 1) \
\
/* Arrays */ \
F(RemoveArrayHoles, 2, 1) \
Index: src/stub-cache.cc
diff --git a/src/stub-cache.cc b/src/stub-cache.cc
index
f23e5aaeb355d167790e6a22369d5b2b80db23ff..64d7d65d028ef3b6c027fafe43acab89686a8668
100644
--- a/src/stub-cache.cc
+++ b/src/stub-cache.cc
@@ -179,7 +179,7 @@ Handle<Code>
StubCache::ComputeLoadNonexistent(Handle<Name> name,
// therefore the stub will be specific to the name.
Handle<Map> current_map = stub_holder;
Handle<Name> cache_name = current_map->is_dictionary_map()
- ? name : Handle<Name>::cast(isolate()->factory()->empty_string());
+ ? name :
Handle<Name>::cast(isolate()->factory()->nonexistent_symbol());
Handle<Object> next(current_map->prototype(), isolate());
Handle<JSObject> last = Handle<JSObject>::null();
while (!next->IsNull()) {
Index: test/mjsunit/test-hidden-string.js
diff --git a/test/mjsunit/regress/regress-347542.js
b/test/mjsunit/test-hidden-string.js
similarity index 58%
copy from test/mjsunit/regress/regress-347542.js
copy to test/mjsunit/test-hidden-string.js
index
901d798fb7fbea45f0d9f3d8ba6c7a9846bf6dd6..a5d32c839ea38e08abedc2d95542009accdec36c
100644
--- a/test/mjsunit/regress/regress-347542.js
+++ b/test/mjsunit/test-hidden-string.js
@@ -4,8 +4,8 @@
// Flags: --allow-natives-syntax
-function foo() {}
-foo();
-%OptimizeFunctionOnNextCall(foo);
-foo();
-%NeverOptimizeFunction(foo);
+var o = {};
+%SetHiddenProperty(o, "test", 1);
+// Create non-internalized ""
+var empty = "a".substring(1, 1);
+assertEquals(undefined, o[empty]);
--
--
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/groups/opt_out.