From 2cd2b8cadb4ebafefd4969c99853a3d7fd9d4906 Mon Sep 17 00:00:00 2001 From: conradw Date: Wed, 5 Aug 2015 09:03:57 -0700 Subject: [PATCH] [strong] Refactor out separate strong runtime call for class objects BUG=v8:3956 LOG=N Review URL: https://codereview.chromium.org/1270393002 Cr-Commit-Position: refs/heads/master@{#30033} --- src/compiler/ast-graph-builder.cc | 6 ++---- src/compiler/linkage.cc | 1 - src/full-codegen/arm/full-codegen-arm.cc | 5 +---- src/full-codegen/arm64/full-codegen-arm64.cc | 5 +---- src/full-codegen/ia32/full-codegen-ia32.cc | 5 +---- src/full-codegen/mips/full-codegen-mips.cc | 5 +---- src/full-codegen/mips64/full-codegen-mips64.cc | 5 +---- src/full-codegen/ppc/full-codegen-ppc.cc | 5 +---- src/full-codegen/x64/full-codegen-x64.cc | 5 +---- src/full-codegen/x87/full-codegen-x87.cc | 5 +---- src/runtime/runtime-classes.cc | 25 ++++++++----------------- src/runtime/runtime.h | 1 - 12 files changed, 18 insertions(+), 55 deletions(-) diff --git a/src/compiler/ast-graph-builder.cc b/src/compiler/ast-graph-builder.cc index fa56f8c..a9825cf 100644 --- a/src/compiler/ast-graph-builder.cc +++ b/src/compiler/ast-graph-builder.cc @@ -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. diff --git a/src/compiler/linkage.cc b/src/compiler/linkage.cc index bae73df..5421f41 100644 --- a/src/compiler/linkage.cc +++ b/src/compiler/linkage.cc @@ -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? diff --git a/src/full-codegen/arm/full-codegen-arm.cc b/src/full-codegen/arm/full-codegen-arm.cc index 4d9e794..0e6d4c0 100644 --- a/src/full-codegen/arm/full-codegen-arm.cc +++ b/src/full-codegen/arm/full-codegen-arm.cc @@ -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); } diff --git a/src/full-codegen/arm64/full-codegen-arm64.cc b/src/full-codegen/arm64/full-codegen-arm64.cc index 655790a..678471d 100644 --- a/src/full-codegen/arm64/full-codegen-arm64.cc +++ b/src/full-codegen/arm64/full-codegen-arm64.cc @@ -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); } diff --git a/src/full-codegen/ia32/full-codegen-ia32.cc b/src/full-codegen/ia32/full-codegen-ia32.cc index 80fb965..6c1ac09 100644 --- a/src/full-codegen/ia32/full-codegen-ia32.cc +++ b/src/full-codegen/ia32/full-codegen-ia32.cc @@ -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); } diff --git a/src/full-codegen/mips/full-codegen-mips.cc b/src/full-codegen/mips/full-codegen-mips.cc index 977a71d..cef99ab 100644 --- a/src/full-codegen/mips/full-codegen-mips.cc +++ b/src/full-codegen/mips/full-codegen-mips.cc @@ -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); } diff --git a/src/full-codegen/mips64/full-codegen-mips64.cc b/src/full-codegen/mips64/full-codegen-mips64.cc index 6014347..8075822 100644 --- a/src/full-codegen/mips64/full-codegen-mips64.cc +++ b/src/full-codegen/mips64/full-codegen-mips64.cc @@ -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); } diff --git a/src/full-codegen/ppc/full-codegen-ppc.cc b/src/full-codegen/ppc/full-codegen-ppc.cc index 6ddf6c6..e20f367 100644 --- a/src/full-codegen/ppc/full-codegen-ppc.cc +++ b/src/full-codegen/ppc/full-codegen-ppc.cc @@ -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); } diff --git a/src/full-codegen/x64/full-codegen-x64.cc b/src/full-codegen/x64/full-codegen-x64.cc index 1eae31d..65c0456 100644 --- a/src/full-codegen/x64/full-codegen-x64.cc +++ b/src/full-codegen/x64/full-codegen-x64.cc @@ -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); } diff --git a/src/full-codegen/x87/full-codegen-x87.cc b/src/full-codegen/x87/full-codegen-x87.cc index 12d24c0..f1848c9 100644 --- a/src/full-codegen/x87/full-codegen-x87.cc +++ b/src/full-codegen/x87/full-codegen-x87.cc @@ -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); } diff --git a/src/runtime/runtime-classes.cc b/src/runtime/runtime-classes.cc index 8312090..4867777 100644 --- a/src/runtime/runtime-classes.cc +++ b/src/runtime/runtime-classes.cc @@ -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 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 result; - ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, result, - JSObject::Freeze(constructor)); - return *result; -} - - RUNTIME_FUNCTION(Runtime_ClassGetSourceCode) { HandleScope shs(isolate); DCHECK(args.length() == 1); diff --git a/src/runtime/runtime.h b/src/runtime/runtime.h index 21f38e5..28292a0 100644 --- a/src/runtime/runtime.h +++ b/src/runtime/runtime.h @@ -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) \ -- 2.7.4