OLD | NEW |
1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
(...skipping 8503 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8514 } | 8514 } |
8515 } | 8515 } |
8516 | 8516 |
8517 | 8517 |
8518 RUNTIME_FUNCTION(MaybeObject*, Runtime_CheckIsBootstrapping) { | 8518 RUNTIME_FUNCTION(MaybeObject*, Runtime_CheckIsBootstrapping) { |
8519 RUNTIME_ASSERT(isolate->bootstrapper()->IsActive()); | 8519 RUNTIME_ASSERT(isolate->bootstrapper()->IsActive()); |
8520 return isolate->heap()->undefined_value(); | 8520 return isolate->heap()->undefined_value(); |
8521 } | 8521 } |
8522 | 8522 |
8523 | 8523 |
| 8524 RUNTIME_FUNCTION(MaybeObject*, Runtime_Call) { |
| 8525 HandleScope scope(isolate); |
| 8526 ASSERT(args.length() >= 2); |
| 8527 CONVERT_CHECKED(JSReceiver, fun, args[args.length() - 1]); |
| 8528 Object* receiver = args[0]; |
| 8529 int argc = args.length() - 2; |
| 8530 |
| 8531 // If there are too many arguments, allocate argv via malloc. |
| 8532 const int argv_small_size = 10; |
| 8533 Handle<Object> argv_small_buffer[argv_small_size]; |
| 8534 SmartArrayPointer<Handle<Object> > argv_large_buffer; |
| 8535 Handle<Object>* argv = argv_small_buffer; |
| 8536 if (argc > argv_small_size) { |
| 8537 argv = new Handle<Object>[argc]; |
| 8538 if (argv == NULL) return isolate->StackOverflow(); |
| 8539 argv_large_buffer = SmartArrayPointer<Handle<Object> >(argv); |
| 8540 } |
| 8541 |
| 8542 for (int i = 0; i < argc; ++i) { |
| 8543 MaybeObject* maybe = args[1 + i]; |
| 8544 Object* object; |
| 8545 if (!maybe->To<Object>(&object)) return maybe; |
| 8546 argv[i] = Handle<Object>(object); |
| 8547 } |
| 8548 |
| 8549 bool threw; |
| 8550 Handle<JSReceiver> hfun(fun); |
| 8551 Handle<Object> hreceiver(receiver); |
| 8552 Handle<Object> result = |
| 8553 Execution::Call(hfun, hreceiver, argc, argv, &threw, true); |
| 8554 |
| 8555 if (threw) return Failure::Exception(); |
| 8556 return *result; |
| 8557 } |
| 8558 |
| 8559 |
8524 RUNTIME_FUNCTION(MaybeObject*, Runtime_Apply) { | 8560 RUNTIME_FUNCTION(MaybeObject*, Runtime_Apply) { |
8525 HandleScope scope(isolate); | 8561 HandleScope scope(isolate); |
8526 ASSERT(args.length() == 5); | 8562 ASSERT(args.length() == 5); |
8527 CONVERT_CHECKED(JSReceiver, fun, args[0]); | 8563 CONVERT_CHECKED(JSReceiver, fun, args[0]); |
8528 Object* receiver = args[1]; | 8564 Object* receiver = args[1]; |
8529 CONVERT_CHECKED(JSObject, arguments, args[2]); | 8565 CONVERT_CHECKED(JSObject, arguments, args[2]); |
8530 CONVERT_CHECKED(Smi, shift, args[3]); | 8566 CONVERT_CHECKED(Smi, shift, args[3]); |
8531 CONVERT_CHECKED(Smi, arity, args[4]); | 8567 CONVERT_CHECKED(Smi, arity, args[4]); |
8532 | 8568 |
8533 int offset = shift->value(); | 8569 int offset = shift->value(); |
(...skipping 4812 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
13346 } else { | 13382 } else { |
13347 // Handle last resort GC and make sure to allow future allocations | 13383 // Handle last resort GC and make sure to allow future allocations |
13348 // to grow the heap without causing GCs (if possible). | 13384 // to grow the heap without causing GCs (if possible). |
13349 isolate->counters()->gc_last_resort_from_js()->Increment(); | 13385 isolate->counters()->gc_last_resort_from_js()->Increment(); |
13350 isolate->heap()->CollectAllGarbage(Heap::kNoGCFlags); | 13386 isolate->heap()->CollectAllGarbage(Heap::kNoGCFlags); |
13351 } | 13387 } |
13352 } | 13388 } |
13353 | 13389 |
13354 | 13390 |
13355 } } // namespace v8::internal | 13391 } } // namespace v8::internal |
OLD | NEW |