OLD | NEW |
1 // Copyright 2010 the V8 project authors. All rights reserved. | 1 // Copyright 2010 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 10388 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
10399 } | 10399 } |
10400 } | 10400 } |
10401 if (!pending_exception) { | 10401 if (!pending_exception) { |
10402 return *result; | 10402 return *result; |
10403 } else { | 10403 } else { |
10404 return Failure::Exception(); | 10404 return Failure::Exception(); |
10405 } | 10405 } |
10406 } | 10406 } |
10407 | 10407 |
10408 | 10408 |
| 10409 // Sets a v8 flag. |
| 10410 static MaybeObject* Runtime_SetFlags(Arguments args) { |
| 10411 CONVERT_CHECKED(String, arg, args[0]); |
| 10412 SmartPointer<char> flags = |
| 10413 arg->ToCString(DISALLOW_NULLS, ROBUST_STRING_TRAVERSAL); |
| 10414 FlagList::SetFlagsFromString(*flags, strlen(*flags)); |
| 10415 return Heap::undefined_value(); |
| 10416 } |
| 10417 |
| 10418 |
| 10419 // Performs a GC. |
| 10420 // Presently, it only does a full GC. |
| 10421 static MaybeObject* Runtime_CollectGarbage(Arguments args) { |
| 10422 Heap::CollectAllGarbage(true); |
| 10423 return Heap::undefined_value(); |
| 10424 } |
| 10425 |
| 10426 |
| 10427 // Gets the current heap usage. |
| 10428 static MaybeObject* Runtime_GetHeapUsage(Arguments args) { |
| 10429 int usage = Heap::SizeOfObjects(); |
| 10430 if (!Smi::IsValid(usage)) { |
| 10431 return *Factory::NewNumberFromInt(usage); |
| 10432 } |
| 10433 return Smi::FromInt(usage); |
| 10434 } |
10409 #endif // ENABLE_DEBUGGER_SUPPORT | 10435 #endif // ENABLE_DEBUGGER_SUPPORT |
10410 | 10436 |
| 10437 |
10411 #ifdef ENABLE_LOGGING_AND_PROFILING | 10438 #ifdef ENABLE_LOGGING_AND_PROFILING |
10412 | |
10413 static MaybeObject* Runtime_ProfilerResume(Arguments args) { | 10439 static MaybeObject* Runtime_ProfilerResume(Arguments args) { |
10414 NoHandleAllocation ha; | 10440 NoHandleAllocation ha; |
10415 ASSERT(args.length() == 2); | 10441 ASSERT(args.length() == 2); |
10416 | 10442 |
10417 CONVERT_CHECKED(Smi, smi_modules, args[0]); | 10443 CONVERT_CHECKED(Smi, smi_modules, args[0]); |
10418 CONVERT_CHECKED(Smi, smi_tag, args[1]); | 10444 CONVERT_CHECKED(Smi, smi_tag, args[1]); |
10419 v8::V8::ResumeProfilerEx(smi_modules->value(), smi_tag->value()); | 10445 v8::V8::ResumeProfilerEx(smi_modules->value(), smi_tag->value()); |
10420 return Heap::undefined_value(); | 10446 return Heap::undefined_value(); |
10421 } | 10447 } |
10422 | 10448 |
(...skipping 373 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
10796 } else { | 10822 } else { |
10797 // Handle last resort GC and make sure to allow future allocations | 10823 // Handle last resort GC and make sure to allow future allocations |
10798 // to grow the heap without causing GCs (if possible). | 10824 // to grow the heap without causing GCs (if possible). |
10799 Counters::gc_last_resort_from_js.Increment(); | 10825 Counters::gc_last_resort_from_js.Increment(); |
10800 Heap::CollectAllGarbage(false); | 10826 Heap::CollectAllGarbage(false); |
10801 } | 10827 } |
10802 } | 10828 } |
10803 | 10829 |
10804 | 10830 |
10805 } } // namespace v8::internal | 10831 } } // namespace v8::internal |
OLD | NEW |