| 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 9944 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 9955 // NOTE: This might require several heap iterations. If the SharedFunctionInfo | 9955 // NOTE: This might require several heap iterations. If the SharedFunctionInfo |
| 9956 // which is found is not compiled it is compiled and the heap is iterated | 9956 // which is found is not compiled it is compiled and the heap is iterated |
| 9957 // again as the compilation might create inner functions from the newly | 9957 // again as the compilation might create inner functions from the newly |
| 9958 // compiled function and the actual requested break point might be in one of | 9958 // compiled function and the actual requested break point might be in one of |
| 9959 // these functions. | 9959 // these functions. |
| 9960 bool done = false; | 9960 bool done = false; |
| 9961 // The current candidate for the source position: | 9961 // The current candidate for the source position: |
| 9962 int target_start_position = RelocInfo::kNoPosition; | 9962 int target_start_position = RelocInfo::kNoPosition; |
| 9963 Handle<SharedFunctionInfo> target; | 9963 Handle<SharedFunctionInfo> target; |
| 9964 while (!done) { | 9964 while (!done) { |
| 9965 HeapIterator iterator; | 9965 { // Extra scope for iterator and no-allocation. |
| 9966 for (HeapObject* obj = iterator.Next(); | 9966 HeapIterator iterator; |
| 9967 obj != NULL; obj = iterator.Next()) { | 9967 AssertNoAllocation no_alloc_during_heap_iteration; |
| 9968 if (obj->IsSharedFunctionInfo()) { | 9968 for (HeapObject* obj = iterator.Next(); |
| 9969 Handle<SharedFunctionInfo> shared(SharedFunctionInfo::cast(obj)); | 9969 obj != NULL; obj = iterator.Next()) { |
| 9970 if (shared->script() == *script) { | 9970 if (obj->IsSharedFunctionInfo()) { |
| 9971 // If the SharedFunctionInfo found has the requested script data and | 9971 Handle<SharedFunctionInfo> shared(SharedFunctionInfo::cast(obj)); |
| 9972 // contains the source position it is a candidate. | 9972 if (shared->script() == *script) { |
| 9973 int start_position = shared->function_token_position(); | 9973 // If the SharedFunctionInfo found has the requested script data and |
| 9974 if (start_position == RelocInfo::kNoPosition) { | 9974 // contains the source position it is a candidate. |
| 9975 start_position = shared->start_position(); | 9975 int start_position = shared->function_token_position(); |
| 9976 } | 9976 if (start_position == RelocInfo::kNoPosition) { |
| 9977 if (start_position <= position && | 9977 start_position = shared->start_position(); |
| 9978 position <= shared->end_position()) { | 9978 } |
| 9979 // If there is no candidate or this function is within the current | 9979 if (start_position <= position && |
| 9980 // candidate this is the new candidate. | 9980 position <= shared->end_position()) { |
| 9981 if (target.is_null()) { | 9981 // If there is no candidate or this function is within the current |
| 9982 target_start_position = start_position; | 9982 // candidate this is the new candidate. |
| 9983 target = shared; | 9983 if (target.is_null()) { |
| 9984 } else { | 9984 target_start_position = start_position; |
| 9985 if (target_start_position == start_position && | 9985 target = shared; |
| 9986 shared->end_position() == target->end_position()) { | 9986 } else { |
| 9987 // If a top-level function contain only one function | 9987 if (target_start_position == start_position && |
| 9988 // declartion the source for the top-level and the function is | 9988 shared->end_position() == target->end_position()) { |
| 9989 // the same. In that case prefer the non top-level function. | 9989 // If a top-level function contain only one function |
| 9990 if (!shared->is_toplevel()) { | 9990 // declartion the source for the top-level and the |
| 9991 // function is the same. In that case prefer the non |
| 9992 // top-level function. |
| 9993 if (!shared->is_toplevel()) { |
| 9994 target_start_position = start_position; |
| 9995 target = shared; |
| 9996 } |
| 9997 } else if (target_start_position <= start_position && |
| 9998 shared->end_position() <= target->end_position()) { |
| 9999 // This containment check includes equality as a function |
| 10000 // inside a top-level function can share either start or end |
| 10001 // position with the top-level function. |
| 9991 target_start_position = start_position; | 10002 target_start_position = start_position; |
| 9992 target = shared; | 10003 target = shared; |
| 9993 } | 10004 } |
| 9994 } else if (target_start_position <= start_position && | |
| 9995 shared->end_position() <= target->end_position()) { | |
| 9996 // This containment check includes equality as a function inside | |
| 9997 // a top-level function can share either start or end position | |
| 9998 // with the top-level function. | |
| 9999 target_start_position = start_position; | |
| 10000 target = shared; | |
| 10001 } | 10005 } |
| 10002 } | 10006 } |
| 10003 } | 10007 } |
| 10004 } | 10008 } |
| 10005 } | 10009 } // End for loop. |
| 10006 } | 10010 } // End No allocation scope. |
| 10007 | 10011 |
| 10008 if (target.is_null()) { | 10012 if (target.is_null()) { |
| 10009 return Heap::undefined_value(); | 10013 return Heap::undefined_value(); |
| 10010 } | 10014 } |
| 10011 | 10015 |
| 10012 // If the candidate found is compiled we are done. NOTE: when lazy | 10016 // If the candidate found is compiled we are done. NOTE: when lazy |
| 10013 // compilation of inner functions is introduced some additional checking | 10017 // compilation of inner functions is introduced some additional checking |
| 10014 // needs to be done here to compile inner functions. | 10018 // needs to be done here to compile inner functions. |
| 10015 done = target->is_compiled(); | 10019 done = target->is_compiled(); |
| 10016 if (!done) { | 10020 if (!done) { |
| 10017 // If the candidate is not compiled compile it to reveal any inner | 10021 // If the candidate is not compiled compile it to reveal any inner |
| 10018 // functions which might contain the requested source position. | 10022 // functions which might contain the requested source position. |
| 10019 CompileLazyShared(target, KEEP_EXCEPTION); | 10023 CompileLazyShared(target, KEEP_EXCEPTION); |
| 10020 } | 10024 } |
| 10021 } | 10025 } // End while loop. |
| 10022 | 10026 |
| 10023 return *target; | 10027 return *target; |
| 10024 } | 10028 } |
| 10025 | 10029 |
| 10026 | 10030 |
| 10027 // Changes the state of a break point in a script and returns source position | 10031 // Changes the state of a break point in a script and returns source position |
| 10028 // where break point was set. NOTE: Regarding performance see the NOTE for | 10032 // where break point was set. NOTE: Regarding performance see the NOTE for |
| 10029 // GetScriptFromScriptData. | 10033 // GetScriptFromScriptData. |
| 10030 // args[0]: script to set break point in | 10034 // args[0]: script to set break point in |
| 10031 // args[1]: number: break source position (within the script source) | 10035 // args[1]: number: break source position (within the script source) |
| (...skipping 409 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 10441 } | 10445 } |
| 10442 | 10446 |
| 10443 // Return result as a JS array. | 10447 // Return result as a JS array. |
| 10444 Handle<JSObject> result = Factory::NewJSObject(Top::array_function()); | 10448 Handle<JSObject> result = Factory::NewJSObject(Top::array_function()); |
| 10445 Handle<JSArray>::cast(result)->SetContent(*instances); | 10449 Handle<JSArray>::cast(result)->SetContent(*instances); |
| 10446 return *result; | 10450 return *result; |
| 10447 } | 10451 } |
| 10448 | 10452 |
| 10449 | 10453 |
| 10450 // Helper function used by Runtime_DebugReferencedBy below. | 10454 // Helper function used by Runtime_DebugReferencedBy below. |
| 10451 static int DebugReferencedBy(JSObject* target, | 10455 static int DebugReferencedBy(HeapIterator* iterator, |
| 10456 JSObject* target, |
| 10452 Object* instance_filter, int max_references, | 10457 Object* instance_filter, int max_references, |
| 10453 FixedArray* instances, int instances_size, | 10458 FixedArray* instances, int instances_size, |
| 10454 JSFunction* arguments_function) { | 10459 JSFunction* arguments_function) { |
| 10455 NoHandleAllocation ha; | 10460 NoHandleAllocation ha; |
| 10456 HeapIterator iterator; | |
| 10457 AssertNoAllocation no_alloc; | 10461 AssertNoAllocation no_alloc; |
| 10458 | 10462 |
| 10459 // Iterate the heap. | 10463 // Iterate the heap. |
| 10460 int count = 0; | 10464 int count = 0; |
| 10461 JSObject* last = NULL; | 10465 JSObject* last = NULL; |
| 10462 HeapObject* heap_obj = NULL; | 10466 HeapObject* heap_obj = NULL; |
| 10463 while (((heap_obj = iterator.Next()) != NULL) && | 10467 while (((heap_obj = iterator->Next()) != NULL) && |
| 10464 (max_references == 0 || count < max_references)) { | 10468 (max_references == 0 || count < max_references)) { |
| 10465 // Only look at all JSObjects. | 10469 // Only look at all JSObjects. |
| 10466 if (heap_obj->IsJSObject()) { | 10470 if (heap_obj->IsJSObject()) { |
| 10467 // Skip context extension objects and argument arrays as these are | 10471 // Skip context extension objects and argument arrays as these are |
| 10468 // checked in the context of functions using them. | 10472 // checked in the context of functions using them. |
| 10469 JSObject* obj = JSObject::cast(heap_obj); | 10473 JSObject* obj = JSObject::cast(heap_obj); |
| 10470 if (obj->IsJSContextExtensionObject() || | 10474 if (obj->IsJSContextExtensionObject() || |
| 10471 obj->map()->constructor() == arguments_function) { | 10475 obj->map()->constructor() == arguments_function) { |
| 10472 continue; | 10476 continue; |
| 10473 } | 10477 } |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 10519 | 10523 |
| 10520 // Scan the heap for objects with direct references to an object | 10524 // Scan the heap for objects with direct references to an object |
| 10521 // args[0]: the object to find references to | 10525 // args[0]: the object to find references to |
| 10522 // args[1]: constructor function for instances to exclude (Mirror) | 10526 // args[1]: constructor function for instances to exclude (Mirror) |
| 10523 // args[2]: the the maximum number of objects to return | 10527 // args[2]: the the maximum number of objects to return |
| 10524 static MaybeObject* Runtime_DebugReferencedBy(Arguments args) { | 10528 static MaybeObject* Runtime_DebugReferencedBy(Arguments args) { |
| 10525 ASSERT(args.length() == 3); | 10529 ASSERT(args.length() == 3); |
| 10526 | 10530 |
| 10527 // First perform a full GC in order to avoid references from dead objects. | 10531 // First perform a full GC in order to avoid references from dead objects. |
| 10528 Heap::CollectAllGarbage(Heap::kMakeHeapIterableMask); | 10532 Heap::CollectAllGarbage(Heap::kMakeHeapIterableMask); |
| 10533 // The heap iterator reserves the right to do a GC to make the heap iterable. |
| 10534 // Due to the GC above we know it won't need to do that, but it seems cleaner |
| 10535 // to get the heap iterator constructed before we start having unprotected |
| 10536 // Object* locals that are not protected by handles. |
| 10537 HeapIterator heap_iterator; |
| 10538 HeapIterator heap_iterator2; |
| 10529 | 10539 |
| 10530 // Check parameters. | 10540 // Check parameters. |
| 10531 CONVERT_CHECKED(JSObject, target, args[0]); | 10541 CONVERT_CHECKED(JSObject, target, args[0]); |
| 10532 Object* instance_filter = args[1]; | 10542 Object* instance_filter = args[1]; |
| 10533 RUNTIME_ASSERT(instance_filter->IsUndefined() || | 10543 RUNTIME_ASSERT(instance_filter->IsUndefined() || |
| 10534 instance_filter->IsJSObject()); | 10544 instance_filter->IsJSObject()); |
| 10535 CONVERT_NUMBER_CHECKED(int32_t, max_references, Int32, args[2]); | 10545 CONVERT_NUMBER_CHECKED(int32_t, max_references, Int32, args[2]); |
| 10536 RUNTIME_ASSERT(max_references >= 0); | 10546 RUNTIME_ASSERT(max_references >= 0); |
| 10537 | 10547 |
| 10548 |
| 10538 // Get the constructor function for context extension and arguments array. | 10549 // Get the constructor function for context extension and arguments array. |
| 10539 JSObject* arguments_boilerplate = | 10550 JSObject* arguments_boilerplate = |
| 10540 Top::context()->global_context()->arguments_boilerplate(); | 10551 Top::context()->global_context()->arguments_boilerplate(); |
| 10541 JSFunction* arguments_function = | 10552 JSFunction* arguments_function = |
| 10542 JSFunction::cast(arguments_boilerplate->map()->constructor()); | 10553 JSFunction::cast(arguments_boilerplate->map()->constructor()); |
| 10543 | 10554 |
| 10544 // Get the number of referencing objects. | 10555 // Get the number of referencing objects. |
| 10545 int count; | 10556 int count; |
| 10546 count = DebugReferencedBy(target, instance_filter, max_references, | 10557 count = DebugReferencedBy(&heap_iterator, |
| 10558 target, instance_filter, max_references, |
| 10547 NULL, 0, arguments_function); | 10559 NULL, 0, arguments_function); |
| 10548 | 10560 |
| 10549 // Allocate an array to hold the result. | 10561 // Allocate an array to hold the result. |
| 10550 Object* object; | 10562 Object* object; |
| 10551 { MaybeObject* maybe_object = Heap::AllocateFixedArray(count); | 10563 { MaybeObject* maybe_object = Heap::AllocateFixedArray(count); |
| 10552 if (!maybe_object->ToObject(&object)) return maybe_object; | 10564 if (!maybe_object->ToObject(&object)) return maybe_object; |
| 10553 } | 10565 } |
| 10554 FixedArray* instances = FixedArray::cast(object); | 10566 FixedArray* instances = FixedArray::cast(object); |
| 10555 | 10567 |
| 10556 // Fill the referencing objects. | 10568 // Fill the referencing objects. |
| 10557 count = DebugReferencedBy(target, instance_filter, max_references, | 10569 count = DebugReferencedBy(&heap_iterator2, |
| 10570 target, instance_filter, max_references, |
| 10558 instances, count, arguments_function); | 10571 instances, count, arguments_function); |
| 10559 | 10572 |
| 10560 // Return result as JS array. | 10573 // Return result as JS array. |
| 10561 Object* result; | 10574 Object* result; |
| 10562 { MaybeObject* maybe_result = Heap::AllocateJSObject( | 10575 { MaybeObject* maybe_result = Heap::AllocateJSObject( |
| 10563 Top::context()->global_context()->array_function()); | 10576 Top::context()->global_context()->array_function()); |
| 10564 if (!maybe_result->ToObject(&result)) return maybe_result; | 10577 if (!maybe_result->ToObject(&result)) return maybe_result; |
| 10565 } | 10578 } |
| 10566 JSArray::cast(result)->SetContent(instances); | 10579 JSArray::cast(result)->SetContent(instances); |
| 10567 return result; | 10580 return result; |
| 10568 } | 10581 } |
| 10569 | 10582 |
| 10570 | 10583 |
| 10571 // Helper function used by Runtime_DebugConstructedBy below. | 10584 // Helper function used by Runtime_DebugConstructedBy below. |
| 10572 static int DebugConstructedBy(JSFunction* constructor, int max_references, | 10585 static int DebugConstructedBy(HeapIterator* iterator, |
| 10573 FixedArray* instances, int instances_size) { | 10586 JSFunction* constructor, |
| 10574 HeapIterator iterator; | 10587 int max_references, |
| 10588 FixedArray* instances, |
| 10589 int instances_size) { |
| 10575 AssertNoAllocation no_alloc; | 10590 AssertNoAllocation no_alloc; |
| 10576 | 10591 |
| 10577 // Iterate the heap. | 10592 // Iterate the heap. |
| 10578 int count = 0; | 10593 int count = 0; |
| 10579 HeapObject* heap_obj = NULL; | 10594 HeapObject* heap_obj = NULL; |
| 10580 while (((heap_obj = iterator.Next()) != NULL) && | 10595 while (((heap_obj = iterator->Next()) != NULL) && |
| 10581 (max_references == 0 || count < max_references)) { | 10596 (max_references == 0 || count < max_references)) { |
| 10582 // Only look at all JSObjects. | 10597 // Only look at all JSObjects. |
| 10583 if (heap_obj->IsJSObject()) { | 10598 if (heap_obj->IsJSObject()) { |
| 10584 JSObject* obj = JSObject::cast(heap_obj); | 10599 JSObject* obj = JSObject::cast(heap_obj); |
| 10585 if (obj->map()->constructor() == constructor) { | 10600 if (obj->map()->constructor() == constructor) { |
| 10586 // Valid reference found add to instance array if supplied an update | 10601 // Valid reference found add to instance array if supplied an update |
| 10587 // count. | 10602 // count. |
| 10588 if (instances != NULL && count < instances_size) { | 10603 if (instances != NULL && count < instances_size) { |
| 10589 instances->set(count, obj); | 10604 instances->set(count, obj); |
| 10590 } | 10605 } |
| 10591 count++; | 10606 count++; |
| 10592 } | 10607 } |
| 10593 } | 10608 } |
| 10594 } | 10609 } |
| 10595 | 10610 |
| 10596 // Return the number of referencing objects found. | 10611 // Return the number of referencing objects found. |
| 10597 return count; | 10612 return count; |
| 10598 } | 10613 } |
| 10599 | 10614 |
| 10600 | 10615 |
| 10601 // Scan the heap for objects constructed by a specific function. | 10616 // Scan the heap for objects constructed by a specific function. |
| 10602 // args[0]: the constructor to find instances of | 10617 // args[0]: the constructor to find instances of |
| 10603 // args[1]: the the maximum number of objects to return | 10618 // args[1]: the the maximum number of objects to return |
| 10604 static MaybeObject* Runtime_DebugConstructedBy(Arguments args) { | 10619 static MaybeObject* Runtime_DebugConstructedBy(Arguments args) { |
| 10605 ASSERT(args.length() == 2); | 10620 ASSERT(args.length() == 2); |
| 10606 | 10621 |
| 10607 // First perform a full GC in order to avoid dead objects. | 10622 // First perform a full GC in order to avoid dead objects. |
| 10608 Heap::CollectAllGarbage(Heap::kMakeHeapIterableMask); | 10623 Heap::CollectAllGarbage(Heap::kMakeHeapIterableMask); |
| 10609 | 10624 |
| 10625 HeapIterator heap_iterator; |
| 10626 HeapIterator heap_iterator2; |
| 10627 |
| 10610 // Check parameters. | 10628 // Check parameters. |
| 10611 CONVERT_CHECKED(JSFunction, constructor, args[0]); | 10629 CONVERT_CHECKED(JSFunction, constructor, args[0]); |
| 10612 CONVERT_NUMBER_CHECKED(int32_t, max_references, Int32, args[1]); | 10630 CONVERT_NUMBER_CHECKED(int32_t, max_references, Int32, args[1]); |
| 10613 RUNTIME_ASSERT(max_references >= 0); | 10631 RUNTIME_ASSERT(max_references >= 0); |
| 10614 | 10632 |
| 10615 // Get the number of referencing objects. | 10633 // Get the number of referencing objects. |
| 10616 int count; | 10634 int count; |
| 10617 count = DebugConstructedBy(constructor, max_references, NULL, 0); | 10635 count = DebugConstructedBy(&heap_iterator, |
| 10636 constructor, |
| 10637 max_references, |
| 10638 NULL, |
| 10639 0); |
| 10618 | 10640 |
| 10619 // Allocate an array to hold the result. | 10641 // Allocate an array to hold the result. |
| 10620 Object* object; | 10642 Object* object; |
| 10621 { MaybeObject* maybe_object = Heap::AllocateFixedArray(count); | 10643 { MaybeObject* maybe_object = Heap::AllocateFixedArray(count); |
| 10622 if (!maybe_object->ToObject(&object)) return maybe_object; | 10644 if (!maybe_object->ToObject(&object)) return maybe_object; |
| 10623 } | 10645 } |
| 10624 FixedArray* instances = FixedArray::cast(object); | 10646 FixedArray* instances = FixedArray::cast(object); |
| 10625 | 10647 |
| 10626 // Fill the referencing objects. | 10648 // Fill the referencing objects. |
| 10627 count = DebugConstructedBy(constructor, max_references, instances, count); | 10649 count = DebugConstructedBy(&heap_iterator2, |
| 10650 constructor, |
| 10651 max_references, |
| 10652 instances, |
| 10653 count); |
| 10628 | 10654 |
| 10629 // Return result as JS array. | 10655 // Return result as JS array. |
| 10630 Object* result; | 10656 Object* result; |
| 10631 { MaybeObject* maybe_result = Heap::AllocateJSObject( | 10657 { MaybeObject* maybe_result = Heap::AllocateJSObject( |
| 10632 Top::context()->global_context()->array_function()); | 10658 Top::context()->global_context()->array_function()); |
| 10633 if (!maybe_result->ToObject(&result)) return maybe_result; | 10659 if (!maybe_result->ToObject(&result)) return maybe_result; |
| 10634 } | 10660 } |
| 10635 JSArray::cast(result)->SetContent(instances); | 10661 JSArray::cast(result)->SetContent(instances); |
| 10636 return result; | 10662 return result; |
| 10637 } | 10663 } |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 10690 | 10716 |
| 10691 static MaybeObject* Runtime_FunctionGetInferredName(Arguments args) { | 10717 static MaybeObject* Runtime_FunctionGetInferredName(Arguments args) { |
| 10692 NoHandleAllocation ha; | 10718 NoHandleAllocation ha; |
| 10693 ASSERT(args.length() == 1); | 10719 ASSERT(args.length() == 1); |
| 10694 | 10720 |
| 10695 CONVERT_CHECKED(JSFunction, f, args[0]); | 10721 CONVERT_CHECKED(JSFunction, f, args[0]); |
| 10696 return f->shared()->inferred_name(); | 10722 return f->shared()->inferred_name(); |
| 10697 } | 10723 } |
| 10698 | 10724 |
| 10699 | 10725 |
| 10700 static int FindSharedFunctionInfosForScript(Script* script, | 10726 static int FindSharedFunctionInfosForScript(HeapIterator* iterator, |
| 10727 Script* script, |
| 10701 FixedArray* buffer) { | 10728 FixedArray* buffer) { |
| 10702 HeapIterator iterator; | |
| 10703 AssertNoAllocation no_allocations; | |
| 10704 | |
| 10705 int counter = 0; | 10729 int counter = 0; |
| 10706 int buffer_size = buffer->length(); | 10730 int buffer_size = buffer->length(); |
| 10707 for (HeapObject* obj = iterator.Next(); obj != NULL; obj = iterator.Next()) { | 10731 for (HeapObject* obj = iterator->Next(); |
| 10732 obj != NULL; |
| 10733 obj = iterator->Next()) { |
| 10708 ASSERT(obj != NULL); | 10734 ASSERT(obj != NULL); |
| 10709 if (!obj->IsSharedFunctionInfo()) { | 10735 if (!obj->IsSharedFunctionInfo()) { |
| 10710 continue; | 10736 continue; |
| 10711 } | 10737 } |
| 10712 SharedFunctionInfo* shared = SharedFunctionInfo::cast(obj); | 10738 SharedFunctionInfo* shared = SharedFunctionInfo::cast(obj); |
| 10713 if (shared->script() != script) { | 10739 if (shared->script() != script) { |
| 10714 continue; | 10740 continue; |
| 10715 } | 10741 } |
| 10716 if (counter < buffer_size) { | 10742 if (counter < buffer_size) { |
| 10717 buffer->set(counter, shared); | 10743 buffer->set(counter, shared); |
| (...skipping 12 matching lines...) Expand all Loading... |
| 10730 HandleScope scope; | 10756 HandleScope scope; |
| 10731 CONVERT_CHECKED(JSValue, script_value, args[0]); | 10757 CONVERT_CHECKED(JSValue, script_value, args[0]); |
| 10732 | 10758 |
| 10733 | 10759 |
| 10734 Handle<Script> script = Handle<Script>(Script::cast(script_value->value())); | 10760 Handle<Script> script = Handle<Script>(Script::cast(script_value->value())); |
| 10735 | 10761 |
| 10736 const int kBufferSize = 32; | 10762 const int kBufferSize = 32; |
| 10737 | 10763 |
| 10738 Handle<FixedArray> array; | 10764 Handle<FixedArray> array; |
| 10739 array = Factory::NewFixedArray(kBufferSize); | 10765 array = Factory::NewFixedArray(kBufferSize); |
| 10740 int number = FindSharedFunctionInfosForScript(*script, *array); | 10766 int number; |
| 10767 { |
| 10768 HeapIterator heap_iterator; |
| 10769 AssertNoAllocation no_allocations; |
| 10770 Script* scr = *script; |
| 10771 FixedArray* arr = *array; |
| 10772 number = FindSharedFunctionInfosForScript(&heap_iterator, scr, arr); |
| 10773 } |
| 10741 if (number > kBufferSize) { | 10774 if (number > kBufferSize) { |
| 10742 array = Factory::NewFixedArray(number); | 10775 array = Factory::NewFixedArray(number); |
| 10743 FindSharedFunctionInfosForScript(*script, *array); | 10776 HeapIterator heap_iterator; |
| 10777 AssertNoAllocation no_allocations; |
| 10778 Script* scr = *script; |
| 10779 FixedArray* arr = *array; |
| 10780 FindSharedFunctionInfosForScript(&heap_iterator, scr, arr); |
| 10744 } | 10781 } |
| 10745 | 10782 |
| 10746 Handle<JSArray> result = Factory::NewJSArrayWithElements(array); | 10783 Handle<JSArray> result = Factory::NewJSArrayWithElements(array); |
| 10747 result->set_length(Smi::FromInt(number)); | 10784 result->set_length(Smi::FromInt(number)); |
| 10748 | 10785 |
| 10749 LiveEdit::WrapSharedFunctionInfos(result); | 10786 LiveEdit::WrapSharedFunctionInfos(result); |
| 10750 | 10787 |
| 10751 return *result; | 10788 return *result; |
| 10752 } | 10789 } |
| 10753 | 10790 |
| (...skipping 472 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 11226 // for the requested break point. For lazily compiled functions several heap | 11263 // for the requested break point. For lazily compiled functions several heap |
| 11227 // traversals might be required rendering this operation as a rather slow | 11264 // traversals might be required rendering this operation as a rather slow |
| 11228 // operation. However for setting break points which is normally done through | 11265 // operation. However for setting break points which is normally done through |
| 11229 // some kind of user interaction the performance is not crucial. | 11266 // some kind of user interaction the performance is not crucial. |
| 11230 static Handle<Object> Runtime_GetScriptFromScriptName( | 11267 static Handle<Object> Runtime_GetScriptFromScriptName( |
| 11231 Handle<String> script_name) { | 11268 Handle<String> script_name) { |
| 11232 // Scan the heap for Script objects to find the script with the requested | 11269 // Scan the heap for Script objects to find the script with the requested |
| 11233 // script data. | 11270 // script data. |
| 11234 Handle<Script> script; | 11271 Handle<Script> script; |
| 11235 HeapIterator iterator; | 11272 HeapIterator iterator; |
| 11273 AssertNoAllocation no_allocation_during_heap_iteration; |
| 11236 HeapObject* obj = NULL; | 11274 HeapObject* obj = NULL; |
| 11237 while (script.is_null() && ((obj = iterator.Next()) != NULL)) { | 11275 while (script.is_null() && ((obj = iterator.Next()) != NULL)) { |
| 11238 // If a script is found check if it has the script data requested. | 11276 // If a script is found check if it has the script data requested. |
| 11239 if (obj->IsScript()) { | 11277 if (obj->IsScript()) { |
| 11240 if (Script::cast(obj)->name()->IsString()) { | 11278 if (Script::cast(obj)->name()->IsString()) { |
| 11241 if (String::cast(Script::cast(obj)->name())->Equals(*script_name)) { | 11279 if (String::cast(Script::cast(obj)->name())->Equals(*script_name)) { |
| 11242 script = Handle<Script>(Script::cast(obj)); | 11280 script = Handle<Script>(Script::cast(obj)); |
| 11243 } | 11281 } |
| 11244 } | 11282 } |
| 11245 } | 11283 } |
| (...skipping 394 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 11640 } else { | 11678 } else { |
| 11641 // Handle last resort GC and make sure to allow future allocations | 11679 // Handle last resort GC and make sure to allow future allocations |
| 11642 // to grow the heap without causing GCs (if possible). | 11680 // to grow the heap without causing GCs (if possible). |
| 11643 Counters::gc_last_resort_from_js.Increment(); | 11681 Counters::gc_last_resort_from_js.Increment(); |
| 11644 Heap::CollectAllGarbage(Heap::kNoGCFlags); | 11682 Heap::CollectAllGarbage(Heap::kNoGCFlags); |
| 11645 } | 11683 } |
| 11646 } | 11684 } |
| 11647 | 11685 |
| 11648 | 11686 |
| 11649 } } // namespace v8::internal | 11687 } } // namespace v8::internal |
| OLD | NEW |