| OLD | NEW |
| 1 // Copyright 2013 the V8 project authors. All rights reserved. | 1 // Copyright 2013 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 <sstream> | 5 #include <sstream> |
| 6 | 6 |
| 7 #include "src/v8.h" | 7 #include "src/v8.h" |
| 8 | 8 |
| 9 #include "src/accessors.h" | 9 #include "src/accessors.h" |
| 10 #include "src/allocation-site-scopes.h" | 10 #include "src/allocation-site-scopes.h" |
| (...skipping 9391 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 9402 void JSFunction::JSFunctionIterateBody(int object_size, ObjectVisitor* v) { | 9402 void JSFunction::JSFunctionIterateBody(int object_size, ObjectVisitor* v) { |
| 9403 // Iterate over all fields in the body but take care in dealing with | 9403 // Iterate over all fields in the body but take care in dealing with |
| 9404 // the code entry. | 9404 // the code entry. |
| 9405 IteratePointers(v, kPropertiesOffset, kCodeEntryOffset); | 9405 IteratePointers(v, kPropertiesOffset, kCodeEntryOffset); |
| 9406 v->VisitCodeEntry(this->address() + kCodeEntryOffset); | 9406 v->VisitCodeEntry(this->address() + kCodeEntryOffset); |
| 9407 IteratePointers(v, kCodeEntryOffset + kPointerSize, object_size); | 9407 IteratePointers(v, kCodeEntryOffset + kPointerSize, object_size); |
| 9408 } | 9408 } |
| 9409 | 9409 |
| 9410 | 9410 |
| 9411 void JSFunction::MarkForOptimization() { | 9411 void JSFunction::MarkForOptimization() { |
| 9412 Isolate* isolate = GetIsolate(); |
| 9413 DCHECK(isolate->use_crankshaft()); |
| 9412 DCHECK(!IsOptimized()); | 9414 DCHECK(!IsOptimized()); |
| 9413 DCHECK(shared()->allows_lazy_compilation() || | 9415 DCHECK(shared()->allows_lazy_compilation() || |
| 9414 code()->optimizable()); | 9416 code()->optimizable()); |
| 9415 DCHECK(!shared()->is_generator()); | 9417 DCHECK(!shared()->is_generator()); |
| 9416 set_code_no_write_barrier( | 9418 set_code_no_write_barrier( |
| 9417 GetIsolate()->builtins()->builtin(Builtins::kCompileOptimized)); | 9419 isolate->builtins()->builtin(Builtins::kCompileOptimized)); |
| 9418 // No write barrier required, since the builtin is part of the root set. | 9420 // No write barrier required, since the builtin is part of the root set. |
| 9419 } | 9421 } |
| 9420 | 9422 |
| 9421 | 9423 |
| 9422 void JSFunction::AttemptConcurrentOptimization() { | 9424 void JSFunction::AttemptConcurrentOptimization() { |
| 9423 Isolate* isolate = GetIsolate(); | 9425 Isolate* isolate = GetIsolate(); |
| 9424 if (!isolate->concurrent_recompilation_enabled() || | 9426 if (!isolate->concurrent_recompilation_enabled() || |
| 9425 isolate->bootstrapper()->IsActive()) { | 9427 isolate->bootstrapper()->IsActive()) { |
| 9426 MarkForOptimization(); | 9428 MarkForOptimization(); |
| 9427 return; | 9429 return; |
| 9428 } | 9430 } |
| 9429 if (isolate->concurrent_osr_enabled() && | 9431 if (isolate->concurrent_osr_enabled() && |
| 9430 isolate->optimizing_compiler_thread()->IsQueuedForOSR(this)) { | 9432 isolate->optimizing_compiler_thread()->IsQueuedForOSR(this)) { |
| 9431 // Do not attempt regular recompilation if we already queued this for OSR. | 9433 // Do not attempt regular recompilation if we already queued this for OSR. |
| 9432 // TODO(yangguo): This is necessary so that we don't install optimized | 9434 // TODO(yangguo): This is necessary so that we don't install optimized |
| 9433 // code on a function that is already optimized, since OSR and regular | 9435 // code on a function that is already optimized, since OSR and regular |
| 9434 // recompilation race. This goes away as soon as OSR becomes one-shot. | 9436 // recompilation race. This goes away as soon as OSR becomes one-shot. |
| 9435 return; | 9437 return; |
| 9436 } | 9438 } |
| 9439 DCHECK(isolate->use_crankshaft()); |
| 9437 DCHECK(!IsInOptimizationQueue()); | 9440 DCHECK(!IsInOptimizationQueue()); |
| 9438 DCHECK(is_compiled() || isolate->DebuggerHasBreakPoints()); | 9441 DCHECK(is_compiled() || isolate->DebuggerHasBreakPoints()); |
| 9439 DCHECK(!IsOptimized()); | 9442 DCHECK(!IsOptimized()); |
| 9440 DCHECK(shared()->allows_lazy_compilation() || code()->optimizable()); | 9443 DCHECK(shared()->allows_lazy_compilation() || code()->optimizable()); |
| 9441 DCHECK(!shared()->is_generator()); | 9444 DCHECK(!shared()->is_generator()); |
| 9442 DCHECK(isolate->concurrent_recompilation_enabled()); | 9445 DCHECK(isolate->concurrent_recompilation_enabled()); |
| 9443 if (FLAG_trace_concurrent_recompilation) { | 9446 if (FLAG_trace_concurrent_recompilation) { |
| 9444 PrintF(" ** Marking "); | 9447 PrintF(" ** Marking "); |
| 9445 ShortPrint(); | 9448 ShortPrint(); |
| 9446 PrintF(" for concurrent recompilation.\n"); | 9449 PrintF(" for concurrent recompilation.\n"); |
| 9447 } | 9450 } |
| 9448 set_code_no_write_barrier( | 9451 set_code_no_write_barrier( |
| 9449 GetIsolate()->builtins()->builtin(Builtins::kCompileOptimizedConcurrent)); | 9452 GetIsolate()->builtins()->builtin(Builtins::kCompileOptimizedConcurrent)); |
| 9450 // No write barrier required, since the builtin is part of the root set. | 9453 // No write barrier required, since the builtin is part of the root set. |
| 9451 } | 9454 } |
| 9452 | 9455 |
| 9453 | 9456 |
| 9454 void JSFunction::MarkInOptimizationQueue() { | |
| 9455 // We can only arrive here via the concurrent-recompilation builtin. If | |
| 9456 // break points were set, the code would point to the lazy-compile builtin. | |
| 9457 DCHECK(!GetIsolate()->DebuggerHasBreakPoints()); | |
| 9458 DCHECK(IsMarkedForConcurrentOptimization() && !IsOptimized()); | |
| 9459 DCHECK(shared()->allows_lazy_compilation() || code()->optimizable()); | |
| 9460 DCHECK(GetIsolate()->concurrent_recompilation_enabled()); | |
| 9461 if (FLAG_trace_concurrent_recompilation) { | |
| 9462 PrintF(" ** Queueing "); | |
| 9463 ShortPrint(); | |
| 9464 PrintF(" for concurrent recompilation.\n"); | |
| 9465 } | |
| 9466 set_code_no_write_barrier( | |
| 9467 GetIsolate()->builtins()->builtin(Builtins::kInOptimizationQueue)); | |
| 9468 // No write barrier required, since the builtin is part of the root set. | |
| 9469 } | |
| 9470 | |
| 9471 | |
| 9472 Handle<JSFunction> JSFunction::CloneClosure(Handle<JSFunction> function) { | 9457 Handle<JSFunction> JSFunction::CloneClosure(Handle<JSFunction> function) { |
| 9473 Isolate* isolate = function->GetIsolate(); | 9458 Isolate* isolate = function->GetIsolate(); |
| 9474 Handle<Map> map(function->map()); | 9459 Handle<Map> map(function->map()); |
| 9475 Handle<SharedFunctionInfo> shared(function->shared()); | 9460 Handle<SharedFunctionInfo> shared(function->shared()); |
| 9476 Handle<Context> context(function->context()); | 9461 Handle<Context> context(function->context()); |
| 9477 Handle<JSFunction> clone = | 9462 Handle<JSFunction> clone = |
| 9478 isolate->factory()->NewFunctionFromSharedFunctionInfo(shared, context); | 9463 isolate->factory()->NewFunctionFromSharedFunctionInfo(shared, context); |
| 9479 | 9464 |
| 9480 if (shared->bound()) { | 9465 if (shared->bound()) { |
| 9481 clone->set_function_bindings(function->function_bindings()); | 9466 clone->set_function_bindings(function->function_bindings()); |
| (...skipping 7357 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 16839 Handle<DependentCode> codes = | 16824 Handle<DependentCode> codes = |
| 16840 DependentCode::Insert(handle(cell->dependent_code(), info->isolate()), | 16825 DependentCode::Insert(handle(cell->dependent_code(), info->isolate()), |
| 16841 DependentCode::kPropertyCellChangedGroup, | 16826 DependentCode::kPropertyCellChangedGroup, |
| 16842 info->object_wrapper()); | 16827 info->object_wrapper()); |
| 16843 if (*codes != cell->dependent_code()) cell->set_dependent_code(*codes); | 16828 if (*codes != cell->dependent_code()) cell->set_dependent_code(*codes); |
| 16844 info->dependencies(DependentCode::kPropertyCellChangedGroup)->Add( | 16829 info->dependencies(DependentCode::kPropertyCellChangedGroup)->Add( |
| 16845 cell, info->zone()); | 16830 cell, info->zone()); |
| 16846 } | 16831 } |
| 16847 | 16832 |
| 16848 } } // namespace v8::internal | 16833 } } // namespace v8::internal |
| OLD | NEW |