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/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/asmjs/asm-js.h" | 8 #include "src/asmjs/asm-js.h" |
9 #include "src/compiler-dispatcher/optimizing-compile-dispatcher.h" | 9 #include "src/compiler-dispatcher/optimizing-compile-dispatcher.h" |
10 #include "src/compiler.h" | 10 #include "src/compiler.h" |
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
120 if (function->shared()->code() == | 120 if (function->shared()->code() == |
121 isolate->builtins()->builtin(Builtins::kInstantiateAsmJs)) { | 121 isolate->builtins()->builtin(Builtins::kInstantiateAsmJs)) { |
122 function->shared()->ReplaceCode( | 122 function->shared()->ReplaceCode( |
123 isolate->builtins()->builtin(Builtins::kCompileLazy)); | 123 isolate->builtins()->builtin(Builtins::kCompileLazy)); |
124 } | 124 } |
125 return Smi::kZero; | 125 return Smi::kZero; |
126 } | 126 } |
127 | 127 |
128 RUNTIME_FUNCTION(Runtime_NotifyStubFailure) { | 128 RUNTIME_FUNCTION(Runtime_NotifyStubFailure) { |
129 HandleScope scope(isolate); | 129 HandleScope scope(isolate); |
130 DCHECK(args.length() == 0); | 130 DCHECK_EQ(0, args.length()); |
131 Deoptimizer* deoptimizer = Deoptimizer::Grab(isolate); | 131 Deoptimizer* deoptimizer = Deoptimizer::Grab(isolate); |
132 DCHECK(AllowHeapAllocation::IsAllowed()); | 132 DCHECK(AllowHeapAllocation::IsAllowed()); |
133 delete deoptimizer; | 133 delete deoptimizer; |
134 return isolate->heap()->undefined_value(); | 134 return isolate->heap()->undefined_value(); |
135 } | 135 } |
136 | 136 |
137 class ActivationsFinder : public ThreadVisitor { | 137 class ActivationsFinder : public ThreadVisitor { |
138 public: | 138 public: |
139 Code* code_; | 139 Code* code_; |
140 bool has_code_activations_; | 140 bool has_code_activations_; |
(...skipping 10 matching lines...) Expand all Loading... |
151 for (; !it->done(); it->Advance()) { | 151 for (; !it->done(); it->Advance()) { |
152 JavaScriptFrame* frame = it->frame(); | 152 JavaScriptFrame* frame = it->frame(); |
153 if (code_->contains(frame->pc())) has_code_activations_ = true; | 153 if (code_->contains(frame->pc())) has_code_activations_ = true; |
154 } | 154 } |
155 } | 155 } |
156 }; | 156 }; |
157 | 157 |
158 | 158 |
159 RUNTIME_FUNCTION(Runtime_NotifyDeoptimized) { | 159 RUNTIME_FUNCTION(Runtime_NotifyDeoptimized) { |
160 HandleScope scope(isolate); | 160 HandleScope scope(isolate); |
161 DCHECK(args.length() == 1); | 161 DCHECK_EQ(1, args.length()); |
162 CONVERT_SMI_ARG_CHECKED(type_arg, 0); | 162 CONVERT_SMI_ARG_CHECKED(type_arg, 0); |
163 Deoptimizer::BailoutType type = | 163 Deoptimizer::BailoutType type = |
164 static_cast<Deoptimizer::BailoutType>(type_arg); | 164 static_cast<Deoptimizer::BailoutType>(type_arg); |
165 Deoptimizer* deoptimizer = Deoptimizer::Grab(isolate); | 165 Deoptimizer* deoptimizer = Deoptimizer::Grab(isolate); |
166 DCHECK(AllowHeapAllocation::IsAllowed()); | 166 DCHECK(AllowHeapAllocation::IsAllowed()); |
167 TimerEventScope<TimerEventDeoptimizeCode> timer(isolate); | 167 TimerEventScope<TimerEventDeoptimizeCode> timer(isolate); |
168 TRACE_EVENT0("v8", "V8.DeoptimizeCode"); | 168 TRACE_EVENT0("v8", "V8.DeoptimizeCode"); |
169 | 169 |
170 Handle<JSFunction> function = deoptimizer->function(); | 170 Handle<JSFunction> function = deoptimizer->function(); |
171 Handle<Code> optimized_code = deoptimizer->compiled_code(); | 171 Handle<Code> optimized_code = deoptimizer->compiled_code(); |
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
293 bytecode->set_osr_loop_nesting_level(0); | 293 bytecode->set_osr_loop_nesting_level(0); |
294 | 294 |
295 // Return a BailoutId representing the bytecode offset of the back branch. | 295 // Return a BailoutId representing the bytecode offset of the back branch. |
296 return BailoutId(iframe->GetBytecodeOffset()); | 296 return BailoutId(iframe->GetBytecodeOffset()); |
297 } | 297 } |
298 | 298 |
299 } // namespace | 299 } // namespace |
300 | 300 |
301 RUNTIME_FUNCTION(Runtime_CompileForOnStackReplacement) { | 301 RUNTIME_FUNCTION(Runtime_CompileForOnStackReplacement) { |
302 HandleScope scope(isolate); | 302 HandleScope scope(isolate); |
303 DCHECK(args.length() == 1); | 303 DCHECK_EQ(1, args.length()); |
304 CONVERT_ARG_HANDLE_CHECKED(JSFunction, function, 0); | 304 CONVERT_ARG_HANDLE_CHECKED(JSFunction, function, 0); |
305 | 305 |
306 // We're not prepared to handle a function with arguments object. | 306 // We're not prepared to handle a function with arguments object. |
307 DCHECK(!function->shared()->uses_arguments()); | 307 DCHECK(!function->shared()->uses_arguments()); |
308 | 308 |
309 // Only reachable when OST is enabled. | 309 // Only reachable when OST is enabled. |
310 CHECK(FLAG_use_osr); | 310 CHECK(FLAG_use_osr); |
311 | 311 |
312 // Determine frame triggering OSR request. | 312 // Determine frame triggering OSR request. |
313 JavaScriptFrameIterator it(isolate); | 313 JavaScriptFrameIterator it(isolate); |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
378 | 378 |
379 if (!function->IsOptimized()) { | 379 if (!function->IsOptimized()) { |
380 function->ReplaceCode(function->shared()->code()); | 380 function->ReplaceCode(function->shared()->code()); |
381 } | 381 } |
382 return NULL; | 382 return NULL; |
383 } | 383 } |
384 | 384 |
385 | 385 |
386 RUNTIME_FUNCTION(Runtime_TryInstallOptimizedCode) { | 386 RUNTIME_FUNCTION(Runtime_TryInstallOptimizedCode) { |
387 HandleScope scope(isolate); | 387 HandleScope scope(isolate); |
388 DCHECK(args.length() == 1); | 388 DCHECK_EQ(1, args.length()); |
389 CONVERT_ARG_HANDLE_CHECKED(JSFunction, function, 0); | 389 CONVERT_ARG_HANDLE_CHECKED(JSFunction, function, 0); |
390 | 390 |
391 // First check if this is a real stack overflow. | 391 // First check if this is a real stack overflow. |
392 StackLimitCheck check(isolate); | 392 StackLimitCheck check(isolate); |
393 if (check.JsHasOverflowed()) { | 393 if (check.JsHasOverflowed()) { |
394 SealHandleScope shs(isolate); | 394 SealHandleScope shs(isolate); |
395 return isolate->StackOverflow(); | 395 return isolate->StackOverflow(); |
396 } | 396 } |
397 | 397 |
398 isolate->optimizing_compile_dispatcher()->InstallOptimizedFunctions(); | 398 isolate->optimizing_compile_dispatcher()->InstallOptimizedFunctions(); |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
445 isolate, compiled, Compiler::GetFunctionFromEval( | 445 isolate, compiled, Compiler::GetFunctionFromEval( |
446 source, outer_info, context, language_mode, | 446 source, outer_info, context, language_mode, |
447 restriction, eval_scope_position, eval_position), | 447 restriction, eval_scope_position, eval_position), |
448 isolate->heap()->exception()); | 448 isolate->heap()->exception()); |
449 return *compiled; | 449 return *compiled; |
450 } | 450 } |
451 | 451 |
452 | 452 |
453 RUNTIME_FUNCTION(Runtime_ResolvePossiblyDirectEval) { | 453 RUNTIME_FUNCTION(Runtime_ResolvePossiblyDirectEval) { |
454 HandleScope scope(isolate); | 454 HandleScope scope(isolate); |
455 DCHECK(args.length() == 6); | 455 DCHECK_EQ(6, args.length()); |
456 | 456 |
457 Handle<Object> callee = args.at(0); | 457 Handle<Object> callee = args.at(0); |
458 | 458 |
459 // If "eval" didn't refer to the original GlobalEval, it's not a | 459 // If "eval" didn't refer to the original GlobalEval, it's not a |
460 // direct call to eval. | 460 // direct call to eval. |
461 // (And even if it is, but the first argument isn't a string, just let | 461 // (And even if it is, but the first argument isn't a string, just let |
462 // execution default to an indirect call to eval, which will also return | 462 // execution default to an indirect call to eval, which will also return |
463 // the first argument without doing anything). | 463 // the first argument without doing anything). |
464 if (*callee != isolate->native_context()->global_eval_fun() || | 464 if (*callee != isolate->native_context()->global_eval_fun() || |
465 !args[1]->IsString()) { | 465 !args[1]->IsString()) { |
466 return *callee; | 466 return *callee; |
467 } | 467 } |
468 | 468 |
469 DCHECK(args[3]->IsSmi()); | 469 DCHECK(args[3]->IsSmi()); |
470 DCHECK(is_valid_language_mode(args.smi_at(3))); | 470 DCHECK(is_valid_language_mode(args.smi_at(3))); |
471 LanguageMode language_mode = static_cast<LanguageMode>(args.smi_at(3)); | 471 LanguageMode language_mode = static_cast<LanguageMode>(args.smi_at(3)); |
472 DCHECK(args[4]->IsSmi()); | 472 DCHECK(args[4]->IsSmi()); |
473 Handle<SharedFunctionInfo> outer_info(args.at<JSFunction>(2)->shared(), | 473 Handle<SharedFunctionInfo> outer_info(args.at<JSFunction>(2)->shared(), |
474 isolate); | 474 isolate); |
475 return CompileGlobalEval(isolate, args.at<String>(1), outer_info, | 475 return CompileGlobalEval(isolate, args.at<String>(1), outer_info, |
476 language_mode, args.smi_at(4), args.smi_at(5)); | 476 language_mode, args.smi_at(4), args.smi_at(5)); |
477 } | 477 } |
478 } // namespace internal | 478 } // namespace internal |
479 } // namespace v8 | 479 } // namespace v8 |
OLD | NEW |