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

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

Issue 911363002: Revert of new classes: implement new.target passing to superclass constructor. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 10 months 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') | src/runtime/runtime-scopes.cc » ('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/v8.h" 5 #include "src/v8.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.h" 9 #include "src/debug.h"
10 #include "src/runtime/runtime.h" 10 #include "src/runtime/runtime.h"
(...skipping 1227 matching lines...) Expand 10 before | Expand all | Expand 10 after
1238 HandleScope scope(isolate); 1238 HandleScope scope(isolate);
1239 DCHECK(args.length() == 0); 1239 DCHECK(args.length() == 0);
1240 return *isolate->factory()->NewHeapNumber(0); 1240 return *isolate->factory()->NewHeapNumber(0);
1241 } 1241 }
1242 1242
1243 1243
1244 static Object* Runtime_NewObjectHelper(Isolate* isolate, 1244 static Object* Runtime_NewObjectHelper(Isolate* isolate,
1245 Handle<Object> constructor, 1245 Handle<Object> constructor,
1246 Handle<Object> original_constructor, 1246 Handle<Object> original_constructor,
1247 Handle<AllocationSite> site) { 1247 Handle<AllocationSite> site) {
1248 // TODO(dslomov): implement prototype rewiring.
1249 // The check below is a sanity check.
1250 CHECK(*constructor == *original_constructor);
1251
1248 // If the constructor isn't a proper function we throw a type error. 1252 // If the constructor isn't a proper function we throw a type error.
1249 if (!constructor->IsJSFunction()) { 1253 if (!constructor->IsJSFunction()) {
1250 Vector<Handle<Object> > arguments = HandleVector(&constructor, 1); 1254 Vector<Handle<Object> > arguments = HandleVector(&constructor, 1);
1251 THROW_NEW_ERROR_RETURN_FAILURE(isolate, 1255 THROW_NEW_ERROR_RETURN_FAILURE(isolate,
1252 NewTypeError("not_constructor", arguments)); 1256 NewTypeError("not_constructor", arguments));
1253 } 1257 }
1254 1258
1255 Handle<JSFunction> function = Handle<JSFunction>::cast(constructor); 1259 Handle<JSFunction> function = Handle<JSFunction>::cast(constructor);
1256 1260
1257 CHECK(original_constructor->IsJSFunction());
1258 Handle<JSFunction> original_function =
1259 Handle<JSFunction>::cast(original_constructor);
1260
1261
1262 // If function should not have prototype, construction is not allowed. In this 1261 // If function should not have prototype, construction is not allowed. In this
1263 // case generated code bailouts here, since function has no initial_map. 1262 // case generated code bailouts here, since function has no initial_map.
1264 if (!function->should_have_prototype() && !function->shared()->bound()) { 1263 if (!function->should_have_prototype() && !function->shared()->bound()) {
1265 Vector<Handle<Object> > arguments = HandleVector(&constructor, 1); 1264 Vector<Handle<Object> > arguments = HandleVector(&constructor, 1);
1266 THROW_NEW_ERROR_RETURN_FAILURE(isolate, 1265 THROW_NEW_ERROR_RETURN_FAILURE(isolate,
1267 NewTypeError("not_constructor", arguments)); 1266 NewTypeError("not_constructor", arguments));
1268 } 1267 }
1269 1268
1270 Debug* debug = isolate->debug(); 1269 Debug* debug = isolate->debug();
1271 // Handle stepping into constructors if step into is active. 1270 // Handle stepping into constructors if step into is active.
(...skipping 22 matching lines...) Expand all
1294 // available. 1293 // available.
1295 Compiler::EnsureCompiled(function, CLEAR_EXCEPTION); 1294 Compiler::EnsureCompiled(function, CLEAR_EXCEPTION);
1296 1295
1297 Handle<JSObject> result; 1296 Handle<JSObject> result;
1298 if (site.is_null()) { 1297 if (site.is_null()) {
1299 result = isolate->factory()->NewJSObject(function); 1298 result = isolate->factory()->NewJSObject(function);
1300 } else { 1299 } else {
1301 result = isolate->factory()->NewJSObjectWithMemento(function, site); 1300 result = isolate->factory()->NewJSObjectWithMemento(function, site);
1302 } 1301 }
1303 1302
1304 // Set up the prototoype using original function.
1305 // TODO(dslomov): instead of setting the __proto__,
1306 // use and cache the correct map.
1307 if (*original_function != *function) {
1308 if (original_function->has_instance_prototype()) {
1309 Handle<Object> prototype =
1310 handle(original_function->instance_prototype(), isolate);
1311 RETURN_FAILURE_ON_EXCEPTION(
1312 isolate, JSObject::SetPrototype(result, prototype, false));
1313 }
1314 }
1315
1316 isolate->counters()->constructed_objects()->Increment(); 1303 isolate->counters()->constructed_objects()->Increment();
1317 isolate->counters()->constructed_objects_runtime()->Increment(); 1304 isolate->counters()->constructed_objects_runtime()->Increment();
1318 1305
1319 return *result; 1306 return *result;
1320 } 1307 }
1321 1308
1322 1309
1323 RUNTIME_FUNCTION(Runtime_NewObject) { 1310 RUNTIME_FUNCTION(Runtime_NewObject) {
1324 HandleScope scope(isolate); 1311 HandleScope scope(isolate);
1325 DCHECK(args.length() == 2); 1312 DCHECK(args.length() == 2);
(...skipping 285 matching lines...) Expand 10 before | Expand all | Expand 10 after
1611 CONVERT_PROPERTY_ATTRIBUTES_CHECKED(attrs, 3); 1598 CONVERT_PROPERTY_ATTRIBUTES_CHECKED(attrs, 3);
1612 1599
1613 RETURN_FAILURE_ON_EXCEPTION( 1600 RETURN_FAILURE_ON_EXCEPTION(
1614 isolate, 1601 isolate,
1615 JSObject::DefineAccessor(object, name, isolate->factory()->null_value(), 1602 JSObject::DefineAccessor(object, name, isolate->factory()->null_value(),
1616 setter, attrs)); 1603 setter, attrs));
1617 return isolate->heap()->undefined_value(); 1604 return isolate->heap()->undefined_value();
1618 } 1605 }
1619 } 1606 }
1620 } // namespace v8::internal 1607 } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/runtime/runtime-function.cc ('k') | src/runtime/runtime-scopes.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698