[strong] Refactor out separate strong runtime call for class objects
authorconradw <conradw@chromium.org>
Wed, 5 Aug 2015 16:03:57 +0000 (09:03 -0700)
committerCommit bot <commit-bot@chromium.org>
Wed, 5 Aug 2015 16:04:51 +0000 (16:04 +0000)
BUG=v8:3956
LOG=N

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

Cr-Commit-Position: refs/heads/master@{#30033}

12 files changed:
src/compiler/ast-graph-builder.cc
src/compiler/linkage.cc
src/full-codegen/arm/full-codegen-arm.cc
src/full-codegen/arm64/full-codegen-arm64.cc
src/full-codegen/ia32/full-codegen-ia32.cc
src/full-codegen/mips/full-codegen-mips.cc
src/full-codegen/mips64/full-codegen-mips64.cc
src/full-codegen/ppc/full-codegen-ppc.cc
src/full-codegen/x64/full-codegen-x64.cc
src/full-codegen/x87/full-codegen-x87.cc
src/runtime/runtime-classes.cc
src/runtime/runtime.h

index fa56f8c..a9825cf 100644 (file)
@@ -1643,10 +1643,8 @@ void AstGraphBuilder::VisitClassLiteralContents(ClassLiteral* expr) {
   // freeze them in strong mode.
   environment()->Pop();  // proto
   environment()->Pop();  // literal
-  const Operator* op = javascript()->CallRuntime(
-      is_strong(language_mode()) ? Runtime::kFinalizeClassDefinitionStrong
-                                 : Runtime::kFinalizeClassDefinition,
-      2);
+  const Operator* op =
+      javascript()->CallRuntime(Runtime::kFinalizeClassDefinition, 2);
   literal = NewNode(op, literal, proto);
 
   // Assign to class variable.
index bae73df..5421f41 100644 (file)
@@ -193,7 +193,6 @@ int Linkage::FrameStateInputCount(Runtime::FunctionId function) {
     case Runtime::kAllocateInTargetSpace:
     case Runtime::kDateField:
     case Runtime::kFinalizeClassDefinition:        // TODO(conradw): Is it safe?
-    case Runtime::kFinalizeClassDefinitionStrong:  // TODO(conradw): Is it safe?
     case Runtime::kDefineClassMethod:              // TODO(jarin): Is it safe?
     case Runtime::kDefineGetterPropertyUnchecked:  // TODO(jarin): Is it safe?
     case Runtime::kDefineSetterPropertyUnchecked:  // TODO(jarin): Is it safe?
index 4d9e794..0e6d4c0 100644 (file)
@@ -2574,10 +2574,7 @@ void FullCodeGenerator::EmitClassDefineProperties(ClassLiteral* lit,
 
   // Set both the prototype and constructor to have fast properties, and also
   // freeze them in strong mode.
-  __ CallRuntime(is_strong(language_mode())
-                     ? Runtime::kFinalizeClassDefinitionStrong
-                     : Runtime::kFinalizeClassDefinition,
-                 2);
+  __ CallRuntime(Runtime::kFinalizeClassDefinition, 2);
 }
 
 
index 655790a..678471d 100644 (file)
@@ -2270,10 +2270,7 @@ void FullCodeGenerator::EmitClassDefineProperties(ClassLiteral* lit,
 
   // Set both the prototype and constructor to have fast properties, and also
   // freeze them in strong mode.
-  __ CallRuntime(is_strong(language_mode())
-                     ? Runtime::kFinalizeClassDefinitionStrong
-                     : Runtime::kFinalizeClassDefinition,
-                 2);
+  __ CallRuntime(Runtime::kFinalizeClassDefinition, 2);
 }
 
 
index 80fb965..6c1ac09 100644 (file)
@@ -2486,10 +2486,7 @@ void FullCodeGenerator::EmitClassDefineProperties(ClassLiteral* lit,
 
   // Set both the prototype and constructor to have fast properties, and also
   // freeze them in strong mode.
-  __ CallRuntime(is_strong(language_mode())
-                     ? Runtime::kFinalizeClassDefinitionStrong
-                     : Runtime::kFinalizeClassDefinition,
-                 2);
+  __ CallRuntime(Runtime::kFinalizeClassDefinition, 2);
 }
 
 
index 977a71d..cef99ab 100644 (file)
@@ -2565,10 +2565,7 @@ void FullCodeGenerator::EmitClassDefineProperties(ClassLiteral* lit,
 
   // Set both the prototype and constructor to have fast properties, and also
   // freeze them in strong mode.
-  __ CallRuntime(is_strong(language_mode())
-                     ? Runtime::kFinalizeClassDefinitionStrong
-                     : Runtime::kFinalizeClassDefinition,
-                 2);
+  __ CallRuntime(Runtime::kFinalizeClassDefinition, 2);
 }
 
 
index 6014347..8075822 100644 (file)
@@ -2563,10 +2563,7 @@ void FullCodeGenerator::EmitClassDefineProperties(ClassLiteral* lit,
 
   // Set both the prototype and constructor to have fast properties, and also
   // freeze them in strong mode.
-  __ CallRuntime(is_strong(language_mode())
-                     ? Runtime::kFinalizeClassDefinitionStrong
-                     : Runtime::kFinalizeClassDefinition,
-                 2);
+  __ CallRuntime(Runtime::kFinalizeClassDefinition, 2);
 }
 
 
index 6ddf6c6..e20f367 100644 (file)
@@ -2575,10 +2575,7 @@ void FullCodeGenerator::EmitClassDefineProperties(ClassLiteral* lit,
 
   // Set both the prototype and constructor to have fast properties, and also
   // freeze them in strong mode.
-  __ CallRuntime(is_strong(language_mode())
-                     ? Runtime::kFinalizeClassDefinitionStrong
-                     : Runtime::kFinalizeClassDefinition,
-                 2);
+  __ CallRuntime(Runtime::kFinalizeClassDefinition, 2);
 }
 
 
index 1eae31d..65c0456 100644 (file)
@@ -2481,10 +2481,7 @@ void FullCodeGenerator::EmitClassDefineProperties(ClassLiteral* lit,
 
   // Set both the prototype and constructor to have fast properties, and also
   // freeze them in strong mode.
-  __ CallRuntime(is_strong(language_mode())
-                     ? Runtime::kFinalizeClassDefinitionStrong
-                     : Runtime::kFinalizeClassDefinition,
-                 2);
+  __ CallRuntime(Runtime::kFinalizeClassDefinition, 2);
 }
 
 
index 12d24c0..f1848c9 100644 (file)
@@ -2477,10 +2477,7 @@ void FullCodeGenerator::EmitClassDefineProperties(ClassLiteral* lit,
 
   // Set both the prototype and constructor to have fast properties, and also
   // freeze them in strong mode.
-  __ CallRuntime(is_strong(language_mode())
-                     ? Runtime::kFinalizeClassDefinitionStrong
-                     : Runtime::kFinalizeClassDefinition,
-                 2);
+  __ CallRuntime(Runtime::kFinalizeClassDefinition, 2);
 }
 
 
index 8312090..4867777 100644 (file)
@@ -265,27 +265,18 @@ RUNTIME_FUNCTION(Runtime_FinalizeClassDefinition) {
   JSObject::MigrateSlowToFast(prototype, 0, "RuntimeToFastProperties");
   JSObject::MigrateSlowToFast(constructor, 0, "RuntimeToFastProperties");
 
+  if (constructor->map()->is_strong()) {
+    DCHECK(prototype->map()->is_strong());
+    RETURN_FAILURE_ON_EXCEPTION(isolate, JSObject::Freeze(prototype));
+    Handle<Object> result;
+    ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, result,
+                                       JSObject::Freeze(constructor));
+    return *result;
+  }
   return *constructor;
 }
 
 
-RUNTIME_FUNCTION(Runtime_FinalizeClassDefinitionStrong) {
-  HandleScope scope(isolate);
-  DCHECK(args.length() == 2);
-  CONVERT_ARG_HANDLE_CHECKED(JSObject, constructor, 0);
-  CONVERT_ARG_HANDLE_CHECKED(JSObject, prototype, 1);
-
-  JSObject::MigrateSlowToFast(prototype, 0, "RuntimeToFastProperties");
-  JSObject::MigrateSlowToFast(constructor, 0, "RuntimeToFastProperties");
-
-  RETURN_FAILURE_ON_EXCEPTION(isolate, JSObject::Freeze(prototype));
-  Handle<Object> result;
-  ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, result,
-                                     JSObject::Freeze(constructor));
-  return *result;
-}
-
-
 RUNTIME_FUNCTION(Runtime_ClassGetSourceCode) {
   HandleScope shs(isolate);
   DCHECK(args.length() == 1);
index 21f38e5..28292a0 100644 (file)
@@ -85,7 +85,6 @@ namespace internal {
   F(DefineClass, 6, 1)                        \
   F(DefineClassStrong, 6, 1)                  \
   F(FinalizeClassDefinition, 2, 1)            \
-  F(FinalizeClassDefinitionStrong, 2, 1)      \
   F(DefineClassMethod, 3, 1)                  \
   F(ClassGetSourceCode, 1, 1)                 \
   F(LoadFromSuper, 4, 1)                      \