From 6a5cd946766e893b2e4cc789dba59aa1c55f02dd Mon Sep 17 00:00:00 2001 From: "arv@chromium.org" Date: Tue, 11 Nov 2014 16:22:14 +0000 Subject: [PATCH] Revert "Classes: Add support for arguments in default constructor" This reverts commit 3f4ea6c91a962a04407c79f08e5c86ce9ff2911a. Broke tests on Mac64 http://build.chromium.org/p/client.v8/builders/V8%20Mac64/builds/923/steps/Check/logs/classes BUG=v8:3672 TBR=dslomov@chromium.org LOG=N Review URL: https://codereview.chromium.org/712333003 Cr-Commit-Position: refs/heads/master@{#25269} git-svn-id: https://v8.googlecode.com/svn/branches/bleeding_edge@25269 ce2b1a6d-e550-0410-aec6-3dcde31c8c00 --- src/parser.cc | 6 ++--- src/runtime/runtime-classes.cc | 47 --------------------------------------- src/runtime/runtime-object.cc | 25 +++++++-------------- src/runtime/runtime.h | 6 +---- test/mjsunit/harmony/classes.js | 49 ----------------------------------------- 5 files changed, 11 insertions(+), 122 deletions(-) diff --git a/src/parser.cc b/src/parser.cc index 4c81355..e34854f 100644 --- a/src/parser.cc +++ b/src/parser.cc @@ -302,12 +302,10 @@ FunctionLiteral* Parser::DefaultConstructor(bool call_super, Scope* scope, body = new (zone()) ZoneList(1, zone()); if (call_super) { + Expression* prop = SuperReference(function_scope, factory(), pos); ZoneList* args = new (zone()) ZoneList(0, zone()); - CallRuntime* call = factory()->NewCallRuntime( - ast_value_factory()->empty_string(), - Runtime::FunctionForId(Runtime::kDefaultConstructorSuperCall), args, - pos); + Call* call = factory()->NewCall(prop, args, pos); body->Add(factory()->NewExpressionStatement(call, pos), zone()); } diff --git a/src/runtime/runtime-classes.cc b/src/runtime/runtime-classes.cc index 73f19bb..30ff918 100644 --- a/src/runtime/runtime-classes.cc +++ b/src/runtime/runtime-classes.cc @@ -448,52 +448,5 @@ RUNTIME_FUNCTION(Runtime_StoreKeyedToSuper_Sloppy) { return StoreKeyedToSuper(isolate, home_object, receiver, key, value, SLOPPY); } - - -RUNTIME_FUNCTION(Runtime_DefaultConstructorSuperCall) { - HandleScope scope(isolate); - DCHECK(args.length() == 0); - - // Compute the frame holding the arguments. - JavaScriptFrameIterator it(isolate); - it.AdvanceToArgumentsFrame(); - JavaScriptFrame* frame = it.frame(); - - Handle function(frame->function(), isolate); - Handle receiver(frame->receiver(), isolate); - - Handle proto_function; - ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, proto_function, - Runtime::GetPrototype(isolate, function)); - - // Get the actual number of provided arguments. - const int argc = frame->ComputeParametersCount(); - - // Loose upper bound to allow fuzzing. We'll most likely run out of - // stack space before hitting this limit. - static int kMaxArgc = 1000000; - RUNTIME_ASSERT(argc >= 0 && argc <= kMaxArgc); - - // If there are too many arguments, allocate argv via malloc. - const int argv_small_size = 10; - Handle argv_small_buffer[argv_small_size]; - SmartArrayPointer > argv_large_buffer; - Handle* argv = argv_small_buffer; - if (argc > argv_small_size) { - argv = new Handle[argc]; - if (argv == NULL) return isolate->StackOverflow(); - argv_large_buffer = SmartArrayPointer >(argv); - } - - for (int i = 0; i < argc; ++i) { - argv[i] = handle(frame->GetParameter(i), isolate); - } - - Handle result; - ASSIGN_RETURN_FAILURE_ON_EXCEPTION( - isolate, result, - Execution::Call(isolate, proto_function, receiver, argc, argv, false)); - return *result; -} } } // namespace v8::internal diff --git a/src/runtime/runtime-object.cc b/src/runtime/runtime-object.cc index 3b302d1..fc97d6b 100644 --- a/src/runtime/runtime-object.cc +++ b/src/runtime/runtime-object.cc @@ -242,8 +242,10 @@ MaybeHandle Runtime::DefineObjectProperty(Handle js_object, } -MaybeHandle Runtime::GetPrototype(Isolate* isolate, - Handle obj) { +RUNTIME_FUNCTION(Runtime_GetPrototype) { + HandleScope scope(isolate); + DCHECK(args.length() == 1); + CONVERT_ARG_HANDLE_CHECKED(Object, obj, 0); // We don't expect access checks to be needed on JSProxy objects. DCHECK(!obj->IsAccessCheckNeeded() || obj->IsJSObject()); PrototypeIterator iter(isolate, obj, PrototypeIterator::START_AT_RECEIVER); @@ -255,26 +257,15 @@ MaybeHandle Runtime::GetPrototype(Isolate* isolate, isolate->ReportFailedAccessCheck( Handle::cast(PrototypeIterator::GetCurrent(iter)), v8::ACCESS_GET); - RETURN_EXCEPTION_IF_SCHEDULED_EXCEPTION(isolate, Object); - return isolate->factory()->undefined_value(); + RETURN_FAILURE_IF_SCHEDULED_EXCEPTION(isolate); + return isolate->heap()->undefined_value(); } iter.AdvanceIgnoringProxies(); if (PrototypeIterator::GetCurrent(iter)->IsJSProxy()) { - return PrototypeIterator::GetCurrent(iter); + return *PrototypeIterator::GetCurrent(iter); } } while (!iter.IsAtEnd(PrototypeIterator::END_AT_NON_HIDDEN)); - return PrototypeIterator::GetCurrent(iter); -} - - -RUNTIME_FUNCTION(Runtime_GetPrototype) { - HandleScope scope(isolate); - DCHECK(args.length() == 1); - CONVERT_ARG_HANDLE_CHECKED(Object, obj, 0); - Handle result; - ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, result, - Runtime::GetPrototype(isolate, obj)); - return *result; + return *PrototypeIterator::GetCurrent(iter); } diff --git a/src/runtime/runtime.h b/src/runtime/runtime.h index 749c15f..ea21faf 100644 --- a/src/runtime/runtime.h +++ b/src/runtime/runtime.h @@ -199,8 +199,7 @@ namespace internal { F(StoreToSuper_Strict, 4, 1) \ F(StoreToSuper_Sloppy, 4, 1) \ F(StoreKeyedToSuper_Strict, 4, 1) \ - F(StoreKeyedToSuper_Sloppy, 4, 1) \ - F(DefaultConstructorSuperCall, 0, 1) + F(StoreKeyedToSuper_Sloppy, 4, 1) #define RUNTIME_FUNCTION_LIST_ALWAYS_2(F) \ @@ -829,9 +828,6 @@ class Runtime : public AllStatic { MUST_USE_RESULT static MaybeHandle GetObjectProperty( Isolate* isolate, Handle object, Handle key); - MUST_USE_RESULT static MaybeHandle GetPrototype( - Isolate* isolate, Handle object); - MUST_USE_RESULT static MaybeHandle ToName(Isolate* isolate, Handle key); diff --git a/test/mjsunit/harmony/classes.js b/test/mjsunit/harmony/classes.js index 767962e..8748f62 100644 --- a/test/mjsunit/harmony/classes.js +++ b/test/mjsunit/harmony/classes.js @@ -624,55 +624,6 @@ function assertAccessorDescriptor(object, name) { })(); -(function TestDefaultConstructorArguments() { - var args, self; - class Base { - constructor() { - self = this; - args = arguments; - } - } - class Derived extends Base {} - - new Derived; - assertEquals(0, args.length); - - new Derived(0, 1, 2); - assertEquals(3, args.length); - assertTrue(self instanceof Derived); - - var arr = new Array(1e5); - var obj = {}; - Derived.apply(obj, arr); - assertEquals(1e5, args.length); - assertEquals(obj, self); -})(); - - -(function TestDefaultConstructorArguments2() { - var args; - class Base { - constructor(x, y) { - args = arguments; - } - } - class Derived extends Base {} - - new Derived; - assertEquals(0, args.length); - - new Derived(1); - assertEquals(1, args.length); - assertEquals(1, args[0]); - - new Derived(1, 2, 3); - assertEquals(3, args.length); - assertEquals(1, args[0]); - assertEquals(2, args[1]); - assertEquals(3, args[2]); -})(); - - /* TODO(arv): Implement (function TestNameBindingInConstructor() { class C { -- 2.7.4