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

Side by Side Diff: test/cctest/compiler/function-tester.h

Issue 563123004: Unify use-sites of EnsureDeoptimizationSupport. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Decomplicatification (aka. simplify). Created 6 years, 3 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 | Annotate | Revision Log
« no previous file with comments | « src/hydrogen.cc ('k') | test/cctest/compiler/test-codegen-deopt.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 #ifndef V8_CCTEST_COMPILER_FUNCTION_TESTER_H_ 5 #ifndef V8_CCTEST_COMPILER_FUNCTION_TESTER_H_
6 #define V8_CCTEST_COMPILER_FUNCTION_TESTER_H_ 6 #define V8_CCTEST_COMPILER_FUNCTION_TESTER_H_
7 7
8 #include "src/v8.h" 8 #include "src/v8.h"
9 #include "test/cctest/cctest.h" 9 #include "test/cctest/cctest.h"
10 10
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
50 info.MarkAsContextSpecializing(); 50 info.MarkAsContextSpecializing();
51 } 51 }
52 if (flags_ & CompilationInfo::kInliningEnabled) { 52 if (flags_ & CompilationInfo::kInliningEnabled) {
53 info.MarkAsInliningEnabled(); 53 info.MarkAsInliningEnabled();
54 } 54 }
55 if (flags_ & CompilationInfo::kTypingEnabled) { 55 if (flags_ & CompilationInfo::kTypingEnabled) {
56 info.MarkAsTypingEnabled(); 56 info.MarkAsTypingEnabled();
57 } 57 }
58 CHECK(Rewriter::Rewrite(&info)); 58 CHECK(Rewriter::Rewrite(&info));
59 CHECK(Scope::Analyze(&info)); 59 CHECK(Scope::Analyze(&info));
60 CHECK_NE(NULL, info.scope()); 60 CHECK(Compiler::EnsureDeoptimizationSupport(&info));
61 Handle<ScopeInfo> scope_info = ScopeInfo::Create(info.scope(), info.zone());
62 info.shared_info()->set_scope_info(*scope_info);
63
64 EnsureDeoptimizationSupport(&info);
65 61
66 Pipeline pipeline(&info); 62 Pipeline pipeline(&info);
67 Handle<Code> code = pipeline.GenerateCode(); 63 Handle<Code> code = pipeline.GenerateCode();
68 if (FLAG_turbo_deoptimization) { 64 if (FLAG_turbo_deoptimization) {
69 info.context()->native_context()->AddOptimizedCode(*code); 65 info.context()->native_context()->AddOptimizedCode(*code);
70 } 66 }
71 67
72 CHECK(!code.is_null()); 68 CHECK(!code.is_null());
73 function->ReplaceCode(*code); 69 function->ReplaceCode(*code);
74 #elif USE_CRANKSHAFT 70 #elif USE_CRANKSHAFT
75 Handle<Code> unoptimized = Handle<Code>(function->code()); 71 Handle<Code> unoptimized = Handle<Code>(function->code());
76 Handle<Code> code = Compiler::GetOptimizedCode(function, unoptimized, 72 Handle<Code> code = Compiler::GetOptimizedCode(function, unoptimized,
77 Compiler::NOT_CONCURRENT); 73 Compiler::NOT_CONCURRENT);
78 CHECK(!code.is_null()); 74 CHECK(!code.is_null());
79 #if ENABLE_DISASSEMBLER 75 #if ENABLE_DISASSEMBLER
80 if (FLAG_print_opt_code) { 76 if (FLAG_print_opt_code) {
81 CodeTracer::Scope tracing_scope(isolate->GetCodeTracer()); 77 CodeTracer::Scope tracing_scope(isolate->GetCodeTracer());
82 code->Disassemble("test code", tracing_scope.file()); 78 code->Disassemble("test code", tracing_scope.file());
83 } 79 }
84 #endif 80 #endif
85 function->ReplaceCode(*code); 81 function->ReplaceCode(*code);
86 #endif 82 #endif
87 return function; 83 return function;
88 } 84 }
89 85
90 static void EnsureDeoptimizationSupport(CompilationInfo* info) {
91 bool should_recompile = !info->shared_info()->has_deoptimization_support();
92 if (should_recompile) {
93 CompilationInfoWithZone unoptimized(info->shared_info());
94 // Note that we use the same AST that we will use for generating the
95 // optimized code.
96 unoptimized.SetFunction(info->function());
97 unoptimized.PrepareForCompilation(info->scope());
98 unoptimized.SetContext(info->context());
99 if (should_recompile) unoptimized.EnableDeoptimizationSupport();
100 bool succeeded = FullCodeGenerator::MakeCode(&unoptimized);
101 CHECK(succeeded);
102 Handle<SharedFunctionInfo> shared = info->shared_info();
103 shared->EnableDeoptimizationSupport(*unoptimized.code());
104 }
105 }
106
107 MaybeHandle<Object> Call(Handle<Object> a, Handle<Object> b) { 86 MaybeHandle<Object> Call(Handle<Object> a, Handle<Object> b) {
108 Handle<Object> args[] = {a, b}; 87 Handle<Object> args[] = {a, b};
109 return Execution::Call(isolate, function, undefined(), 2, args, false); 88 return Execution::Call(isolate, function, undefined(), 2, args, false);
110 } 89 }
111 90
112 void CheckThrows(Handle<Object> a, Handle<Object> b) { 91 void CheckThrows(Handle<Object> a, Handle<Object> b) {
113 TryCatch try_catch; 92 TryCatch try_catch;
114 MaybeHandle<Object> no_result = Call(a, b); 93 MaybeHandle<Object> no_result = Call(a, b);
115 CHECK(isolate->has_pending_exception()); 94 CHECK(isolate->has_pending_exception());
116 CHECK(try_catch.HasCaught()); 95 CHECK(try_catch.HasCaught());
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
205 Handle<Object> false_value() { return isolate->factory()->false_value(); } 184 Handle<Object> false_value() { return isolate->factory()->false_value(); }
206 185
207 private: 186 private:
208 uint32_t flags_; 187 uint32_t flags_;
209 }; 188 };
210 } 189 }
211 } 190 }
212 } // namespace v8::internal::compiler 191 } // namespace v8::internal::compiler
213 192
214 #endif // V8_CCTEST_COMPILER_FUNCTION_TESTER_H_ 193 #endif // V8_CCTEST_COMPILER_FUNCTION_TESTER_H_
OLDNEW
« no previous file with comments | « src/hydrogen.cc ('k') | test/cctest/compiler/test-codegen-deopt.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698