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 6491 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6502 bool has_pending_exception; | 6502 bool has_pending_exception; |
6503 Handle<Object> receiver = Top::global(); | 6503 Handle<Object> receiver = Top::global(); |
6504 Handle<Object> result = | 6504 Handle<Object> result = |
6505 Execution::Call(compiled_function, receiver, 0, NULL, | 6505 Execution::Call(compiled_function, receiver, 0, NULL, |
6506 &has_pending_exception); | 6506 &has_pending_exception); |
6507 if (has_pending_exception) return Failure::Exception(); | 6507 if (has_pending_exception) return Failure::Exception(); |
6508 return *result; | 6508 return *result; |
6509 } | 6509 } |
6510 | 6510 |
6511 | 6511 |
| 6512 // If an object given is an external string, check that the underlying |
| 6513 // resource is accessible. For other kinds of objects, always return true. |
| 6514 static bool IsExternalStringValid(Object* str) { |
| 6515 if (!str->IsString() || !StringShape(String::cast(str)).IsExternal()) { |
| 6516 return true; |
| 6517 } |
| 6518 if (StringShape(String::cast(str)).IsAsciiRepresentation()) { |
| 6519 return ExternalAsciiString::cast(str)->resource() != 0; |
| 6520 } else if (StringShape(String::cast(str)).IsTwoByteRepresentation()) { |
| 6521 return ExternalTwoByteString::cast(str)->resource() != 0; |
| 6522 } else { |
| 6523 return true; |
| 6524 } |
| 6525 } |
| 6526 |
| 6527 |
6512 // Helper function used by Runtime_DebugGetLoadedScripts below. | 6528 // Helper function used by Runtime_DebugGetLoadedScripts below. |
6513 static int DebugGetLoadedScripts(FixedArray* instances, int instances_size) { | 6529 static int DebugGetLoadedScripts(FixedArray* instances, int instances_size) { |
6514 NoHandleAllocation ha; | 6530 NoHandleAllocation ha; |
6515 AssertNoAllocation no_alloc; | 6531 AssertNoAllocation no_alloc; |
6516 | 6532 |
6517 // Scan heap for Script objects. | 6533 // Scan heap for Script objects. |
6518 int count = 0; | 6534 int count = 0; |
6519 HeapIterator iterator; | 6535 HeapIterator iterator; |
6520 while (iterator.has_next()) { | 6536 while (iterator.has_next()) { |
6521 HeapObject* obj = iterator.next(); | 6537 HeapObject* obj = iterator.next(); |
6522 ASSERT(obj != NULL); | 6538 ASSERT(obj != NULL); |
6523 if (obj->IsScript()) { | 6539 if (obj->IsScript() && IsExternalStringValid(Script::cast(obj)->source())) { |
6524 if (instances != NULL && count < instances_size) { | 6540 if (instances != NULL && count < instances_size) { |
6525 instances->set(count, obj); | 6541 instances->set(count, obj); |
6526 } | 6542 } |
6527 count++; | 6543 count++; |
6528 } | 6544 } |
6529 } | 6545 } |
6530 | 6546 |
6531 return count; | 6547 return count; |
6532 } | 6548 } |
6533 | 6549 |
(...skipping 394 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6928 } else { | 6944 } else { |
6929 // Handle last resort GC and make sure to allow future allocations | 6945 // Handle last resort GC and make sure to allow future allocations |
6930 // to grow the heap without causing GCs (if possible). | 6946 // to grow the heap without causing GCs (if possible). |
6931 Counters::gc_last_resort_from_js.Increment(); | 6947 Counters::gc_last_resort_from_js.Increment(); |
6932 Heap::CollectAllGarbage(); | 6948 Heap::CollectAllGarbage(); |
6933 } | 6949 } |
6934 } | 6950 } |
6935 | 6951 |
6936 | 6952 |
6937 } } // namespace v8::internal | 6953 } } // namespace v8::internal |
OLD | NEW |