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

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: Fix x64 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
« no previous file with comments | « src/runtime/runtime.h ('k') | src/x64/builtins-x64.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 1261 matching lines...) Expand 10 before | Expand all | Expand 10 after
1272 1272
1273 RUNTIME_FUNCTION(Runtime_AllocateHeapNumber) { 1273 RUNTIME_FUNCTION(Runtime_AllocateHeapNumber) {
1274 HandleScope scope(isolate); 1274 HandleScope scope(isolate);
1275 DCHECK(args.length() == 0); 1275 DCHECK(args.length() == 0);
1276 return *isolate->factory()->NewHeapNumber(0); 1276 return *isolate->factory()->NewHeapNumber(0);
1277 } 1277 }
1278 1278
1279 1279
1280 static Object* Runtime_NewObjectHelper(Isolate* isolate, 1280 static Object* Runtime_NewObjectHelper(Isolate* isolate,
1281 Handle<Object> constructor, 1281 Handle<Object> constructor,
1282 Handle<Object> original_constructor,
1282 Handle<AllocationSite> site) { 1283 Handle<AllocationSite> site) {
1284 // TODO(dslomov): implement prototype rewiring.
1285 // The check below is a sanity check.
1286 CHECK(*constructor == *original_constructor);
1287
1283 // If the constructor isn't a proper function we throw a type error. 1288 // If the constructor isn't a proper function we throw a type error.
1284 if (!constructor->IsJSFunction()) { 1289 if (!constructor->IsJSFunction()) {
1285 Vector<Handle<Object> > arguments = HandleVector(&constructor, 1); 1290 Vector<Handle<Object> > arguments = HandleVector(&constructor, 1);
1286 THROW_NEW_ERROR_RETURN_FAILURE(isolate, 1291 THROW_NEW_ERROR_RETURN_FAILURE(isolate,
1287 NewTypeError("not_constructor", arguments)); 1292 NewTypeError("not_constructor", arguments));
1288 } 1293 }
1289 1294
1290 Handle<JSFunction> function = Handle<JSFunction>::cast(constructor); 1295 Handle<JSFunction> function = Handle<JSFunction>::cast(constructor);
1291 1296
1292 // If function should not have prototype, construction is not allowed. In this 1297 // If function should not have prototype, construction is not allowed. In this
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
1333 1338
1334 isolate->counters()->constructed_objects()->Increment(); 1339 isolate->counters()->constructed_objects()->Increment();
1335 isolate->counters()->constructed_objects_runtime()->Increment(); 1340 isolate->counters()->constructed_objects_runtime()->Increment();
1336 1341
1337 return *result; 1342 return *result;
1338 } 1343 }
1339 1344
1340 1345
1341 RUNTIME_FUNCTION(Runtime_NewObject) { 1346 RUNTIME_FUNCTION(Runtime_NewObject) {
1342 HandleScope scope(isolate); 1347 HandleScope scope(isolate);
1343 DCHECK(args.length() == 1); 1348 DCHECK(args.length() == 2);
1344 CONVERT_ARG_HANDLE_CHECKED(Object, constructor, 0); 1349 CONVERT_ARG_HANDLE_CHECKED(Object, constructor, 0);
1345 return Runtime_NewObjectHelper(isolate, constructor, 1350 CONVERT_ARG_HANDLE_CHECKED(Object, original_constructor, 1);
1351 return Runtime_NewObjectHelper(isolate, constructor, original_constructor,
1346 Handle<AllocationSite>::null()); 1352 Handle<AllocationSite>::null());
1347 } 1353 }
1348 1354
1349 1355
1350 RUNTIME_FUNCTION(Runtime_NewObjectWithAllocationSite) { 1356 RUNTIME_FUNCTION(Runtime_NewObjectWithAllocationSite) {
1351 HandleScope scope(isolate); 1357 HandleScope scope(isolate);
1352 DCHECK(args.length() == 2); 1358 DCHECK(args.length() == 3);
1359 CONVERT_ARG_HANDLE_CHECKED(Object, original_constructor, 2);
1353 CONVERT_ARG_HANDLE_CHECKED(Object, constructor, 1); 1360 CONVERT_ARG_HANDLE_CHECKED(Object, constructor, 1);
1354 CONVERT_ARG_HANDLE_CHECKED(Object, feedback, 0); 1361 CONVERT_ARG_HANDLE_CHECKED(Object, feedback, 0);
1355 Handle<AllocationSite> site; 1362 Handle<AllocationSite> site;
1356 if (feedback->IsAllocationSite()) { 1363 if (feedback->IsAllocationSite()) {
1357 // The feedback can be an AllocationSite or undefined. 1364 // The feedback can be an AllocationSite or undefined.
1358 site = Handle<AllocationSite>::cast(feedback); 1365 site = Handle<AllocationSite>::cast(feedback);
1359 } 1366 }
1360 return Runtime_NewObjectHelper(isolate, constructor, site); 1367 return Runtime_NewObjectHelper(isolate, constructor, original_constructor,
1368 site);
1361 } 1369 }
1362 1370
1363 1371
1364 RUNTIME_FUNCTION(Runtime_FinalizeInstanceSize) { 1372 RUNTIME_FUNCTION(Runtime_FinalizeInstanceSize) {
1365 HandleScope scope(isolate); 1373 HandleScope scope(isolate);
1366 DCHECK(args.length() == 1); 1374 DCHECK(args.length() == 1);
1367 1375
1368 CONVERT_ARG_HANDLE_CHECKED(JSFunction, function, 0); 1376 CONVERT_ARG_HANDLE_CHECKED(JSFunction, function, 0);
1369 function->CompleteInobjectSlackTracking(); 1377 function->CompleteInobjectSlackTracking();
1370 1378
(...skipping 257 matching lines...) Expand 10 before | Expand all | Expand 10 after
1628 CONVERT_ARG_HANDLE_CHECKED(JSFunction, setter, 2); 1636 CONVERT_ARG_HANDLE_CHECKED(JSFunction, setter, 2);
1629 1637
1630 RETURN_FAILURE_ON_EXCEPTION( 1638 RETURN_FAILURE_ON_EXCEPTION(
1631 isolate, 1639 isolate,
1632 JSObject::DefineAccessor(object, name, isolate->factory()->null_value(), 1640 JSObject::DefineAccessor(object, name, isolate->factory()->null_value(),
1633 setter, NONE)); 1641 setter, NONE));
1634 return isolate->heap()->undefined_value(); 1642 return isolate->heap()->undefined_value();
1635 } 1643 }
1636 } 1644 }
1637 } // namespace v8::internal 1645 } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/runtime/runtime.h ('k') | src/x64/builtins-x64.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698