| 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 9043 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 9054 static Object* Runtime_SetFunctionBreakPoint(Arguments args) { | 9054 static Object* Runtime_SetFunctionBreakPoint(Arguments args) { |
| 9055 HandleScope scope; | 9055 HandleScope scope; |
| 9056 ASSERT(args.length() == 3); | 9056 ASSERT(args.length() == 3); |
| 9057 CONVERT_ARG_CHECKED(JSFunction, fun, 0); | 9057 CONVERT_ARG_CHECKED(JSFunction, fun, 0); |
| 9058 Handle<SharedFunctionInfo> shared(fun->shared()); | 9058 Handle<SharedFunctionInfo> shared(fun->shared()); |
| 9059 CONVERT_NUMBER_CHECKED(int32_t, source_position, Int32, args[1]); | 9059 CONVERT_NUMBER_CHECKED(int32_t, source_position, Int32, args[1]); |
| 9060 RUNTIME_ASSERT(source_position >= 0); | 9060 RUNTIME_ASSERT(source_position >= 0); |
| 9061 Handle<Object> break_point_object_arg = args.at<Object>(2); | 9061 Handle<Object> break_point_object_arg = args.at<Object>(2); |
| 9062 | 9062 |
| 9063 // Set break point. | 9063 // Set break point. |
| 9064 Debug::SetBreakPoint(shared, source_position, break_point_object_arg); | 9064 Debug::SetBreakPoint(shared, break_point_object_arg, &source_position); |
| 9065 | 9065 |
| 9066 return Heap::undefined_value(); | 9066 return Heap::undefined_value(); |
| 9067 } | 9067 } |
| 9068 | 9068 |
| 9069 | 9069 |
| 9070 Object* Runtime::FindSharedFunctionInfoInScript(Handle<Script> script, | 9070 Object* Runtime::FindSharedFunctionInfoInScript(Handle<Script> script, |
| 9071 int position) { | 9071 int position) { |
| 9072 // Iterate the heap looking for SharedFunctionInfo generated from the | 9072 // Iterate the heap looking for SharedFunctionInfo generated from the |
| 9073 // script. The inner most SharedFunctionInfo containing the source position | 9073 // script. The inner most SharedFunctionInfo containing the source position |
| 9074 // for the requested break point is found. | 9074 // for the requested break point is found. |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 9152 // If the candidate is not compiled compile it to reveal any inner | 9152 // If the candidate is not compiled compile it to reveal any inner |
| 9153 // functions which might contain the requested source position. | 9153 // functions which might contain the requested source position. |
| 9154 CompileLazyShared(target, KEEP_EXCEPTION); | 9154 CompileLazyShared(target, KEEP_EXCEPTION); |
| 9155 } | 9155 } |
| 9156 } | 9156 } |
| 9157 | 9157 |
| 9158 return *target; | 9158 return *target; |
| 9159 } | 9159 } |
| 9160 | 9160 |
| 9161 | 9161 |
| 9162 // Change the state of a break point in a script. NOTE: Regarding performance | 9162 // Changes the state of a break point in a script and returns source position |
| 9163 // see the NOTE for GetScriptFromScriptData. | 9163 // where break point was set. NOTE: Regarding performance see the NOTE for |
| 9164 // GetScriptFromScriptData. |
| 9164 // args[0]: script to set break point in | 9165 // args[0]: script to set break point in |
| 9165 // args[1]: number: break source position (within the script source) | 9166 // args[1]: number: break source position (within the script source) |
| 9166 // args[2]: number: break point object | 9167 // args[2]: number: break point object |
| 9167 static Object* Runtime_SetScriptBreakPoint(Arguments args) { | 9168 static Object* Runtime_SetScriptBreakPoint(Arguments args) { |
| 9168 HandleScope scope; | 9169 HandleScope scope; |
| 9169 ASSERT(args.length() == 3); | 9170 ASSERT(args.length() == 3); |
| 9170 CONVERT_ARG_CHECKED(JSValue, wrapper, 0); | 9171 CONVERT_ARG_CHECKED(JSValue, wrapper, 0); |
| 9171 CONVERT_NUMBER_CHECKED(int32_t, source_position, Int32, args[1]); | 9172 CONVERT_NUMBER_CHECKED(int32_t, source_position, Int32, args[1]); |
| 9172 RUNTIME_ASSERT(source_position >= 0); | 9173 RUNTIME_ASSERT(source_position >= 0); |
| 9173 Handle<Object> break_point_object_arg = args.at<Object>(2); | 9174 Handle<Object> break_point_object_arg = args.at<Object>(2); |
| 9174 | 9175 |
| 9175 // Get the script from the script wrapper. | 9176 // Get the script from the script wrapper. |
| 9176 RUNTIME_ASSERT(wrapper->value()->IsScript()); | 9177 RUNTIME_ASSERT(wrapper->value()->IsScript()); |
| 9177 Handle<Script> script(Script::cast(wrapper->value())); | 9178 Handle<Script> script(Script::cast(wrapper->value())); |
| 9178 | 9179 |
| 9179 Object* result = Runtime::FindSharedFunctionInfoInScript( | 9180 Object* result = Runtime::FindSharedFunctionInfoInScript( |
| 9180 script, source_position); | 9181 script, source_position); |
| 9181 if (!result->IsUndefined()) { | 9182 if (!result->IsUndefined()) { |
| 9182 Handle<SharedFunctionInfo> shared(SharedFunctionInfo::cast(result)); | 9183 Handle<SharedFunctionInfo> shared(SharedFunctionInfo::cast(result)); |
| 9183 // Find position within function. The script position might be before the | 9184 // Find position within function. The script position might be before the |
| 9184 // source position of the first function. | 9185 // source position of the first function. |
| 9185 int position; | 9186 int position; |
| 9186 if (shared->start_position() > source_position) { | 9187 if (shared->start_position() > source_position) { |
| 9187 position = 0; | 9188 position = 0; |
| 9188 } else { | 9189 } else { |
| 9189 position = source_position - shared->start_position(); | 9190 position = source_position - shared->start_position(); |
| 9190 } | 9191 } |
| 9191 Debug::SetBreakPoint(shared, position, break_point_object_arg); | 9192 Debug::SetBreakPoint(shared, break_point_object_arg, &position); |
| 9193 position += shared->start_position(); |
| 9194 return Smi::FromInt(position); |
| 9192 } | 9195 } |
| 9193 return Heap::undefined_value(); | 9196 return Heap::undefined_value(); |
| 9194 } | 9197 } |
| 9195 | 9198 |
| 9196 | 9199 |
| 9197 // Clear a break point | 9200 // Clear a break point |
| 9198 // args[0]: number: break point object | 9201 // args[0]: number: break point object |
| 9199 static Object* Runtime_ClearBreakPoint(Arguments args) { | 9202 static Object* Runtime_ClearBreakPoint(Arguments args) { |
| 9200 HandleScope scope; | 9203 HandleScope scope; |
| 9201 ASSERT(args.length() == 1); | 9204 ASSERT(args.length() == 1); |
| (...skipping 1189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 10391 } else { | 10394 } else { |
| 10392 // Handle last resort GC and make sure to allow future allocations | 10395 // Handle last resort GC and make sure to allow future allocations |
| 10393 // to grow the heap without causing GCs (if possible). | 10396 // to grow the heap without causing GCs (if possible). |
| 10394 Counters::gc_last_resort_from_js.Increment(); | 10397 Counters::gc_last_resort_from_js.Increment(); |
| 10395 Heap::CollectAllGarbage(false); | 10398 Heap::CollectAllGarbage(false); |
| 10396 } | 10399 } |
| 10397 } | 10400 } |
| 10398 | 10401 |
| 10399 | 10402 |
| 10400 } } // namespace v8::internal | 10403 } } // namespace v8::internal |
| OLD | NEW |