Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(41)

Side by Side Diff: src/runtime/runtime-object.cc

Issue 1415683007: Reland "[es6] Fix Function and GeneratorFunction built-ins subclassing." (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@fix-subclass
Patch Set: Improved test Created 5 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/runtime/runtime-function.cc ('k') | test/mjsunit/es6/classes-subclass-builtins.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 the V8 project authors. All rights reserved. 1 // Copyright 2014 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "src/runtime/runtime-utils.h" 5 #include "src/runtime/runtime-utils.h"
6 6
7 #include "src/arguments.h" 7 #include "src/arguments.h"
8 #include "src/bootstrapper.h" 8 #include "src/bootstrapper.h"
9 #include "src/debug/debug.h" 9 #include "src/debug/debug.h"
10 #include "src/isolate-inl.h" 10 #include "src/isolate-inl.h"
(...skipping 980 matching lines...) Expand 10 before | Expand all | Expand 10 after
991 991
992 Debug* debug = isolate->debug(); 992 Debug* debug = isolate->debug();
993 // Handle stepping into constructors if step into is active. 993 // Handle stepping into constructors if step into is active.
994 if (debug->StepInActive()) debug->HandleStepIn(function, true); 994 if (debug->StepInActive()) debug->HandleStepIn(function, true);
995 995
996 // The function should be compiled for the optimization hints to be 996 // The function should be compiled for the optimization hints to be
997 // available. 997 // available.
998 Compiler::Compile(function, CLEAR_EXCEPTION); 998 Compiler::Compile(function, CLEAR_EXCEPTION);
999 999
1000 JSFunction::EnsureHasInitialMap(function); 1000 JSFunction::EnsureHasInitialMap(function);
1001 if (function->initial_map()->instance_type() == JS_FUNCTION_TYPE) {
1002 // The 'Function' function ignores the receiver object when
1003 // called using 'new' and creates a new JSFunction object that
1004 // is returned.
1005 return isolate->heap()->undefined_value();
1006 }
1007
1001 Handle<Map> initial_map = 1008 Handle<Map> initial_map =
1002 JSFunction::EnsureDerivedHasInitialMap(original_function, function); 1009 JSFunction::EnsureDerivedHasInitialMap(original_function, function);
1003 1010
1004 if (initial_map->instance_type() == JS_FUNCTION_TYPE) {
1005 // The 'Function' function ignores the receiver object when
1006 // called using 'new' and creates a new JSFunction object that
1007 // is returned. The receiver object is only used for error
1008 // reporting if an error occurs when constructing the new
1009 // JSFunction. Factory::NewJSObject() should not be used to
1010 // allocate JSFunctions since it does not properly initialize
1011 // the shared part of the function. Since the receiver is
1012 // ignored anyway, we use the global object as the receiver
1013 // instead of a new JSFunction object. This way, errors are
1014 // reported the same way whether or not 'Function' is called
1015 // using 'new'.
1016 return isolate->global_proxy();
1017 }
1018
1019 Handle<JSObject> result = 1011 Handle<JSObject> result =
1020 isolate->factory()->NewJSObjectFromMap(initial_map, NOT_TENURED, site); 1012 isolate->factory()->NewJSObjectFromMap(initial_map, NOT_TENURED, site);
1021 1013
1022 isolate->counters()->constructed_objects()->Increment(); 1014 isolate->counters()->constructed_objects()->Increment();
1023 isolate->counters()->constructed_objects_runtime()->Increment(); 1015 isolate->counters()->constructed_objects_runtime()->Increment();
1024 1016
1025 return *result; 1017 return *result;
1026 } 1018 }
1027 1019
1028 1020
(...skipping 531 matching lines...) Expand 10 before | Expand all | Expand 10 after
1560 1552
1561 RUNTIME_FUNCTION(Runtime_ObjectDefineProperties) { 1553 RUNTIME_FUNCTION(Runtime_ObjectDefineProperties) {
1562 HandleScope scope(isolate); 1554 HandleScope scope(isolate);
1563 DCHECK(args.length() == 2); 1555 DCHECK(args.length() == 2);
1564 CONVERT_ARG_HANDLE_CHECKED(Object, o, 0); 1556 CONVERT_ARG_HANDLE_CHECKED(Object, o, 0);
1565 CONVERT_ARG_HANDLE_CHECKED(Object, properties, 1); 1557 CONVERT_ARG_HANDLE_CHECKED(Object, properties, 1);
1566 return JSReceiver::DefineProperties(isolate, o, properties); 1558 return JSReceiver::DefineProperties(isolate, o, properties);
1567 } 1559 }
1568 } // namespace internal 1560 } // namespace internal
1569 } // namespace v8 1561 } // namespace v8
OLDNEW
« no previous file with comments | « src/runtime/runtime-function.cc ('k') | test/mjsunit/es6/classes-subclass-builtins.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698