| OLD | NEW |
| 1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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 3271 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3282 | 3282 |
| 3283 int length() { | 3283 int length() { |
| 3284 return length_; | 3284 return length_; |
| 3285 } | 3285 } |
| 3286 | 3286 |
| 3287 int capacity() { | 3287 int capacity() { |
| 3288 return array_->length(); | 3288 return array_->length(); |
| 3289 } | 3289 } |
| 3290 | 3290 |
| 3291 Handle<JSArray> ToJSArray(Handle<JSArray> target_array) { | 3291 Handle<JSArray> ToJSArray(Handle<JSArray> target_array) { |
| 3292 Factory* factory = target_array->GetIsolate()->factory(); | 3292 JSArray::SetContent(target_array, array_); |
| 3293 factory->SetContent(target_array, array_); | |
| 3294 target_array->set_length(Smi::FromInt(length_)); | 3293 target_array->set_length(Smi::FromInt(length_)); |
| 3295 return target_array; | 3294 return target_array; |
| 3296 } | 3295 } |
| 3297 | 3296 |
| 3298 | 3297 |
| 3299 private: | 3298 private: |
| 3300 Handle<FixedArray> array_; | 3299 Handle<FixedArray> array_; |
| 3301 int length_; | 3300 int length_; |
| 3302 bool has_non_smi_elements_; | 3301 bool has_non_smi_elements_; |
| 3303 }; | 3302 }; |
| (...skipping 1255 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4559 if (subject_length > kMinLengthToCache) { | 4558 if (subject_length > kMinLengthToCache) { |
| 4560 Handle<Object> cached_answer(RegExpResultsCache::Lookup( | 4559 Handle<Object> cached_answer(RegExpResultsCache::Lookup( |
| 4561 isolate->heap(), | 4560 isolate->heap(), |
| 4562 *subject, | 4561 *subject, |
| 4563 regexp->data(), | 4562 regexp->data(), |
| 4564 RegExpResultsCache::REGEXP_MULTIPLE_INDICES), isolate); | 4563 RegExpResultsCache::REGEXP_MULTIPLE_INDICES), isolate); |
| 4565 if (*cached_answer != Smi::FromInt(0)) { | 4564 if (*cached_answer != Smi::FromInt(0)) { |
| 4566 Handle<FixedArray> cached_fixed_array = | 4565 Handle<FixedArray> cached_fixed_array = |
| 4567 Handle<FixedArray>(FixedArray::cast(*cached_answer)); | 4566 Handle<FixedArray>(FixedArray::cast(*cached_answer)); |
| 4568 // The cache FixedArray is a COW-array and can therefore be reused. | 4567 // The cache FixedArray is a COW-array and can therefore be reused. |
| 4569 isolate->factory()->SetContent(result_array, cached_fixed_array); | 4568 JSArray::SetContent(result_array, cached_fixed_array); |
| 4570 // The actual length of the result array is stored in the last element of | 4569 // The actual length of the result array is stored in the last element of |
| 4571 // the backing store (the backing FixedArray may have a larger capacity). | 4570 // the backing store (the backing FixedArray may have a larger capacity). |
| 4572 Object* cached_fixed_array_last_element = | 4571 Object* cached_fixed_array_last_element = |
| 4573 cached_fixed_array->get(cached_fixed_array->length() - 1); | 4572 cached_fixed_array->get(cached_fixed_array->length() - 1); |
| 4574 Smi* js_array_length = Smi::cast(cached_fixed_array_last_element); | 4573 Smi* js_array_length = Smi::cast(cached_fixed_array_last_element); |
| 4575 result_array->set_length(js_array_length); | 4574 result_array->set_length(js_array_length); |
| 4576 RegExpImpl::SetLastMatchInfo( | 4575 RegExpImpl::SetLastMatchInfo( |
| 4577 last_match_array, subject, capture_count, NULL); | 4576 last_match_array, subject, capture_count, NULL); |
| 4578 return *result_array; | 4577 return *result_array; |
| 4579 } | 4578 } |
| (...skipping 5097 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 9677 date_cache_version->set(0, Smi::FromInt(0)); | 9676 date_cache_version->set(0, Smi::FromInt(0)); |
| 9678 isolate->eternal_handles()->CreateSingleton( | 9677 isolate->eternal_handles()->CreateSingleton( |
| 9679 isolate, *date_cache_version, EternalHandles::DATE_CACHE_VERSION); | 9678 isolate, *date_cache_version, EternalHandles::DATE_CACHE_VERSION); |
| 9680 } | 9679 } |
| 9681 Handle<FixedArray> date_cache_version = | 9680 Handle<FixedArray> date_cache_version = |
| 9682 Handle<FixedArray>::cast(isolate->eternal_handles()->GetSingleton( | 9681 Handle<FixedArray>::cast(isolate->eternal_handles()->GetSingleton( |
| 9683 EternalHandles::DATE_CACHE_VERSION)); | 9682 EternalHandles::DATE_CACHE_VERSION)); |
| 9684 // Return result as a JS array. | 9683 // Return result as a JS array. |
| 9685 Handle<JSObject> result = | 9684 Handle<JSObject> result = |
| 9686 isolate->factory()->NewJSObject(isolate->array_function()); | 9685 isolate->factory()->NewJSObject(isolate->array_function()); |
| 9687 isolate->factory()->SetContent(Handle<JSArray>::cast(result), | 9686 JSArray::SetContent(Handle<JSArray>::cast(result), date_cache_version); |
| 9688 date_cache_version); | |
| 9689 return *result; | 9687 return *result; |
| 9690 } | 9688 } |
| 9691 | 9689 |
| 9692 | 9690 |
| 9693 RUNTIME_FUNCTION(MaybeObject*, Runtime_GlobalReceiver) { | 9691 RUNTIME_FUNCTION(MaybeObject*, Runtime_GlobalReceiver) { |
| 9694 SealHandleScope shs(isolate); | 9692 SealHandleScope shs(isolate); |
| 9695 ASSERT(args.length() == 1); | 9693 ASSERT(args.length() == 1); |
| 9696 Object* global = args[0]; | 9694 Object* global = args[0]; |
| 9697 if (!global->IsJSGlobalObject()) return isolate->heap()->null_value(); | 9695 if (!global->IsJSGlobalObject()) return isolate->heap()->null_value(); |
| 9698 return JSGlobalObject::cast(global)->global_receiver(); | 9696 return JSGlobalObject::cast(global)->global_receiver(); |
| (...skipping 3255 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 12954 // instances->set(i, *GetScriptWrapper(script)) | 12952 // instances->set(i, *GetScriptWrapper(script)) |
| 12955 // is unsafe as GetScriptWrapper might call GC and the C++ compiler might | 12953 // is unsafe as GetScriptWrapper might call GC and the C++ compiler might |
| 12956 // already have dereferenced the instances handle. | 12954 // already have dereferenced the instances handle. |
| 12957 Handle<JSValue> wrapper = GetScriptWrapper(script); | 12955 Handle<JSValue> wrapper = GetScriptWrapper(script); |
| 12958 instances->set(i, *wrapper); | 12956 instances->set(i, *wrapper); |
| 12959 } | 12957 } |
| 12960 | 12958 |
| 12961 // Return result as a JS array. | 12959 // Return result as a JS array. |
| 12962 Handle<JSObject> result = | 12960 Handle<JSObject> result = |
| 12963 isolate->factory()->NewJSObject(isolate->array_function()); | 12961 isolate->factory()->NewJSObject(isolate->array_function()); |
| 12964 isolate->factory()->SetContent(Handle<JSArray>::cast(result), instances); | 12962 JSArray::SetContent(Handle<JSArray>::cast(result), instances); |
| 12965 return *result; | 12963 return *result; |
| 12966 } | 12964 } |
| 12967 | 12965 |
| 12968 | 12966 |
| 12969 // Helper function used by Runtime_DebugReferencedBy below. | 12967 // Helper function used by Runtime_DebugReferencedBy below. |
| 12970 static int DebugReferencedBy(HeapIterator* iterator, | 12968 static int DebugReferencedBy(HeapIterator* iterator, |
| 12971 JSObject* target, | 12969 JSObject* target, |
| 12972 Object* instance_filter, int max_references, | 12970 Object* instance_filter, int max_references, |
| 12973 FixedArray* instances, int instances_size, | 12971 FixedArray* instances, int instances_size, |
| 12974 JSFunction* arguments_function) { | 12972 JSFunction* arguments_function) { |
| (...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 13084 HeapIterator heap_iterator2(heap); | 13082 HeapIterator heap_iterator2(heap); |
| 13085 count = DebugReferencedBy(&heap_iterator2, | 13083 count = DebugReferencedBy(&heap_iterator2, |
| 13086 *target, *instance_filter, max_references, | 13084 *target, *instance_filter, max_references, |
| 13087 *instances, count, *arguments_function); | 13085 *instances, count, *arguments_function); |
| 13088 | 13086 |
| 13089 // Return result as JS array. | 13087 // Return result as JS array. |
| 13090 Handle<JSFunction> constructor( | 13088 Handle<JSFunction> constructor( |
| 13091 isolate->context()->native_context()->array_function()); | 13089 isolate->context()->native_context()->array_function()); |
| 13092 | 13090 |
| 13093 Handle<JSObject> result = isolate->factory()->NewJSObject(constructor); | 13091 Handle<JSObject> result = isolate->factory()->NewJSObject(constructor); |
| 13094 isolate->factory()->SetContent(Handle<JSArray>::cast(result), instances); | 13092 JSArray::SetContent(Handle<JSArray>::cast(result), instances); |
| 13095 return *result; | 13093 return *result; |
| 13096 } | 13094 } |
| 13097 | 13095 |
| 13098 | 13096 |
| 13099 // Helper function used by Runtime_DebugConstructedBy below. | 13097 // Helper function used by Runtime_DebugConstructedBy below. |
| 13100 static int DebugConstructedBy(HeapIterator* iterator, | 13098 static int DebugConstructedBy(HeapIterator* iterator, |
| 13101 JSFunction* constructor, | 13099 JSFunction* constructor, |
| 13102 int max_references, | 13100 int max_references, |
| 13103 FixedArray* instances, | 13101 FixedArray* instances, |
| 13104 int instances_size) { | 13102 int instances_size) { |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 13162 count = DebugConstructedBy(&heap_iterator2, | 13160 count = DebugConstructedBy(&heap_iterator2, |
| 13163 *constructor, | 13161 *constructor, |
| 13164 max_references, | 13162 max_references, |
| 13165 *instances, | 13163 *instances, |
| 13166 count); | 13164 count); |
| 13167 | 13165 |
| 13168 // Return result as JS array. | 13166 // Return result as JS array. |
| 13169 Handle<JSFunction> array_function( | 13167 Handle<JSFunction> array_function( |
| 13170 isolate->context()->native_context()->array_function()); | 13168 isolate->context()->native_context()->array_function()); |
| 13171 Handle<JSObject> result = isolate->factory()->NewJSObject(array_function); | 13169 Handle<JSObject> result = isolate->factory()->NewJSObject(array_function); |
| 13172 isolate->factory()->SetContent(Handle<JSArray>::cast(result), instances); | 13170 JSArray::SetContent(Handle<JSArray>::cast(result), instances); |
| 13173 return *result; | 13171 return *result; |
| 13174 } | 13172 } |
| 13175 | 13173 |
| 13176 | 13174 |
| 13177 // Find the effective prototype object as returned by __proto__. | 13175 // Find the effective prototype object as returned by __proto__. |
| 13178 // args[0]: the object to find the prototype for. | 13176 // args[0]: the object to find the prototype for. |
| 13179 RUNTIME_FUNCTION(MaybeObject*, Runtime_DebugGetPrototype) { | 13177 RUNTIME_FUNCTION(MaybeObject*, Runtime_DebugGetPrototype) { |
| 13180 SealHandleScope shs(isolate); | 13178 SealHandleScope shs(isolate); |
| 13181 ASSERT(args.length() == 1); | 13179 ASSERT(args.length() == 1); |
| 13182 CONVERT_ARG_CHECKED(JSObject, obj, 0); | 13180 CONVERT_ARG_CHECKED(JSObject, obj, 0); |
| (...skipping 1844 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 15027 // Handle last resort GC and make sure to allow future allocations | 15025 // Handle last resort GC and make sure to allow future allocations |
| 15028 // to grow the heap without causing GCs (if possible). | 15026 // to grow the heap without causing GCs (if possible). |
| 15029 isolate->counters()->gc_last_resort_from_js()->Increment(); | 15027 isolate->counters()->gc_last_resort_from_js()->Increment(); |
| 15030 isolate->heap()->CollectAllGarbage(Heap::kNoGCFlags, | 15028 isolate->heap()->CollectAllGarbage(Heap::kNoGCFlags, |
| 15031 "Runtime::PerformGC"); | 15029 "Runtime::PerformGC"); |
| 15032 } | 15030 } |
| 15033 } | 15031 } |
| 15034 | 15032 |
| 15035 | 15033 |
| 15036 } } // namespace v8::internal | 15034 } } // namespace v8::internal |
| OLD | NEW |