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

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

Issue 716853003: Classes: Add support for arguments in default constructor (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 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 | Annotate | Revision Log
« no previous file with comments | « src/runtime/runtime.h ('k') | src/runtime/runtime-object.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 <stdlib.h> 5 #include <stdlib.h>
6 #include <limits> 6 #include <limits>
7 7
8 #include "src/v8.h" 8 #include "src/v8.h"
9 9
10 #include "src/isolate-inl.h" 10 #include "src/isolate-inl.h"
(...skipping 418 matching lines...) Expand 10 before | Expand all | Expand 10 after
429 RUNTIME_FUNCTION(Runtime_StoreKeyedToSuper_Sloppy) { 429 RUNTIME_FUNCTION(Runtime_StoreKeyedToSuper_Sloppy) {
430 HandleScope scope(isolate); 430 HandleScope scope(isolate);
431 DCHECK(args.length() == 4); 431 DCHECK(args.length() == 4);
432 CONVERT_ARG_HANDLE_CHECKED(Object, receiver, 0); 432 CONVERT_ARG_HANDLE_CHECKED(Object, receiver, 0);
433 CONVERT_ARG_HANDLE_CHECKED(JSObject, home_object, 1); 433 CONVERT_ARG_HANDLE_CHECKED(JSObject, home_object, 1);
434 CONVERT_ARG_HANDLE_CHECKED(Object, key, 2); 434 CONVERT_ARG_HANDLE_CHECKED(Object, key, 2);
435 CONVERT_ARG_HANDLE_CHECKED(Object, value, 3); 435 CONVERT_ARG_HANDLE_CHECKED(Object, value, 3);
436 436
437 return StoreKeyedToSuper(isolate, home_object, receiver, key, value, SLOPPY); 437 return StoreKeyedToSuper(isolate, home_object, receiver, key, value, SLOPPY);
438 } 438 }
439
440
441 RUNTIME_FUNCTION(Runtime_DefaultConstructorSuperCall) {
442 HandleScope scope(isolate);
443 DCHECK(args.length() == 0);
444
445 // Compute the frame holding the arguments.
446 JavaScriptFrameIterator it(isolate);
447 it.AdvanceToArgumentsFrame();
448 JavaScriptFrame* frame = it.frame();
449
450 Handle<JSFunction> function(frame->function(), isolate);
451 Handle<Object> receiver(frame->receiver(), isolate);
452
453 Handle<Object> proto_function;
454 ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, proto_function,
455 Runtime::GetPrototype(isolate, function));
456
457 // Get the actual number of provided arguments.
458 const int argc = frame->ComputeParametersCount();
459
460 // Loose upper bound to allow fuzzing. We'll most likely run out of
461 // stack space before hitting this limit.
462 static int kMaxArgc = 1000000;
463 RUNTIME_ASSERT(argc >= 0 && argc <= kMaxArgc);
464
465 // If there are too many arguments, allocate argv via malloc.
466 const int argv_small_size = 10;
467 Handle<Object> argv_small_buffer[argv_small_size];
468 SmartArrayPointer<Handle<Object> > argv_large_buffer;
469 Handle<Object>* argv = argv_small_buffer;
470 if (argc > argv_small_size) {
471 argv = new Handle<Object>[argc];
472 if (argv == NULL) return isolate->StackOverflow();
473 argv_large_buffer = SmartArrayPointer<Handle<Object> >(argv);
474 }
475
476 for (int i = 0; i < argc; ++i) {
477 argv[i] = handle(frame->GetParameter(i), isolate);
478 }
479
480 Handle<Object> result;
481 ASSIGN_RETURN_FAILURE_ON_EXCEPTION(
482 isolate, result,
483 Execution::Call(isolate, proto_function, receiver, argc, argv, false));
484 return *result;
485 }
439 } 486 }
440 } // namespace v8::internal 487 } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/runtime/runtime.h ('k') | src/runtime/runtime-object.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698