Support non-internalized string key lookups in Hydrogen KeyedLoadIC
authordanno@chromium.org <danno@chromium.org@ce2b1a6d-e550-0410-aec6-3dcde31c8c00>
Sat, 28 Jun 2014 00:33:04 +0000 (00:33 +0000)
committerdanno@chromium.org <danno@chromium.org@ce2b1a6d-e550-0410-aec6-3dcde31c8c00>
Sat, 28 Jun 2014 00:33:04 +0000 (00:33 +0000)
R=jkummerow@chromium.org

Review URL: https://codereview.chromium.org/356213003

git-svn-id: https://v8.googlecode.com/svn/branches/bleeding_edge@22070 ce2b1a6d-e550-0410-aec6-3dcde31c8c00

src/hydrogen.cc
src/runtime.cc
src/runtime.h
test/mjsunit/runtime-gen/internalizestring.js [new file with mode: 0644]
tools/generate-runtime-tests.py

index 89f61de..1b6cb11 100644 (file)
@@ -1513,13 +1513,23 @@ void HGraphBuilder::BuildKeyedIndexCheck(HValue* key,
               Token::BIT_AND,
               instance_type,
               Add<HConstant>(static_cast<int>(kIsNotInternalizedMask)));
-          DeoptimizeIf<HCompareNumericAndBranch>(
-              not_internalized_bit,
-              graph()->GetConstant0(),
-              Token::NE,
-              "BuildKeyedIndexCheck: string isn't internalized");
-          // Key guaranteed to be a unqiue string
+
+          IfBuilder internalized(this);
+          internalized.If<HCompareNumericAndBranch>(not_internalized_bit,
+                                                    graph()->GetConstant0(),
+                                                    Token::EQ);
+          internalized.Then();
           Push(key);
+
+          internalized.Else();
+          Add<HPushArguments>(key);
+          HValue* intern_key = Add<HCallRuntime>(
+              isolate()->factory()->empty_string(),
+              Runtime::FunctionForId(Runtime::kInternalizeString), 1);
+          Push(intern_key);
+
+          internalized.End();
+          // Key guaranteed to be a unique string
         }
         string_index_if.JoinContinuation(join_continuation);
       }
index 31d91be..eba17a1 100644 (file)
@@ -4455,6 +4455,14 @@ RUNTIME_FUNCTION(Runtime_SubString) {
 }
 
 
+RUNTIME_FUNCTION(Runtime_InternalizeString) {
+  HandleScope handles(isolate);
+  RUNTIME_ASSERT(args.length() == 1);
+  CONVERT_ARG_HANDLE_CHECKED(String, string, 0);
+  return *isolate->factory()->InternalizeString(string);
+}
+
+
 RUNTIME_FUNCTION(Runtime_StringMatch) {
   HandleScope handles(isolate);
   ASSERT(args.length() == 3);
index 1bd087b..f01f173 100644 (file)
@@ -403,6 +403,7 @@ namespace internal {
   F(RegExpExecRT, 4, 1) \
   F(StringAdd, 2, 1)  \
   F(SubString, 3, 1) \
+  F(InternalizeString, 1, 1) \
   F(StringCompare, 2, 1) \
   F(StringCharCodeAtRT, 2, 1) \
   F(GetFromCache, 2, 1) \
diff --git a/test/mjsunit/runtime-gen/internalizestring.js b/test/mjsunit/runtime-gen/internalizestring.js
new file mode 100644 (file)
index 0000000..7729f56
--- /dev/null
@@ -0,0 +1,5 @@
+// Copyright 2014 the V8 project authors. All rights reserved.
+// AUTO-GENERATED BY tools/generate-runtime-tests.py, DO NOT MODIFY
+// Flags: --allow-natives-syntax --harmony
+var _string = "foo";
+%InternalizeString(_string);
index 9740b37..52b7dcb 100755 (executable)
@@ -47,8 +47,8 @@ EXPAND_MACROS = [
 # that the parser doesn't bit-rot. Change the values as needed when you add,
 # remove or change runtime functions, but make sure we don't lose our ability
 # to parse them!
-EXPECTED_FUNCTION_COUNT = 414
-EXPECTED_FUZZABLE_COUNT = 329
+EXPECTED_FUNCTION_COUNT = 415
+EXPECTED_FUZZABLE_COUNT = 330
 EXPECTED_CCTEST_COUNT = 6
 EXPECTED_UNKNOWN_COUNT = 4
 EXPECTED_BUILTINS_COUNT = 806