From 79417664b2ef50f4224b660c5514591b1e94514f Mon Sep 17 00:00:00 2001 From: dcarney Date: Wed, 11 Feb 2015 01:28:06 -0800 Subject: [PATCH] remove undetectable strings BUG= Review URL: https://codereview.chromium.org/916753002 Cr-Commit-Position: refs/heads/master@{#26571} --- include/v8.h | 6 +-- src/api.cc | 5 +- src/heap/heap.cc | 6 --- src/heap/heap.h | 2 - src/objects.cc | 17 ------- src/objects.h | 4 -- test/cctest/test-api.cc | 74 ----------------------------- tools/v8heapconst.py | 122 ++++++++++++++++++++++++------------------------ 8 files changed, 63 insertions(+), 173 deletions(-) diff --git a/include/v8.h b/include/v8.h index 28b140e..6f4268f 100644 --- a/include/v8.h +++ b/include/v8.h @@ -2130,9 +2130,7 @@ class V8_EXPORT String : public Name { V8_INLINE static String* Cast(v8::Value* obj); - enum NewStringType { - kNormalString, kInternalizedString, kUndetectableString - }; + enum NewStringType { kNormalString, kInternalizedString }; /** Allocates a new string from UTF-8 data.*/ static Local NewFromUtf8(Isolate* isolate, @@ -6256,7 +6254,7 @@ class Internals { static const int kNullValueRootIndex = 7; static const int kTrueValueRootIndex = 8; static const int kFalseValueRootIndex = 9; - static const int kEmptyStringRootIndex = 156; + static const int kEmptyStringRootIndex = 154; // The external allocation limit should be below 256 MB on all architectures // to avoid that resource-constrained embedders run low on memory. diff --git a/src/api.cc b/src/api.cc index 304d880..8716b4a 100644 --- a/src/api.cc +++ b/src/api.cc @@ -5432,7 +5432,7 @@ inline Local NewString(Isolate* v8_isolate, int length) { i::Isolate* isolate = reinterpret_cast(v8_isolate); LOG_API(isolate, env); - if (length == 0 && type != String::kUndetectableString) { + if (length == 0) { return String::Empty(v8_isolate); } ENTER_V8(isolate); @@ -5442,9 +5442,6 @@ inline Local NewString(Isolate* v8_isolate, isolate->factory(), type, i::Vector(data, length)).ToHandleChecked(); - if (type == String::kUndetectableString) { - result->MarkAsUndetectable(); - } return Utils::ToLocal(result); } diff --git a/src/heap/heap.cc b/src/heap/heap.cc index 523b819..8feec8f 100644 --- a/src/heap/heap.cc +++ b/src/heap/heap.cc @@ -2716,12 +2716,6 @@ bool Heap::CreateInitialMaps() { set_native_source_string_map(Map::cast(obj)); } - ALLOCATE_VARSIZE_MAP(STRING_TYPE, undetectable_string) - undetectable_string_map()->set_is_undetectable(); - - ALLOCATE_VARSIZE_MAP(ONE_BYTE_STRING_TYPE, undetectable_one_byte_string); - undetectable_one_byte_string_map()->set_is_undetectable(); - ALLOCATE_VARSIZE_MAP(FIXED_DOUBLE_ARRAY_TYPE, fixed_double_array) ALLOCATE_VARSIZE_MAP(BYTE_ARRAY_TYPE, byte_array) ALLOCATE_VARSIZE_MAP(FREE_SPACE_TYPE, free_space) diff --git a/src/heap/heap.h b/src/heap/heap.h index 8988578..e7b8e79 100644 --- a/src/heap/heap.h +++ b/src/heap/heap.h @@ -102,8 +102,6 @@ namespace internal { V(Map, short_external_one_byte_internalized_string_map, \ ShortExternalOneByteInternalizedStringMap) \ V(Map, short_external_one_byte_string_map, ShortExternalOneByteStringMap) \ - V(Map, undetectable_string_map, UndetectableStringMap) \ - V(Map, undetectable_one_byte_string_map, UndetectableOneByteStringMap) \ V(Map, external_int8_array_map, ExternalInt8ArrayMap) \ V(Map, external_uint8_array_map, ExternalUint8ArrayMap) \ V(Map, external_int16_array_map, ExternalInt16ArrayMap) \ diff --git a/src/objects.cc b/src/objects.cc index bc4fb1b..24bd9b8 100644 --- a/src/objects.cc +++ b/src/objects.cc @@ -9168,23 +9168,6 @@ bool String::SlowEquals(Handle one, Handle two) { } -bool String::MarkAsUndetectable() { - if (StringShape(this).IsInternalized()) return false; - - Map* map = this->map(); - Heap* heap = GetHeap(); - if (map == heap->string_map()) { - this->set_map(heap->undetectable_string_map()); - return true; - } else if (map == heap->one_byte_string_map()) { - this->set_map(heap->undetectable_one_byte_string_map()); - return true; - } - // Rest cannot be marked as undetectable - return false; -} - - bool String::IsUtf8EqualTo(Vector str, bool allow_prefix_match) { int slen = length(); // Can't check exact length equality, but we can check bounds. diff --git a/src/objects.h b/src/objects.h index 5fa64cb..a86e6b1 100644 --- a/src/objects.h +++ b/src/objects.h @@ -8984,10 +8984,6 @@ class String: public Name { // Requires: StringShape(this).IsIndirect() && this->IsFlat() inline String* GetUnderlying(); - // Mark the string as an undetectable object. It only applies to - // one-byte and two-byte string types. - bool MarkAsUndetectable(); - // String equality operations. inline bool Equals(String* other); inline static bool Equals(Handle one, Handle two); diff --git a/test/cctest/test-api.cc b/test/cctest/test-api.cc index 5d07cd8..95a64a9 100644 --- a/test/cctest/test-api.cc +++ b/test/cctest/test-api.cc @@ -5775,80 +5775,6 @@ THREADED_TEST(ExtensibleOnUndetectable) { } -THREADED_TEST(UndetectableString) { - LocalContext env; - v8::HandleScope scope(env->GetIsolate()); - - Local obj = String::NewFromUtf8(env->GetIsolate(), "foo", - String::kUndetectableString); - env->Global()->Set(v8_str("undetectable"), obj); - - ExpectString("undetectable", "foo"); - ExpectString("typeof undetectable", "undefined"); - ExpectString("typeof(undetectable)", "undefined"); - ExpectBoolean("typeof undetectable == 'undefined'", true); - ExpectBoolean("typeof undetectable == 'string'", false); - ExpectBoolean("if (undetectable) { true; } else { false; }", false); - ExpectBoolean("!undetectable", true); - - ExpectObject("true&&undetectable", obj); - ExpectBoolean("false&&undetectable", false); - ExpectBoolean("true||undetectable", true); - ExpectObject("false||undetectable", obj); - - ExpectObject("undetectable&&true", obj); - ExpectObject("undetectable&&false", obj); - ExpectBoolean("undetectable||true", true); - ExpectBoolean("undetectable||false", false); - - ExpectBoolean("undetectable==null", true); - ExpectBoolean("null==undetectable", true); - ExpectBoolean("undetectable==undefined", true); - ExpectBoolean("undefined==undetectable", true); - ExpectBoolean("undetectable==undetectable", true); - - - ExpectBoolean("undetectable===null", false); - ExpectBoolean("null===undetectable", false); - ExpectBoolean("undetectable===undefined", false); - ExpectBoolean("undefined===undetectable", false); - ExpectBoolean("undetectable===undetectable", true); -} - - -TEST(UndetectableOptimized) { - i::FLAG_allow_natives_syntax = true; - LocalContext env; - v8::HandleScope scope(env->GetIsolate()); - - Local obj = String::NewFromUtf8(env->GetIsolate(), "foo", - String::kUndetectableString); - env->Global()->Set(v8_str("undetectable"), obj); - env->Global()->Set(v8_str("detectable"), v8_str("bar")); - - ExpectString( - "function testBranch() {" - " if (!%_IsUndetectableObject(undetectable)) throw 1;" - " if (%_IsUndetectableObject(detectable)) throw 2;" - "}\n" - "function testBool() {" - " var b1 = !%_IsUndetectableObject(undetectable);" - " var b2 = %_IsUndetectableObject(detectable);" - " if (b1) throw 3;" - " if (b2) throw 4;" - " return b1 == b2;" - "}\n" - "%OptimizeFunctionOnNextCall(testBranch);" - "%OptimizeFunctionOnNextCall(testBool);" - "for (var i = 0; i < 10; i++) {" - " testBranch();" - " testBool();" - "}\n" - "\"PASS\"", - "PASS"); -} - - // The point of this test is type checking. We run it only so compilers // don't complain about an unused function. TEST(PersistentHandles) { diff --git a/tools/v8heapconst.py b/tools/v8heapconst.py index 9704545..7a69393 100644 --- a/tools/v8heapconst.py +++ b/tools/v8heapconst.py @@ -185,56 +185,54 @@ KNOWN_MAPS = { 0x08801: (26, "ShortExternalInternalizedStringWithOneByteDataMap"), 0x08829: (22, "ShortExternalOneByteInternalizedStringMap"), 0x08851: (86, "ShortExternalOneByteStringMap"), - 0x08879: (64, "UndetectableStringMap"), - 0x088a1: (68, "UndetectableOneByteStringMap"), - 0x088c9: (139, "ExternalInt8ArrayMap"), - 0x088f1: (140, "ExternalUint8ArrayMap"), - 0x08919: (141, "ExternalInt16ArrayMap"), - 0x08941: (142, "ExternalUint16ArrayMap"), - 0x08969: (143, "ExternalInt32ArrayMap"), - 0x08991: (144, "ExternalUint32ArrayMap"), - 0x089b9: (145, "ExternalFloat32ArrayMap"), - 0x089e1: (146, "ExternalFloat64ArrayMap"), - 0x08a09: (147, "ExternalUint8ClampedArrayMap"), - 0x08a31: (149, "FixedUint8ArrayMap"), - 0x08a59: (148, "FixedInt8ArrayMap"), - 0x08a81: (151, "FixedUint16ArrayMap"), - 0x08aa9: (150, "FixedInt16ArrayMap"), - 0x08ad1: (153, "FixedUint32ArrayMap"), - 0x08af9: (152, "FixedInt32ArrayMap"), - 0x08b21: (154, "FixedFloat32ArrayMap"), - 0x08b49: (155, "FixedFloat64ArrayMap"), - 0x08b71: (156, "FixedUint8ClampedArrayMap"), - 0x08b99: (180, "SloppyArgumentsElementsMap"), - 0x08bc1: (180, "FunctionContextMap"), - 0x08be9: (180, "CatchContextMap"), - 0x08c11: (180, "WithContextMap"), - 0x08c39: (180, "BlockContextMap"), - 0x08c61: (180, "ModuleContextMap"), - 0x08c89: (180, "ScriptContextMap"), - 0x08cb1: (180, "ScriptContextTableMap"), - 0x08cd9: (187, "JSMessageObjectMap"), - 0x08d01: (136, "ForeignMap"), - 0x08d29: (189, "NeanderMap"), - 0x08d51: (170, "AllocationSiteMap"), - 0x08d79: (171, "AllocationMementoMap"), - 0x08da1: (174, "PolymorphicCodeCacheMap"), - 0x08dc9: (172, "ScriptMap"), - 0x08e19: (189, "ExternalMap"), - 0x08f59: (177, "BoxMap"), - 0x08f81: (161, "ExecutableAccessorInfoMap"), - 0x08fa9: (162, "AccessorPairMap"), - 0x08fd1: (163, "AccessCheckInfoMap"), - 0x08ff9: (164, "InterceptorInfoMap"), - 0x09021: (165, "CallHandlerInfoMap"), - 0x09049: (166, "FunctionTemplateInfoMap"), - 0x09071: (167, "ObjectTemplateInfoMap"), - 0x09099: (169, "TypeSwitchInfoMap"), - 0x090c1: (173, "CodeCacheMap"), - 0x090e9: (175, "TypeFeedbackInfoMap"), - 0x09111: (176, "AliasedArgumentsEntryMap"), - 0x09139: (178, "DebugInfoMap"), - 0x09161: (179, "BreakPointInfoMap"), + 0x08879: (139, "ExternalInt8ArrayMap"), + 0x088a1: (140, "ExternalUint8ArrayMap"), + 0x088c9: (141, "ExternalInt16ArrayMap"), + 0x088f1: (142, "ExternalUint16ArrayMap"), + 0x08919: (143, "ExternalInt32ArrayMap"), + 0x08941: (144, "ExternalUint32ArrayMap"), + 0x08969: (145, "ExternalFloat32ArrayMap"), + 0x08991: (146, "ExternalFloat64ArrayMap"), + 0x089b9: (147, "ExternalUint8ClampedArrayMap"), + 0x089e1: (149, "FixedUint8ArrayMap"), + 0x08a09: (148, "FixedInt8ArrayMap"), + 0x08a31: (151, "FixedUint16ArrayMap"), + 0x08a59: (150, "FixedInt16ArrayMap"), + 0x08a81: (153, "FixedUint32ArrayMap"), + 0x08aa9: (152, "FixedInt32ArrayMap"), + 0x08ad1: (154, "FixedFloat32ArrayMap"), + 0x08af9: (155, "FixedFloat64ArrayMap"), + 0x08b21: (156, "FixedUint8ClampedArrayMap"), + 0x08b49: (180, "SloppyArgumentsElementsMap"), + 0x08b71: (180, "FunctionContextMap"), + 0x08b99: (180, "CatchContextMap"), + 0x08bc1: (180, "WithContextMap"), + 0x08be9: (180, "BlockContextMap"), + 0x08c11: (180, "ModuleContextMap"), + 0x08c39: (180, "ScriptContextMap"), + 0x08c61: (180, "ScriptContextTableMap"), + 0x08c89: (187, "JSMessageObjectMap"), + 0x08cb1: (136, "ForeignMap"), + 0x08cd9: (189, "NeanderMap"), + 0x08d01: (170, "AllocationSiteMap"), + 0x08d29: (171, "AllocationMementoMap"), + 0x08d51: (174, "PolymorphicCodeCacheMap"), + 0x08d79: (172, "ScriptMap"), + 0x08dc9: (189, "ExternalMap"), + 0x08f09: (177, "BoxMap"), + 0x08f31: (161, "ExecutableAccessorInfoMap"), + 0x08f59: (162, "AccessorPairMap"), + 0x08f81: (163, "AccessCheckInfoMap"), + 0x08fa9: (164, "InterceptorInfoMap"), + 0x08fd1: (165, "CallHandlerInfoMap"), + 0x08ff9: (166, "FunctionTemplateInfoMap"), + 0x09021: (167, "ObjectTemplateInfoMap"), + 0x09049: (169, "TypeSwitchInfoMap"), + 0x09071: (173, "CodeCacheMap"), + 0x09099: (175, "TypeFeedbackInfoMap"), + 0x090c1: (176, "AliasedArgumentsEntryMap"), + 0x090e9: (178, "DebugInfoMap"), + 0x09111: (179, "BreakPointInfoMap"), } # List of known V8 objects. @@ -255,16 +253,16 @@ KNOWN_OBJECTS = { ("OLD_POINTER_SPACE", 0x09531): "TerminationException", ("OLD_POINTER_SPACE", 0x09541): "MessageListeners", ("OLD_POINTER_SPACE", 0x0955d): "CodeStubs", - ("OLD_POINTER_SPACE", 0x1139d): "NonMonomorphicCache", - ("OLD_POINTER_SPACE", 0x119b1): "PolymorphicCodeCache", - ("OLD_POINTER_SPACE", 0x119b9): "NativesSourceCache", - ("OLD_POINTER_SPACE", 0x11a2d): "EmptyScript", - ("OLD_POINTER_SPACE", 0x11a69): "IntrinsicFunctionNames", - ("OLD_POINTER_SPACE", 0x17a85): "ObservationState", - ("OLD_POINTER_SPACE", 0x17a91): "SymbolRegistry", - ("OLD_POINTER_SPACE", 0x1844d): "EmptySlowElementDictionary", - ("OLD_POINTER_SPACE", 0x185e9): "AllocationSitesScratchpad", - ("OLD_POINTER_SPACE", 0x45d11): "StringTable", + ("OLD_POINTER_SPACE", 0x0f555): "NonMonomorphicCache", + ("OLD_POINTER_SPACE", 0x0fb69): "PolymorphicCodeCache", + ("OLD_POINTER_SPACE", 0x0fb71): "NativesSourceCache", + ("OLD_POINTER_SPACE", 0x0fbe1): "EmptyScript", + ("OLD_POINTER_SPACE", 0x0fc1d): "IntrinsicFunctionNames", + ("OLD_POINTER_SPACE", 0x15c39): "ObservationState", + ("OLD_POINTER_SPACE", 0x15c45): "SymbolRegistry", + ("OLD_POINTER_SPACE", 0x16601): "EmptySlowElementDictionary", + ("OLD_POINTER_SPACE", 0x1679d): "AllocationSitesScratchpad", + ("OLD_POINTER_SPACE", 0x43e61): "StringTable", ("OLD_DATA_SPACE", 0x08081): "EmptyDescriptorArray", ("OLD_DATA_SPACE", 0x08089): "EmptyFixedArray", ("OLD_DATA_SPACE", 0x080a9): "NanValue", @@ -290,6 +288,6 @@ KNOWN_OBJECTS = { ("OLD_DATA_SPACE", 0x082ed): "EmptyFixedUint8ClampedArray", ("OLD_DATA_SPACE", 0x082f5): "InfinityValue", ("OLD_DATA_SPACE", 0x08301): "MinusZeroValue", - ("CODE_SPACE", 0x17da1): "JsEntryCode", - ("CODE_SPACE", 0x2a921): "JsConstructEntryCode", + ("CODE_SPACE", 0x15fa1): "JsEntryCode", + ("CODE_SPACE", 0x243c1): "JsConstructEntryCode", } -- 2.7.4