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

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

Issue 803933008: new classes: change semantics of super(...) call and add new.target to construct stub. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Platform ports Created 5 years, 11 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
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 1264 matching lines...) Expand 10 before | Expand all | Expand 10 after
1275 1275
1276 RUNTIME_FUNCTION(Runtime_AllocateHeapNumber) { 1276 RUNTIME_FUNCTION(Runtime_AllocateHeapNumber) {
1277 HandleScope scope(isolate); 1277 HandleScope scope(isolate);
1278 DCHECK(args.length() == 0); 1278 DCHECK(args.length() == 0);
1279 return *isolate->factory()->NewHeapNumber(0); 1279 return *isolate->factory()->NewHeapNumber(0);
1280 } 1280 }
1281 1281
1282 1282
1283 static Object* Runtime_NewObjectHelper(Isolate* isolate, 1283 static Object* Runtime_NewObjectHelper(Isolate* isolate,
1284 Handle<Object> constructor, 1284 Handle<Object> constructor,
1285 Handle<Object> original_constructor,
1285 Handle<AllocationSite> site) { 1286 Handle<AllocationSite> site) {
1286 // If the constructor isn't a proper function we throw a type error. 1287 // If the constructor isn't a proper function we throw a type error.
1287 if (!constructor->IsJSFunction()) { 1288 if (!constructor->IsJSFunction()) {
1288 Vector<Handle<Object> > arguments = HandleVector(&constructor, 1); 1289 Vector<Handle<Object> > arguments = HandleVector(&constructor, 1);
1289 THROW_NEW_ERROR_RETURN_FAILURE(isolate, 1290 THROW_NEW_ERROR_RETURN_FAILURE(isolate,
1290 NewTypeError("not_constructor", arguments)); 1291 NewTypeError("not_constructor", arguments));
1291 } 1292 }
1292 1293
1293 Handle<JSFunction> function = Handle<JSFunction>::cast(constructor); 1294 Handle<JSFunction> function = Handle<JSFunction>::cast(constructor);
1294 1295
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
1336 1337
1337 isolate->counters()->constructed_objects()->Increment(); 1338 isolate->counters()->constructed_objects()->Increment();
1338 isolate->counters()->constructed_objects_runtime()->Increment(); 1339 isolate->counters()->constructed_objects_runtime()->Increment();
1339 1340
1340 return *result; 1341 return *result;
1341 } 1342 }
1342 1343
1343 1344
1344 RUNTIME_FUNCTION(Runtime_NewObject) { 1345 RUNTIME_FUNCTION(Runtime_NewObject) {
1345 HandleScope scope(isolate); 1346 HandleScope scope(isolate);
1346 DCHECK(args.length() == 1); 1347 DCHECK(args.length() == 2);
1347 CONVERT_ARG_HANDLE_CHECKED(Object, constructor, 0); 1348 CONVERT_ARG_HANDLE_CHECKED(Object, constructor, 0);
1348 return Runtime_NewObjectHelper(isolate, constructor, 1349 CONVERT_ARG_HANDLE_CHECKED(Object, original_constructor, 1);
1350 CHECK(*constructor == *original_constructor);
arv (Not doing code reviews) 2015/01/21 19:18:56 Why are we passing two args here?
Dmitry Lomov (no reviews) 2015/01/22 11:59:00 We will need both args once prototype rewiring is
1351 return Runtime_NewObjectHelper(isolate, constructor, original_constructor,
1349 Handle<AllocationSite>::null()); 1352 Handle<AllocationSite>::null());
1350 } 1353 }
1351 1354
1352 1355
1353 RUNTIME_FUNCTION(Runtime_NewObjectWithAllocationSite) { 1356 RUNTIME_FUNCTION(Runtime_NewObjectWithAllocationSite) {
1354 HandleScope scope(isolate); 1357 HandleScope scope(isolate);
1355 DCHECK(args.length() == 2); 1358 DCHECK(args.length() == 3);
1359 CONVERT_ARG_HANDLE_CHECKED(Object, original_constructor, 2);
1356 CONVERT_ARG_HANDLE_CHECKED(Object, constructor, 1); 1360 CONVERT_ARG_HANDLE_CHECKED(Object, constructor, 1);
1357 CONVERT_ARG_HANDLE_CHECKED(Object, feedback, 0); 1361 CONVERT_ARG_HANDLE_CHECKED(Object, feedback, 0);
1358 Handle<AllocationSite> site; 1362 Handle<AllocationSite> site;
1359 if (feedback->IsAllocationSite()) { 1363 if (feedback->IsAllocationSite()) {
1360 // The feedback can be an AllocationSite or undefined. 1364 // The feedback can be an AllocationSite or undefined.
1361 site = Handle<AllocationSite>::cast(feedback); 1365 site = Handle<AllocationSite>::cast(feedback);
1362 } 1366 }
1363 return Runtime_NewObjectHelper(isolate, constructor, site); 1367 return Runtime_NewObjectHelper(isolate, constructor, original_constructor,
1368 site);
1364 } 1369 }
1365 1370
1366 1371
1367 RUNTIME_FUNCTION(Runtime_FinalizeInstanceSize) { 1372 RUNTIME_FUNCTION(Runtime_FinalizeInstanceSize) {
1368 HandleScope scope(isolate); 1373 HandleScope scope(isolate);
1369 DCHECK(args.length() == 1); 1374 DCHECK(args.length() == 1);
1370 1375
1371 CONVERT_ARG_HANDLE_CHECKED(JSFunction, function, 0); 1376 CONVERT_ARG_HANDLE_CHECKED(JSFunction, function, 0);
1372 function->CompleteInobjectSlackTracking(); 1377 function->CompleteInobjectSlackTracking();
1373 1378
(...skipping 257 matching lines...) Expand 10 before | Expand all | Expand 10 after
1631 CONVERT_ARG_HANDLE_CHECKED(JSFunction, setter, 2); 1636 CONVERT_ARG_HANDLE_CHECKED(JSFunction, setter, 2);
1632 1637
1633 RETURN_FAILURE_ON_EXCEPTION( 1638 RETURN_FAILURE_ON_EXCEPTION(
1634 isolate, 1639 isolate,
1635 JSObject::DefineAccessor(object, name, isolate->factory()->null_value(), 1640 JSObject::DefineAccessor(object, name, isolate->factory()->null_value(),
1636 setter, NONE)); 1641 setter, NONE));
1637 return isolate->heap()->undefined_value(); 1642 return isolate->heap()->undefined_value();
1638 } 1643 }
1639 } 1644 }
1640 } // namespace v8::internal 1645 } // namespace v8::internal
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698