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

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

Issue 2122173003: [runtime] Specifically handle robust RUNTIME_ASSERTs. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Fix. Created 4 years, 5 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-strings.cc ('k') | no next file » | 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/runtime/runtime-utils.h" 5 #include "src/runtime/runtime-utils.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/frames-inl.h" 9 #include "src/frames-inl.h"
10 #include "src/full-codegen/full-codegen.h" 10 #include "src/full-codegen/full-codegen.h"
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
95 RUNTIME_FUNCTION(Runtime_IsConcurrentRecompilationSupported) { 95 RUNTIME_FUNCTION(Runtime_IsConcurrentRecompilationSupported) {
96 SealHandleScope shs(isolate); 96 SealHandleScope shs(isolate);
97 DCHECK(args.length() == 0); 97 DCHECK(args.length() == 0);
98 return isolate->heap()->ToBoolean( 98 return isolate->heap()->ToBoolean(
99 isolate->concurrent_recompilation_enabled()); 99 isolate->concurrent_recompilation_enabled());
100 } 100 }
101 101
102 102
103 RUNTIME_FUNCTION(Runtime_OptimizeFunctionOnNextCall) { 103 RUNTIME_FUNCTION(Runtime_OptimizeFunctionOnNextCall) {
104 HandleScope scope(isolate); 104 HandleScope scope(isolate);
105 RUNTIME_ASSERT(args.length() == 1 || args.length() == 2); 105
106 // This function is used by fuzzers, ignore calls with bogus arguments count.
107 if (args.length() != 1 && args.length() != 2) {
108 return isolate->heap()->undefined_value();
109 }
106 110
107 // This function is used by fuzzers to get coverage for optimizations 111 // This function is used by fuzzers to get coverage for optimizations
108 // in compiler. Ignore calls on non-function objects to avoid runtime errors. 112 // in compiler. Ignore calls on non-function objects to avoid runtime errors.
109 CONVERT_ARG_HANDLE_CHECKED(Object, function_object, 0); 113 CONVERT_ARG_HANDLE_CHECKED(Object, function_object, 0);
110 // If it is not a JSFunction, just return. 114 // If it is not a JSFunction, just return.
111 if (!function_object->IsJSFunction()) { 115 if (!function_object->IsJSFunction()) {
112 return isolate->heap()->undefined_value(); 116 return isolate->heap()->undefined_value();
113 } 117 }
114 Handle<JSFunction> function = Handle<JSFunction>::cast(function_object); 118 Handle<JSFunction> function = Handle<JSFunction>::cast(function_object);
115 119
116 // The following assertion was lifted from the DCHECK inside 120 // The following condition was lifted from the DCHECK inside
117 // JSFunction::MarkForOptimization(). 121 // JSFunction::MarkForOptimization().
118 RUNTIME_ASSERT(function->shared()->allows_lazy_compilation() || 122 if (!(function->shared()->allows_lazy_compilation() ||
119 (function->code()->kind() == Code::FUNCTION && 123 (function->code()->kind() == Code::FUNCTION &&
120 !function->shared()->optimization_disabled())); 124 !function->shared()->optimization_disabled()))) {
125 return isolate->heap()->undefined_value();
126 }
121 127
122 // If the function is already optimized, just return. 128 // If the function is already optimized, just return.
123 if (function->IsOptimized()) return isolate->heap()->undefined_value(); 129 if (function->IsOptimized()) return isolate->heap()->undefined_value();
124 130
125 function->MarkForOptimization(); 131 function->MarkForOptimization();
126 132
127 Code* unoptimized = function->shared()->code(); 133 Code* unoptimized = function->shared()->code();
128 if (args.length() == 2 && unoptimized->kind() == Code::FUNCTION) { 134 if (args.length() == 2 && unoptimized->kind() == Code::FUNCTION) {
129 CONVERT_ARG_HANDLE_CHECKED(String, type, 1); 135 CONVERT_ARG_HANDLE_CHECKED(String, type, 1);
130 if (type->IsOneByteEqualTo(STATIC_CHAR_VECTOR("concurrent")) && 136 if (type->IsOneByteEqualTo(STATIC_CHAR_VECTOR("concurrent")) &&
131 isolate->concurrent_recompilation_enabled()) { 137 isolate->concurrent_recompilation_enabled()) {
132 function->AttemptConcurrentOptimization(); 138 function->AttemptConcurrentOptimization();
133 } 139 }
134 } 140 }
135 141
136 return isolate->heap()->undefined_value(); 142 return isolate->heap()->undefined_value();
137 } 143 }
138 144
139 145
140 RUNTIME_FUNCTION(Runtime_OptimizeOsr) { 146 RUNTIME_FUNCTION(Runtime_OptimizeOsr) {
141 HandleScope scope(isolate); 147 HandleScope scope(isolate);
142 RUNTIME_ASSERT(args.length() == 0 || args.length() == 1); 148
149 // This function is used by fuzzers, ignore calls with bogus arguments count.
150 if (args.length() != 0 && args.length() == 1) {
151 return isolate->heap()->undefined_value();
152 }
153
143 Handle<JSFunction> function = Handle<JSFunction>::null(); 154 Handle<JSFunction> function = Handle<JSFunction>::null();
144
145 if (args.length() == 0) { 155 if (args.length() == 0) {
146 // Find the JavaScript function on the top of the stack. 156 // Find the JavaScript function on the top of the stack.
147 JavaScriptFrameIterator it(isolate); 157 JavaScriptFrameIterator it(isolate);
148 while (!it.done()) { 158 while (!it.done()) {
149 if (it.frame()->is_java_script()) { 159 if (it.frame()->is_java_script()) {
150 function = Handle<JSFunction>(it.frame()->function()); 160 function = Handle<JSFunction>(it.frame()->function());
151 break; 161 break;
152 } 162 }
153 } 163 }
154 if (function.is_null()) return isolate->heap()->undefined_value(); 164 if (function.is_null()) return isolate->heap()->undefined_value();
155 } else { 165 } else {
156 // Function was passed as an argument. 166 // Function was passed as an argument.
157 CONVERT_ARG_HANDLE_CHECKED(JSFunction, arg, 0); 167 CONVERT_ARG_HANDLE_CHECKED(JSFunction, arg, 0);
158 function = arg; 168 function = arg;
159 } 169 }
160 170
161 // The following assertion was lifted from the DCHECK inside 171 // The following condition was lifted from the DCHECK inside
162 // JSFunction::MarkForOptimization(). 172 // JSFunction::MarkForOptimization().
163 RUNTIME_ASSERT(function->shared()->allows_lazy_compilation() || 173 if (!(function->shared()->allows_lazy_compilation() ||
164 !function->shared()->optimization_disabled()); 174 !function->shared()->optimization_disabled())) {
175 return isolate->heap()->undefined_value();
176 }
165 177
166 // If function is interpreted, just return. OSR is not supported. 178 // If function is interpreted, just return. OSR is not supported.
167 // TODO(4764): Remove this check when OSR is enabled in the interpreter. 179 // TODO(4764): Remove this check when OSR is enabled in the interpreter.
168 if (function->shared()->HasBytecodeArray()) { 180 if (function->shared()->HasBytecodeArray()) {
169 return isolate->heap()->undefined_value(); 181 return isolate->heap()->undefined_value();
170 } 182 }
171 183
172 // If the function is already optimized, just return. 184 // If the function is already optimized, just return.
173 if (function->IsOptimized()) return isolate->heap()->undefined_value(); 185 if (function->IsOptimized()) return isolate->heap()->undefined_value();
174 186
(...skipping 14 matching lines...) Expand all
189 CONVERT_ARG_CHECKED(JSFunction, function, 0); 201 CONVERT_ARG_CHECKED(JSFunction, function, 0);
190 function->shared()->set_disable_optimization_reason( 202 function->shared()->set_disable_optimization_reason(
191 kOptimizationDisabledForTest); 203 kOptimizationDisabledForTest);
192 function->shared()->set_optimization_disabled(true); 204 function->shared()->set_optimization_disabled(true);
193 return isolate->heap()->undefined_value(); 205 return isolate->heap()->undefined_value();
194 } 206 }
195 207
196 208
197 RUNTIME_FUNCTION(Runtime_GetOptimizationStatus) { 209 RUNTIME_FUNCTION(Runtime_GetOptimizationStatus) {
198 HandleScope scope(isolate); 210 HandleScope scope(isolate);
199 RUNTIME_ASSERT(args.length() == 1 || args.length() == 2); 211 DCHECK(args.length() == 1 || args.length() == 2);
200 if (!isolate->use_crankshaft()) { 212 if (!isolate->use_crankshaft()) {
201 return Smi::FromInt(4); // 4 == "never". 213 return Smi::FromInt(4); // 4 == "never".
202 } 214 }
203 bool sync_with_compiler_thread = true; 215 bool sync_with_compiler_thread = true;
204 if (args.length() == 2) { 216 if (args.length() == 2) {
205 CONVERT_ARG_HANDLE_CHECKED(String, sync, 1); 217 CONVERT_ARG_HANDLE_CHECKED(String, sync, 1);
206 if (sync->IsOneByteEqualTo(STATIC_CHAR_VECTOR("no sync"))) { 218 if (sync->IsOneByteEqualTo(STATIC_CHAR_VECTOR("no sync"))) {
207 sync_with_compiler_thread = false; 219 sync_with_compiler_thread = false;
208 } 220 }
209 } 221 }
(...skipping 16 matching lines...) Expand all
226 if (function->IsOptimized() && function->code()->is_turbofanned()) { 238 if (function->IsOptimized() && function->code()->is_turbofanned()) {
227 return Smi::FromInt(7); // 7 == "TurboFan compiler". 239 return Smi::FromInt(7); // 7 == "TurboFan compiler".
228 } 240 }
229 return function->IsOptimized() ? Smi::FromInt(1) // 1 == "yes". 241 return function->IsOptimized() ? Smi::FromInt(1) // 1 == "yes".
230 : Smi::FromInt(2); // 2 == "no". 242 : Smi::FromInt(2); // 2 == "no".
231 } 243 }
232 244
233 245
234 RUNTIME_FUNCTION(Runtime_UnblockConcurrentRecompilation) { 246 RUNTIME_FUNCTION(Runtime_UnblockConcurrentRecompilation) {
235 DCHECK(args.length() == 0); 247 DCHECK(args.length() == 0);
236 RUNTIME_ASSERT(FLAG_block_concurrent_recompilation); 248 if (FLAG_block_concurrent_recompilation &&
237 RUNTIME_ASSERT(isolate->concurrent_recompilation_enabled()); 249 isolate->concurrent_recompilation_enabled()) {
238 isolate->optimizing_compile_dispatcher()->Unblock(); 250 isolate->optimizing_compile_dispatcher()->Unblock();
251 }
239 return isolate->heap()->undefined_value(); 252 return isolate->heap()->undefined_value();
240 } 253 }
241 254
242 255
243 RUNTIME_FUNCTION(Runtime_GetOptimizationCount) { 256 RUNTIME_FUNCTION(Runtime_GetOptimizationCount) {
244 HandleScope scope(isolate); 257 HandleScope scope(isolate);
245 DCHECK(args.length() == 1); 258 DCHECK(args.length() == 1);
246 CONVERT_ARG_HANDLE_CHECKED(JSFunction, function, 0); 259 CONVERT_ARG_HANDLE_CHECKED(JSFunction, function, 0);
247 return Smi::FromInt(function->shared()->opt_count()); 260 return Smi::FromInt(function->shared()->opt_count());
248 } 261 }
(...skipping 318 matching lines...) Expand 10 before | Expand all | Expand 10 after
567 580
568 RUNTIME_FUNCTION(Runtime_SpeciesProtector) { 581 RUNTIME_FUNCTION(Runtime_SpeciesProtector) {
569 SealHandleScope shs(isolate); 582 SealHandleScope shs(isolate);
570 DCHECK_EQ(0, args.length()); 583 DCHECK_EQ(0, args.length());
571 return isolate->heap()->ToBoolean(isolate->IsArraySpeciesLookupChainIntact()); 584 return isolate->heap()->ToBoolean(isolate->IsArraySpeciesLookupChainIntact());
572 } 585 }
573 586
574 587
575 } // namespace internal 588 } // namespace internal
576 } // namespace v8 589 } // namespace v8
OLDNEW
« no previous file with comments | « src/runtime/runtime-strings.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698