| OLD | NEW |
| 1 // Copyright 2006-2009 the V8 project authors. All rights reserved. | 1 // Copyright 2006-2009 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 4141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4152 | 4152 |
| 4153 static Object* Runtime_NewObject(Arguments args) { | 4153 static Object* Runtime_NewObject(Arguments args) { |
| 4154 NoHandleAllocation ha; | 4154 NoHandleAllocation ha; |
| 4155 ASSERT(args.length() == 1); | 4155 ASSERT(args.length() == 1); |
| 4156 | 4156 |
| 4157 Object* constructor = args[0]; | 4157 Object* constructor = args[0]; |
| 4158 if (constructor->IsJSFunction()) { | 4158 if (constructor->IsJSFunction()) { |
| 4159 JSFunction* function = JSFunction::cast(constructor); | 4159 JSFunction* function = JSFunction::cast(constructor); |
| 4160 | 4160 |
| 4161 // Handle stepping into constructors if step into is active. | 4161 // Handle stepping into constructors if step into is active. |
| 4162 #ifdef ENABLE_DEBUGGER_SUPPORT |
| 4162 if (Debug::StepInActive()) { | 4163 if (Debug::StepInActive()) { |
| 4163 HandleScope scope; | 4164 HandleScope scope; |
| 4164 Debug::HandleStepIn(Handle<JSFunction>(function), 0, true); | 4165 Debug::HandleStepIn(Handle<JSFunction>(function), 0, true); |
| 4165 } | 4166 } |
| 4167 #endif |
| 4166 | 4168 |
| 4167 if (function->has_initial_map() && | 4169 if (function->has_initial_map() && |
| 4168 function->initial_map()->instance_type() == JS_FUNCTION_TYPE) { | 4170 function->initial_map()->instance_type() == JS_FUNCTION_TYPE) { |
| 4169 // The 'Function' function ignores the receiver object when | 4171 // The 'Function' function ignores the receiver object when |
| 4170 // called using 'new' and creates a new JSFunction object that | 4172 // called using 'new' and creates a new JSFunction object that |
| 4171 // is returned. The receiver object is only used for error | 4173 // is returned. The receiver object is only used for error |
| 4172 // reporting if an error occurs when constructing the new | 4174 // reporting if an error occurs when constructing the new |
| 4173 // JSFunction. AllocateJSObject should not be used to allocate | 4175 // JSFunction. AllocateJSObject should not be used to allocate |
| 4174 // JSFunctions since it does not properly initialize the shared | 4176 // JSFunctions since it does not properly initialize the shared |
| 4175 // part of the function. Since the receiver is ignored anyway, | 4177 // part of the function. Since the receiver is ignored anyway, |
| (...skipping 343 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4519 return Top::Throw(*reference_error); | 4521 return Top::Throw(*reference_error); |
| 4520 } | 4522 } |
| 4521 | 4523 |
| 4522 | 4524 |
| 4523 static Object* Runtime_StackOverflow(Arguments args) { | 4525 static Object* Runtime_StackOverflow(Arguments args) { |
| 4524 NoHandleAllocation na; | 4526 NoHandleAllocation na; |
| 4525 return Top::StackOverflow(); | 4527 return Top::StackOverflow(); |
| 4526 } | 4528 } |
| 4527 | 4529 |
| 4528 | 4530 |
| 4529 static Object* Runtime_DebugBreak(Arguments args) { | |
| 4530 ASSERT(args.length() == 0); | |
| 4531 return Execution::DebugBreakHelper(); | |
| 4532 } | |
| 4533 | |
| 4534 | |
| 4535 static Object* Runtime_StackGuard(Arguments args) { | 4531 static Object* Runtime_StackGuard(Arguments args) { |
| 4536 ASSERT(args.length() == 1); | 4532 ASSERT(args.length() == 1); |
| 4537 | 4533 |
| 4538 // First check if this is a real stack overflow. | 4534 // First check if this is a real stack overflow. |
| 4539 if (StackGuard::IsStackOverflow()) { | 4535 if (StackGuard::IsStackOverflow()) { |
| 4540 return Runtime_StackOverflow(args); | 4536 return Runtime_StackOverflow(args); |
| 4541 } | 4537 } |
| 4542 | 4538 |
| 4543 return Execution::HandleStackGuardInterrupt(); | 4539 return Execution::HandleStackGuardInterrupt(); |
| 4544 } | 4540 } |
| (...skipping 765 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5310 | 5306 |
| 5311 static Object* Runtime_LookupAccessor(Arguments args) { | 5307 static Object* Runtime_LookupAccessor(Arguments args) { |
| 5312 ASSERT(args.length() == 3); | 5308 ASSERT(args.length() == 3); |
| 5313 CONVERT_CHECKED(JSObject, obj, args[0]); | 5309 CONVERT_CHECKED(JSObject, obj, args[0]); |
| 5314 CONVERT_CHECKED(String, name, args[1]); | 5310 CONVERT_CHECKED(String, name, args[1]); |
| 5315 CONVERT_CHECKED(Smi, flag, args[2]); | 5311 CONVERT_CHECKED(Smi, flag, args[2]); |
| 5316 return obj->LookupAccessor(name, flag->value() == 0); | 5312 return obj->LookupAccessor(name, flag->value() == 0); |
| 5317 } | 5313 } |
| 5318 | 5314 |
| 5319 | 5315 |
| 5316 #ifdef ENABLE_DEBUGGER_SUPPORT |
| 5317 static Object* Runtime_DebugBreak(Arguments args) { |
| 5318 ASSERT(args.length() == 0); |
| 5319 return Execution::DebugBreakHelper(); |
| 5320 } |
| 5321 |
| 5322 |
| 5320 // Helper functions for wrapping and unwrapping stack frame ids. | 5323 // Helper functions for wrapping and unwrapping stack frame ids. |
| 5321 static Smi* WrapFrameId(StackFrame::Id id) { | 5324 static Smi* WrapFrameId(StackFrame::Id id) { |
| 5322 ASSERT(IsAligned(OffsetFrom(id), 4)); | 5325 ASSERT(IsAligned(OffsetFrom(id), 4)); |
| 5323 return Smi::FromInt(id >> 2); | 5326 return Smi::FromInt(id >> 2); |
| 5324 } | 5327 } |
| 5325 | 5328 |
| 5326 | 5329 |
| 5327 static StackFrame::Id UnwrapFrameId(Smi* wrapped) { | 5330 static StackFrame::Id UnwrapFrameId(Smi* wrapped) { |
| 5328 return static_cast<StackFrame::Id>(wrapped->value() << 2); | 5331 return static_cast<StackFrame::Id>(wrapped->value() << 2); |
| 5329 } | 5332 } |
| (...skipping 1460 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6790 } | 6793 } |
| 6791 | 6794 |
| 6792 | 6795 |
| 6793 static Object* Runtime_SystemBreak(Arguments args) { | 6796 static Object* Runtime_SystemBreak(Arguments args) { |
| 6794 ASSERT(args.length() == 0); | 6797 ASSERT(args.length() == 0); |
| 6795 CPU::DebugBreak(); | 6798 CPU::DebugBreak(); |
| 6796 return Heap::undefined_value(); | 6799 return Heap::undefined_value(); |
| 6797 } | 6800 } |
| 6798 | 6801 |
| 6799 | 6802 |
| 6803 static Object* Runtime_FunctionGetAssemblerCode(Arguments args) { |
| 6804 #ifdef DEBUG |
| 6805 HandleScope scope; |
| 6806 ASSERT(args.length() == 1); |
| 6807 // Get the function and make sure it is compiled. |
| 6808 CONVERT_ARG_CHECKED(JSFunction, func, 0); |
| 6809 if (!func->is_compiled() && !CompileLazy(func, KEEP_EXCEPTION)) { |
| 6810 return Failure::Exception(); |
| 6811 } |
| 6812 func->code()->PrintLn(); |
| 6813 #endif // DEBUG |
| 6814 return Heap::undefined_value(); |
| 6815 } |
| 6816 #endif // ENABLE_DEBUGGER_SUPPORT |
| 6817 |
| 6800 // Finds the script object from the script data. NOTE: This operation uses | 6818 // Finds the script object from the script data. NOTE: This operation uses |
| 6801 // heap traversal to find the function generated for the source position | 6819 // heap traversal to find the function generated for the source position |
| 6802 // for the requested break point. For lazily compiled functions several heap | 6820 // for the requested break point. For lazily compiled functions several heap |
| 6803 // traversals might be required rendering this operation as a rather slow | 6821 // traversals might be required rendering this operation as a rather slow |
| 6804 // operation. However for setting break points which is normally done through | 6822 // operation. However for setting break points which is normally done through |
| 6805 // some kind of user interaction the performance is not crucial. | 6823 // some kind of user interaction the performance is not crucial. |
| 6806 static Handle<Object> Runtime_GetScriptFromScriptName( | 6824 static Handle<Object> Runtime_GetScriptFromScriptName( |
| 6807 Handle<String> script_name) { | 6825 Handle<String> script_name) { |
| 6808 // Scan the heap for Script objects to find the script with the requested | 6826 // Scan the heap for Script objects to find the script with the requested |
| 6809 // script data. | 6827 // script data. |
| (...skipping 29 matching lines...) Expand all Loading... |
| 6839 | 6857 |
| 6840 CONVERT_CHECKED(String, script_name, args[0]); | 6858 CONVERT_CHECKED(String, script_name, args[0]); |
| 6841 | 6859 |
| 6842 // Find the requested script. | 6860 // Find the requested script. |
| 6843 Handle<Object> result = | 6861 Handle<Object> result = |
| 6844 Runtime_GetScriptFromScriptName(Handle<String>(script_name)); | 6862 Runtime_GetScriptFromScriptName(Handle<String>(script_name)); |
| 6845 return *result; | 6863 return *result; |
| 6846 } | 6864 } |
| 6847 | 6865 |
| 6848 | 6866 |
| 6849 static Object* Runtime_FunctionGetAssemblerCode(Arguments args) { | |
| 6850 #ifdef DEBUG | |
| 6851 HandleScope scope; | |
| 6852 ASSERT(args.length() == 1); | |
| 6853 // Get the function and make sure it is compiled. | |
| 6854 CONVERT_ARG_CHECKED(JSFunction, func, 0); | |
| 6855 if (!func->is_compiled() && !CompileLazy(func, KEEP_EXCEPTION)) { | |
| 6856 return Failure::Exception(); | |
| 6857 } | |
| 6858 func->code()->PrintLn(); | |
| 6859 #endif // DEBUG | |
| 6860 return Heap::undefined_value(); | |
| 6861 } | |
| 6862 | |
| 6863 | |
| 6864 static Object* Runtime_Abort(Arguments args) { | 6867 static Object* Runtime_Abort(Arguments args) { |
| 6865 ASSERT(args.length() == 2); | 6868 ASSERT(args.length() == 2); |
| 6866 OS::PrintError("abort: %s\n", reinterpret_cast<char*>(args[0]) + | 6869 OS::PrintError("abort: %s\n", reinterpret_cast<char*>(args[0]) + |
| 6867 Smi::cast(args[1])->value()); | 6870 Smi::cast(args[1])->value()); |
| 6868 Top::PrintStack(); | 6871 Top::PrintStack(); |
| 6869 OS::Abort(); | 6872 OS::Abort(); |
| 6870 UNREACHABLE(); | 6873 UNREACHABLE(); |
| 6871 return NULL; | 6874 return NULL; |
| 6872 } | 6875 } |
| 6873 | 6876 |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6953 } else { | 6956 } else { |
| 6954 // Handle last resort GC and make sure to allow future allocations | 6957 // Handle last resort GC and make sure to allow future allocations |
| 6955 // to grow the heap without causing GCs (if possible). | 6958 // to grow the heap without causing GCs (if possible). |
| 6956 Counters::gc_last_resort_from_js.Increment(); | 6959 Counters::gc_last_resort_from_js.Increment(); |
| 6957 Heap::CollectAllGarbage(); | 6960 Heap::CollectAllGarbage(); |
| 6958 } | 6961 } |
| 6959 } | 6962 } |
| 6960 | 6963 |
| 6961 | 6964 |
| 6962 } } // namespace v8::internal | 6965 } } // namespace v8::internal |
| OLD | NEW |