OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "src/v8.h" | 5 #include "src/v8.h" |
6 | 6 |
7 #include "src/api.h" | 7 #include "src/api.h" |
8 #include "src/arguments.h" | 8 #include "src/arguments.h" |
9 #include "src/bootstrapper.h" | 9 #include "src/bootstrapper.h" |
10 #include "src/code-stubs.h" | 10 #include "src/code-stubs.h" |
(...skipping 2043 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2054 if (!script->shared_function_infos()->IsWeakFixedArray()) break; | 2054 if (!script->shared_function_infos()->IsWeakFixedArray()) break; |
2055 WeakFixedArray* array = | 2055 WeakFixedArray* array = |
2056 WeakFixedArray::cast(script->shared_function_infos()); | 2056 WeakFixedArray::cast(script->shared_function_infos()); |
2057 | 2057 |
2058 SharedFunctionInfo* shared; | 2058 SharedFunctionInfo* shared; |
2059 { | 2059 { |
2060 SharedFunctionInfoFinder finder(position); | 2060 SharedFunctionInfoFinder finder(position); |
2061 for (int i = 0; i < array->Length(); i++) { | 2061 for (int i = 0; i < array->Length(); i++) { |
2062 Object* item = array->Get(i); | 2062 Object* item = array->Get(i); |
2063 if (!item->IsSharedFunctionInfo()) continue; | 2063 if (!item->IsSharedFunctionInfo()) continue; |
2064 SharedFunctionInfo* shared = SharedFunctionInfo::cast(item); | 2064 finder.NewCandidate(SharedFunctionInfo::cast(item)); |
2065 finder.NewCandidate(shared); | |
2066 } | 2065 } |
2067 shared = finder.Result(); | 2066 shared = finder.Result(); |
2068 if (shared == NULL) break; | 2067 if (shared == NULL) break; |
2069 // We found it if it's already compiled. | 2068 // We found it if it's already compiled. |
2070 if (shared->is_compiled()) return handle(shared); | 2069 if (shared->is_compiled()) return handle(shared); |
2071 } | 2070 } |
2072 // If not, compile to reveal inner functions, if possible. | 2071 // If not, compile to reveal inner functions, if possible. |
2073 if (shared->allows_lazy_compilation_without_context()) { | 2072 if (shared->allows_lazy_compilation_without_context()) { |
2074 if (!CompileToRevealInnerFunctions(shared)) break; | 2073 if (!CompileToRevealInnerFunctions(shared)) break; |
2075 continue; | 2074 continue; |
2076 } | 2075 } |
2077 | 2076 |
2078 // If not possible, comb the heap for the best suitable compile target. | 2077 // If not possible, comb the heap for the best suitable compile target. |
2079 JSFunction* closure; | 2078 JSFunction* closure; |
2080 { | 2079 { |
2081 HeapIterator it(isolate_->heap(), HeapIterator::kNoFiltering); | 2080 HeapIterator it(isolate_->heap(), HeapIterator::kNoFiltering); |
2082 SharedFunctionInfoFinder finder(position); | 2081 SharedFunctionInfoFinder finder(position); |
2083 while (HeapObject* object = it.next()) { | 2082 while (HeapObject* object = it.next()) { |
2084 JSFunction* closure = NULL; | 2083 JSFunction* candidate_closure = NULL; |
2085 SharedFunctionInfo* shared = NULL; | 2084 SharedFunctionInfo* candidate = NULL; |
2086 if (object->IsJSFunction()) { | 2085 if (object->IsJSFunction()) { |
2087 closure = JSFunction::cast(object); | 2086 candidate_closure = JSFunction::cast(object); |
2088 shared = closure->shared(); | 2087 candidate = candidate_closure->shared(); |
2089 } else if (object->IsSharedFunctionInfo()) { | 2088 } else if (object->IsSharedFunctionInfo()) { |
2090 shared = SharedFunctionInfo::cast(object); | 2089 candidate = SharedFunctionInfo::cast(object); |
2091 if (!shared->allows_lazy_compilation_without_context()) continue; | 2090 if (!candidate->allows_lazy_compilation_without_context()) continue; |
2092 } else { | 2091 } else { |
2093 continue; | 2092 continue; |
2094 } | 2093 } |
2095 if (shared->script() == *script) finder.NewCandidate(shared, closure); | 2094 if (candidate->script() == *script) { |
| 2095 finder.NewCandidate(candidate, candidate_closure); |
| 2096 } |
2096 } | 2097 } |
2097 closure = finder.ResultClosure(); | 2098 closure = finder.ResultClosure(); |
2098 shared = finder.Result(); | 2099 shared = finder.Result(); |
2099 } | 2100 } |
2100 if (closure == NULL ? !CompileToRevealInnerFunctions(shared) | 2101 if (closure == NULL ? !CompileToRevealInnerFunctions(shared) |
2101 : !CompileToRevealInnerFunctions(closure)) { | 2102 : !CompileToRevealInnerFunctions(closure)) { |
2102 break; | 2103 break; |
2103 } | 2104 } |
2104 } | 2105 } |
2105 return isolate_->factory()->undefined_value(); | 2106 return isolate_->factory()->undefined_value(); |
(...skipping 1280 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3386 } | 3387 } |
3387 | 3388 |
3388 | 3389 |
3389 void LockingCommandMessageQueue::Clear() { | 3390 void LockingCommandMessageQueue::Clear() { |
3390 base::LockGuard<base::Mutex> lock_guard(&mutex_); | 3391 base::LockGuard<base::Mutex> lock_guard(&mutex_); |
3391 queue_.Clear(); | 3392 queue_.Clear(); |
3392 } | 3393 } |
3393 | 3394 |
3394 } // namespace internal | 3395 } // namespace internal |
3395 } // namespace v8 | 3396 } // namespace v8 |
OLD | NEW |