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

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

Issue 2188713002: [runtime] Fix stack frame iteration in test methods. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 years, 4 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 | « no previous file | 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 <memory> 7 #include <memory>
8 8
9 #include "src/arguments.h" 9 #include "src/arguments.h"
10 #include "src/deoptimizer.h" 10 #include "src/deoptimizer.h"
(...skipping 19 matching lines...) Expand all
30 DCHECK(args.length() == 1); 30 DCHECK(args.length() == 1);
31 31
32 // This function is used by fuzzers to get coverage in compiler. 32 // This function is used by fuzzers to get coverage in compiler.
33 // Ignore calls on non-function objects to avoid runtime errors. 33 // Ignore calls on non-function objects to avoid runtime errors.
34 CONVERT_ARG_HANDLE_CHECKED(Object, function_object, 0); 34 CONVERT_ARG_HANDLE_CHECKED(Object, function_object, 0);
35 if (!function_object->IsJSFunction()) { 35 if (!function_object->IsJSFunction()) {
36 return isolate->heap()->undefined_value(); 36 return isolate->heap()->undefined_value();
37 } 37 }
38 Handle<JSFunction> function = Handle<JSFunction>::cast(function_object); 38 Handle<JSFunction> function = Handle<JSFunction>::cast(function_object);
39 39
40 // If the function is not optimized, just return.
40 if (!function->IsOptimized()) return isolate->heap()->undefined_value(); 41 if (!function->IsOptimized()) return isolate->heap()->undefined_value();
41 42
42 // TODO(turbofan): Deoptimization is not supported yet. 43 // TODO(turbofan): Deoptimization is not supported yet.
43 if (function->code()->is_turbofanned() && 44 if (function->code()->is_turbofanned() &&
44 function->shared()->asm_function() && !FLAG_turbo_asm_deoptimization) { 45 function->shared()->asm_function() && !FLAG_turbo_asm_deoptimization) {
45 return isolate->heap()->undefined_value(); 46 return isolate->heap()->undefined_value();
46 } 47 }
47 48
48 Deoptimizer::DeoptimizeFunction(*function); 49 Deoptimizer::DeoptimizeFunction(*function);
49 50
50 return isolate->heap()->undefined_value(); 51 return isolate->heap()->undefined_value();
51 } 52 }
52 53
53 54
54 RUNTIME_FUNCTION(Runtime_DeoptimizeNow) { 55 RUNTIME_FUNCTION(Runtime_DeoptimizeNow) {
55 HandleScope scope(isolate); 56 HandleScope scope(isolate);
56 DCHECK(args.length() == 0); 57 DCHECK(args.length() == 0);
57 58
58 Handle<JSFunction> function; 59 Handle<JSFunction> function;
59 60
60 // If the argument is 'undefined', deoptimize the topmost 61 // Find the JavaScript function on the top of the stack.
61 // function.
62 JavaScriptFrameIterator it(isolate); 62 JavaScriptFrameIterator it(isolate);
63 while (!it.done()) { 63 if (!it.done()) function = Handle<JSFunction>(it.frame()->function());
64 if (it.frame()->is_java_script()) {
65 function = Handle<JSFunction>(it.frame()->function());
66 break;
67 }
68 }
69 if (function.is_null()) return isolate->heap()->undefined_value(); 64 if (function.is_null()) return isolate->heap()->undefined_value();
70 65
66 // If the function is not optimized, just return.
71 if (!function->IsOptimized()) return isolate->heap()->undefined_value(); 67 if (!function->IsOptimized()) return isolate->heap()->undefined_value();
72 68
73 // TODO(turbofan): Deoptimization is not supported yet. 69 // TODO(turbofan): Deoptimization is not supported yet.
74 if (function->code()->is_turbofanned() && 70 if (function->code()->is_turbofanned() &&
75 function->shared()->asm_function() && !FLAG_turbo_asm_deoptimization) { 71 function->shared()->asm_function() && !FLAG_turbo_asm_deoptimization) {
76 return isolate->heap()->undefined_value(); 72 return isolate->heap()->undefined_value();
77 } 73 }
78 74
79 Deoptimizer::DeoptimizeFunction(*function); 75 Deoptimizer::DeoptimizeFunction(*function);
80 76
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
148 144
149 // This function is used by fuzzers, ignore calls with bogus arguments count. 145 // This function is used by fuzzers, ignore calls with bogus arguments count.
150 if (args.length() != 0 && args.length() != 1) { 146 if (args.length() != 0 && args.length() != 1) {
151 return isolate->heap()->undefined_value(); 147 return isolate->heap()->undefined_value();
152 } 148 }
153 149
154 Handle<JSFunction> function = Handle<JSFunction>::null(); 150 Handle<JSFunction> function = Handle<JSFunction>::null();
155 if (args.length() == 0) { 151 if (args.length() == 0) {
156 // Find the JavaScript function on the top of the stack. 152 // Find the JavaScript function on the top of the stack.
157 JavaScriptFrameIterator it(isolate); 153 JavaScriptFrameIterator it(isolate);
158 while (!it.done()) { 154 if (!it.done()) function = Handle<JSFunction>(it.frame()->function());
159 if (it.frame()->is_java_script()) {
160 function = Handle<JSFunction>(it.frame()->function());
161 break;
162 }
163 }
164 if (function.is_null()) return isolate->heap()->undefined_value(); 155 if (function.is_null()) return isolate->heap()->undefined_value();
165 } else { 156 } else {
166 // Function was passed as an argument. 157 // Function was passed as an argument.
167 CONVERT_ARG_HANDLE_CHECKED(JSFunction, arg, 0); 158 CONVERT_ARG_HANDLE_CHECKED(JSFunction, arg, 0);
168 function = arg; 159 function = arg;
169 } 160 }
170 161
171 // The following condition was lifted from the DCHECK inside
172 // JSFunction::MarkForOptimization().
173 if (!(function->shared()->allows_lazy_compilation() ||
174 !function->shared()->optimization_disabled())) {
175 return isolate->heap()->undefined_value();
176 }
177
178 // If function is interpreted but OSR hasn't been enabled, just return. 162 // If function is interpreted but OSR hasn't been enabled, just return.
179 if (function->shared()->HasBytecodeArray() && !FLAG_ignition_osr) { 163 if (function->shared()->HasBytecodeArray() && !FLAG_ignition_osr) {
180 return isolate->heap()->undefined_value(); 164 return isolate->heap()->undefined_value();
181 } 165 }
182 166
183 // If the function is already optimized, just return. 167 // If the function is already optimized, just return.
184 if (function->IsOptimized()) return isolate->heap()->undefined_value(); 168 if (function->IsOptimized()) return isolate->heap()->undefined_value();
185 169
186 // Make the profiler arm all back edges in unoptimized code. 170 // Make the profiler arm all back edges in unoptimized code.
187 if (function->shared()->HasBytecodeArray() || 171 if (function->shared()->HasBytecodeArray() ||
(...skipping 402 matching lines...) Expand 10 before | Expand all | Expand 10 after
590 574
591 RUNTIME_FUNCTION(Runtime_SpeciesProtector) { 575 RUNTIME_FUNCTION(Runtime_SpeciesProtector) {
592 SealHandleScope shs(isolate); 576 SealHandleScope shs(isolate);
593 DCHECK_EQ(0, args.length()); 577 DCHECK_EQ(0, args.length());
594 return isolate->heap()->ToBoolean(isolate->IsArraySpeciesLookupChainIntact()); 578 return isolate->heap()->ToBoolean(isolate->IsArraySpeciesLookupChainIntact());
595 } 579 }
596 580
597 581
598 } // namespace internal 582 } // namespace internal
599 } // namespace v8 583 } // namespace v8
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698