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

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

Issue 1456003003: Simplify dispatch in optimizing compile stubs. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 1 month 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') | src/x64/builtins-x64.cc » ('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/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/compiler.h" 8 #include "src/compiler.h"
9 #include "src/deoptimizer.h" 9 #include "src/deoptimizer.h"
10 #include "src/frames-inl.h" 10 #include "src/frames-inl.h"
(...skipping 26 matching lines...) Expand all
37 Handle<Code> code; 37 Handle<Code> code;
38 ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, code, 38 ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, code,
39 Compiler::GetLazyCode(function)); 39 Compiler::GetLazyCode(function));
40 DCHECK(code->IsJavaScriptCode()); 40 DCHECK(code->IsJavaScriptCode());
41 41
42 function->ReplaceCode(*code); 42 function->ReplaceCode(*code);
43 return *code; 43 return *code;
44 } 44 }
45 45
46 46
47 RUNTIME_FUNCTION(Runtime_CompileOptimized) { 47 namespace {
48 HandleScope scope(isolate);
49 DCHECK(args.length() == 2);
50 CONVERT_ARG_HANDLE_CHECKED(JSFunction, function, 0);
51 CONVERT_BOOLEAN_ARG_CHECKED(concurrent, 1);
52 48
49 Object* CompileOptimized(Isolate* isolate, Handle<JSFunction> function,
50 Compiler::ConcurrencyMode mode) {
53 StackLimitCheck check(isolate); 51 StackLimitCheck check(isolate);
54 if (check.JsHasOverflowed(1 * KB)) return isolate->StackOverflow(); 52 if (check.JsHasOverflowed(1 * KB)) return isolate->StackOverflow();
55 53
56 Compiler::ConcurrencyMode mode =
57 concurrent ? Compiler::CONCURRENT : Compiler::NOT_CONCURRENT;
58 Handle<Code> code; 54 Handle<Code> code;
59 Handle<Code> unoptimized(function->shared()->code()); 55 Handle<Code> unoptimized(function->shared()->code());
60 if (Compiler::GetOptimizedCode(function, unoptimized, mode).ToHandle(&code)) { 56 if (Compiler::GetOptimizedCode(function, unoptimized, mode).ToHandle(&code)) {
61 // Optimization succeeded, return optimized code. 57 // Optimization succeeded, return optimized code.
62 function->ReplaceCode(*code); 58 function->ReplaceCode(*code);
63 } else { 59 } else {
64 // Optimization failed, get unoptimized code. 60 // Optimization failed, get unoptimized code.
65 if (isolate->has_pending_exception()) { // Possible stack overflow. 61 if (isolate->has_pending_exception()) { // Possible stack overflow.
66 return isolate->heap()->exception(); 62 return isolate->heap()->exception();
67 } 63 }
68 code = Handle<Code>(function->shared()->code(), isolate); 64 code = Handle<Code>(function->shared()->code(), isolate);
69 if (code->kind() != Code::FUNCTION && 65 if (code->kind() != Code::FUNCTION &&
70 code->kind() != Code::OPTIMIZED_FUNCTION) { 66 code->kind() != Code::OPTIMIZED_FUNCTION) {
71 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( 67 ASSIGN_RETURN_FAILURE_ON_EXCEPTION(
72 isolate, code, Compiler::GetUnoptimizedCode(function)); 68 isolate, code, Compiler::GetUnoptimizedCode(function));
73 } 69 }
74 function->ReplaceCode(*code); 70 function->ReplaceCode(*code);
75 } 71 }
76 72
77 DCHECK(function->code()->kind() == Code::FUNCTION || 73 DCHECK(function->code()->kind() == Code::FUNCTION ||
78 function->code()->kind() == Code::OPTIMIZED_FUNCTION || 74 function->code()->kind() == Code::OPTIMIZED_FUNCTION ||
79 function->IsInOptimizationQueue()); 75 function->IsInOptimizationQueue());
80 return function->code(); 76 return function->code();
81 } 77 }
82 78
79 } // namespace
80
81
82 RUNTIME_FUNCTION(Runtime_CompileOptimized_Concurrent) {
83 HandleScope scope(isolate);
84 DCHECK(args.length() == 1);
85 CONVERT_ARG_HANDLE_CHECKED(JSFunction, function, 0);
86 return CompileOptimized(isolate, function, Compiler::CONCURRENT);
87 }
88
89
90 RUNTIME_FUNCTION(Runtime_CompileOptimized_NotConcurrent) {
91 HandleScope scope(isolate);
92 DCHECK(args.length() == 1);
93 CONVERT_ARG_HANDLE_CHECKED(JSFunction, function, 0);
94 return CompileOptimized(isolate, function, Compiler::NOT_CONCURRENT);
95 }
96
83 97
84 RUNTIME_FUNCTION(Runtime_NotifyStubFailure) { 98 RUNTIME_FUNCTION(Runtime_NotifyStubFailure) {
85 HandleScope scope(isolate); 99 HandleScope scope(isolate);
86 DCHECK(args.length() == 0); 100 DCHECK(args.length() == 0);
87 Deoptimizer* deoptimizer = Deoptimizer::Grab(isolate); 101 Deoptimizer* deoptimizer = Deoptimizer::Grab(isolate);
88 DCHECK(AllowHeapAllocation::IsAllowed()); 102 DCHECK(AllowHeapAllocation::IsAllowed());
89 delete deoptimizer; 103 delete deoptimizer;
90 return isolate->heap()->undefined_value(); 104 return isolate->heap()->undefined_value();
91 } 105 }
92 106
(...skipping 346 matching lines...) Expand 10 before | Expand all | Expand 10 after
439 DCHECK(is_valid_language_mode(args.smi_at(3))); 453 DCHECK(is_valid_language_mode(args.smi_at(3)));
440 LanguageMode language_mode = static_cast<LanguageMode>(args.smi_at(3)); 454 LanguageMode language_mode = static_cast<LanguageMode>(args.smi_at(3));
441 DCHECK(args[4]->IsSmi()); 455 DCHECK(args[4]->IsSmi());
442 Handle<SharedFunctionInfo> outer_info(args.at<JSFunction>(2)->shared(), 456 Handle<SharedFunctionInfo> outer_info(args.at<JSFunction>(2)->shared(),
443 isolate); 457 isolate);
444 return CompileGlobalEval(isolate, args.at<String>(1), outer_info, 458 return CompileGlobalEval(isolate, args.at<String>(1), outer_info,
445 language_mode, args.smi_at(4)); 459 language_mode, args.smi_at(4));
446 } 460 }
447 } // namespace internal 461 } // namespace internal
448 } // namespace v8 462 } // namespace v8
OLDNEW
« no previous file with comments | « src/runtime/runtime.h ('k') | src/x64/builtins-x64.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698