Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2014 the V8 project authors. All rights reserved. | 1 // Copyright 2014 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/arguments.h" | 7 #include "src/arguments.h" |
| 8 #include "src/deoptimizer.h" | 8 #include "src/deoptimizer.h" |
| 9 #include "src/full-codegen.h" | 9 #include "src/full-codegen.h" |
| 10 #include "src/natives.h" | 10 #include "src/natives.h" |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 62 if (!isolate->use_crankshaft()) return isolate->heap()->undefined_value(); | 62 if (!isolate->use_crankshaft()) return isolate->heap()->undefined_value(); |
| 63 | 63 |
| 64 // If the function is already optimized, just return. | 64 // If the function is already optimized, just return. |
| 65 if (function->IsOptimized()) return isolate->heap()->undefined_value(); | 65 if (function->IsOptimized()) return isolate->heap()->undefined_value(); |
| 66 | 66 |
| 67 function->MarkForOptimization(); | 67 function->MarkForOptimization(); |
| 68 | 68 |
| 69 Code* unoptimized = function->shared()->code(); | 69 Code* unoptimized = function->shared()->code(); |
| 70 if (args.length() == 2 && unoptimized->kind() == Code::FUNCTION) { | 70 if (args.length() == 2 && unoptimized->kind() == Code::FUNCTION) { |
| 71 CONVERT_ARG_HANDLE_CHECKED(String, type, 1); | 71 CONVERT_ARG_HANDLE_CHECKED(String, type, 1); |
| 72 if (type->IsOneByteEqualTo(STATIC_CHAR_VECTOR("osr")) && FLAG_use_osr) { | 72 if (type->IsOneByteEqualTo(STATIC_CHAR_VECTOR("concurrent")) && |
| 73 // Start patching from the currently patched loop nesting level. | 73 isolate->concurrent_recompilation_enabled()) { |
| 74 DCHECK(BackEdgeTable::Verify(isolate, unoptimized)); | |
| 75 isolate->runtime_profiler()->AttemptOnStackReplacement( | |
| 76 *function, Code::kMaxLoopNestingMarker); | |
| 77 } else if (type->IsOneByteEqualTo(STATIC_CHAR_VECTOR("concurrent")) && | |
| 78 isolate->concurrent_recompilation_enabled()) { | |
| 79 function->AttemptConcurrentOptimization(); | 74 function->AttemptConcurrentOptimization(); |
| 80 } | 75 } |
| 81 } | 76 } |
| 82 | 77 |
| 83 return isolate->heap()->undefined_value(); | 78 return isolate->heap()->undefined_value(); |
| 84 } | 79 } |
| 85 | 80 |
| 86 | 81 |
| 82 RUNTIME_FUNCTION(Runtime_OptimizeOsr) { | |
| 83 RUNTIME_ASSERT(args.length() == 0); | |
| 84 | |
| 85 HandleScope scope(isolate); | |
|
Michael Starzinger
2015/02/09 12:11:06
nit: Please place the HandleScope first before the
titzer
2015/02/09 12:16:02
Done.
| |
| 86 Handle<JSFunction> function = Handle<JSFunction>::null(); | |
| 87 | |
| 88 { | |
| 89 // Find the JavaScript function on the top of the stack. | |
| 90 JavaScriptFrameIterator it(isolate); | |
| 91 while (!it.done()) { | |
| 92 if (it.frame()->is_java_script()) { | |
| 93 function = Handle<JSFunction>(it.frame()->function()); | |
| 94 break; | |
| 95 } | |
| 96 } | |
| 97 if (function.is_null()) return isolate->heap()->undefined_value(); | |
| 98 } | |
| 99 | |
| 100 // The following assertion was lifted from the DCHECK inside | |
| 101 // JSFunction::MarkForOptimization(). | |
| 102 RUNTIME_ASSERT(function->shared()->allows_lazy_compilation() || | |
| 103 (function->code()->kind() == Code::FUNCTION && | |
| 104 function->code()->optimizable())); | |
| 105 | |
| 106 if (!isolate->use_crankshaft()) return isolate->heap()->undefined_value(); | |
| 107 | |
| 108 // If the function is already optimized, just return. | |
| 109 if (function->IsOptimized()) return isolate->heap()->undefined_value(); | |
| 110 | |
| 111 Code* unoptimized = function->shared()->code(); | |
| 112 if (unoptimized->kind() == Code::FUNCTION) { | |
| 113 DCHECK(BackEdgeTable::Verify(isolate, unoptimized)); | |
| 114 isolate->runtime_profiler()->AttemptOnStackReplacement( | |
| 115 *function, Code::kMaxLoopNestingMarker); | |
| 116 } | |
| 117 | |
| 118 return isolate->heap()->undefined_value(); | |
| 119 } | |
| 120 | |
| 121 | |
| 87 RUNTIME_FUNCTION(Runtime_NeverOptimizeFunction) { | 122 RUNTIME_FUNCTION(Runtime_NeverOptimizeFunction) { |
| 88 HandleScope scope(isolate); | 123 HandleScope scope(isolate); |
| 89 DCHECK(args.length() == 1); | 124 DCHECK(args.length() == 1); |
| 90 CONVERT_ARG_CHECKED(JSFunction, function, 0); | 125 CONVERT_ARG_CHECKED(JSFunction, function, 0); |
| 91 function->shared()->set_disable_optimization_reason(kOptimizationDisabled); | 126 function->shared()->set_disable_optimization_reason(kOptimizationDisabled); |
| 92 function->shared()->set_optimization_disabled(true); | 127 function->shared()->set_optimization_disabled(true); |
| 93 return isolate->heap()->undefined_value(); | 128 return isolate->heap()->undefined_value(); |
| 94 } | 129 } |
| 95 | 130 |
| 96 | 131 |
| (...skipping 306 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 403 RUNTIME_FUNCTION(Runtime_HasFixed##Type##Elements) { \ | 438 RUNTIME_FUNCTION(Runtime_HasFixed##Type##Elements) { \ |
| 404 CONVERT_ARG_CHECKED(JSObject, obj, 0); \ | 439 CONVERT_ARG_CHECKED(JSObject, obj, 0); \ |
| 405 return isolate->heap()->ToBoolean(obj->HasFixed##Type##Elements()); \ | 440 return isolate->heap()->ToBoolean(obj->HasFixed##Type##Elements()); \ |
| 406 } | 441 } |
| 407 | 442 |
| 408 TYPED_ARRAYS(FIXED_TYPED_ARRAYS_CHECK_RUNTIME_FUNCTION) | 443 TYPED_ARRAYS(FIXED_TYPED_ARRAYS_CHECK_RUNTIME_FUNCTION) |
| 409 | 444 |
| 410 #undef FIXED_TYPED_ARRAYS_CHECK_RUNTIME_FUNCTION | 445 #undef FIXED_TYPED_ARRAYS_CHECK_RUNTIME_FUNCTION |
| 411 } | 446 } |
| 412 } // namespace v8::internal | 447 } // namespace v8::internal |
| OLD | NEW |