Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(705)

Side by Side Diff: src/runtime/runtime-test.cc

Issue 906243002: Make it easier to test OSR with %OptimizeOsr() runtime call. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/runtime/runtime.h ('k') | test/mjsunit/compiler/optimized-for-in.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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 HandleScope scope(isolate);
84 RUNTIME_ASSERT(args.length() == 0);
85 Handle<JSFunction> function = Handle<JSFunction>::null();
86
87 {
88 // Find the JavaScript function on the top of the stack.
89 JavaScriptFrameIterator it(isolate);
90 while (!it.done()) {
91 if (it.frame()->is_java_script()) {
92 function = Handle<JSFunction>(it.frame()->function());
93 break;
94 }
95 }
96 if (function.is_null()) return isolate->heap()->undefined_value();
97 }
98
99 // The following assertion was lifted from the DCHECK inside
100 // JSFunction::MarkForOptimization().
101 RUNTIME_ASSERT(function->shared()->allows_lazy_compilation() ||
102 (function->code()->kind() == Code::FUNCTION &&
103 function->code()->optimizable()));
104
105 if (!isolate->use_crankshaft()) return isolate->heap()->undefined_value();
106
107 // If the function is already optimized, just return.
108 if (function->IsOptimized()) return isolate->heap()->undefined_value();
109
110 Code* unoptimized = function->shared()->code();
111 if (unoptimized->kind() == Code::FUNCTION) {
112 DCHECK(BackEdgeTable::Verify(isolate, unoptimized));
113 isolate->runtime_profiler()->AttemptOnStackReplacement(
114 *function, Code::kMaxLoopNestingMarker);
115 }
116
117 return isolate->heap()->undefined_value();
118 }
119
120
87 RUNTIME_FUNCTION(Runtime_NeverOptimizeFunction) { 121 RUNTIME_FUNCTION(Runtime_NeverOptimizeFunction) {
88 HandleScope scope(isolate); 122 HandleScope scope(isolate);
89 DCHECK(args.length() == 1); 123 DCHECK(args.length() == 1);
90 CONVERT_ARG_CHECKED(JSFunction, function, 0); 124 CONVERT_ARG_CHECKED(JSFunction, function, 0);
91 function->shared()->set_disable_optimization_reason(kOptimizationDisabled); 125 function->shared()->set_disable_optimization_reason(kOptimizationDisabled);
92 function->shared()->set_optimization_disabled(true); 126 function->shared()->set_optimization_disabled(true);
93 return isolate->heap()->undefined_value(); 127 return isolate->heap()->undefined_value();
94 } 128 }
95 129
96 130
(...skipping 306 matching lines...) Expand 10 before | Expand all | Expand 10 after
403 RUNTIME_FUNCTION(Runtime_HasFixed##Type##Elements) { \ 437 RUNTIME_FUNCTION(Runtime_HasFixed##Type##Elements) { \
404 CONVERT_ARG_CHECKED(JSObject, obj, 0); \ 438 CONVERT_ARG_CHECKED(JSObject, obj, 0); \
405 return isolate->heap()->ToBoolean(obj->HasFixed##Type##Elements()); \ 439 return isolate->heap()->ToBoolean(obj->HasFixed##Type##Elements()); \
406 } 440 }
407 441
408 TYPED_ARRAYS(FIXED_TYPED_ARRAYS_CHECK_RUNTIME_FUNCTION) 442 TYPED_ARRAYS(FIXED_TYPED_ARRAYS_CHECK_RUNTIME_FUNCTION)
409 443
410 #undef FIXED_TYPED_ARRAYS_CHECK_RUNTIME_FUNCTION 444 #undef FIXED_TYPED_ARRAYS_CHECK_RUNTIME_FUNCTION
411 } 445 }
412 } // namespace v8::internal 446 } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/runtime/runtime.h ('k') | test/mjsunit/compiler/optimized-for-in.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698