Chromium Code Reviews| 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 #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 |
| 11 #include "src/compiler.h" | 11 #include "src/compiler.h" |
| 12 #include "src/compiler/pipeline.h" | 12 #include "src/compiler/pipeline.h" |
| 13 #include "src/execution.h" | 13 #include "src/execution.h" |
| 14 #include "src/full-codegen.h" | 14 #include "src/full-codegen.h" |
| 15 #include "src/handles.h" | 15 #include "src/handles.h" |
| 16 #include "src/objects-inl.h" | 16 #include "src/objects-inl.h" |
| 17 #include "src/parser.h" | 17 #include "src/parser.h" |
| 18 #include "src/rewriter.h" | 18 #include "src/rewriter.h" |
| 19 #include "src/scopes.h" | 19 #include "src/scopes.h" |
| 20 | 20 |
| 21 #define USE_CRANKSHAFT 0 | 21 #define USE_CRANKSHAFT 0 |
| 22 | 22 |
| 23 namespace v8 { | 23 namespace v8 { |
| 24 namespace internal { | 24 namespace internal { |
| 25 namespace compiler { | 25 namespace compiler { |
| 26 | 26 |
| 27 class FunctionTester : public InitializedHandleScope { | 27 class FunctionTester : public InitializedHandleScope { |
| 28 public: | 28 public: |
| 29 explicit FunctionTester(const char* source, bool context_specialization = | 29 explicit FunctionTester(const char* source, uint32_t flags = 0) |
| 30 FLAG_context_specialization) | |
| 31 : isolate(main_isolate()), | 30 : isolate(main_isolate()), |
| 32 function((FLAG_allow_natives_syntax = true, NewFunction(source))), | 31 function((FLAG_allow_natives_syntax = true, NewFunction(source))), |
| 33 context_specialization_(context_specialization) { | 32 flags_(flags) { |
| 34 Compile(function); | 33 Compile(function); |
| 34 USE(flags_); | |
|
Michael Starzinger
2014/08/27 13:26:18
Why do we need this USE here?
sigurds
2014/08/27 13:48:49
The only use is guarded by V8_TURBOFAN_TARGET, so
Michael Starzinger
2014/08/27 14:06:40
Acknowledged. Interesting, I didn't know that C-co
| |
| 35 } | 35 } |
| 36 | 36 |
| 37 Isolate* isolate; | 37 Isolate* isolate; |
| 38 Handle<JSFunction> function; | 38 Handle<JSFunction> function; |
| 39 | 39 |
| 40 Handle<JSFunction> Compile(Handle<JSFunction> function) { | 40 Handle<JSFunction> Compile(Handle<JSFunction> function) { |
| 41 #if V8_TURBOFAN_TARGET | 41 #if V8_TURBOFAN_TARGET |
| 42 CompilationInfoWithZone info(function); | 42 CompilationInfoWithZone info(function); |
| 43 | 43 |
| 44 CHECK(Parser::Parse(&info)); | 44 CHECK(Parser::Parse(&info)); |
| 45 StrictMode strict_mode = info.function()->strict_mode(); | 45 StrictMode strict_mode = info.function()->strict_mode(); |
| 46 info.SetStrictMode(strict_mode); | 46 info.SetStrictMode(strict_mode); |
| 47 info.SetOptimizing(BailoutId::None(), Handle<Code>(function->code())); | 47 info.SetOptimizing(BailoutId::None(), Handle<Code>(function->code())); |
| 48 if (context_specialization_) info.MarkAsContextSpecializing(); | 48 if (flags_ & CompilationInfo::kContextSpecializing) |
| 49 info.MarkAsContextSpecializing(); | |
|
Michael Starzinger
2014/08/27 13:26:18
If the condition goes over a line-break then pleas
sigurds
2014/08/27 13:48:49
Done.
| |
| 50 if (flags_ & CompilationInfo::kInliningEnabled) | |
| 51 info.MarkAsInliningEnabled(); | |
| 49 CHECK(Rewriter::Rewrite(&info)); | 52 CHECK(Rewriter::Rewrite(&info)); |
| 50 CHECK(Scope::Analyze(&info)); | 53 CHECK(Scope::Analyze(&info)); |
| 51 CHECK_NE(NULL, info.scope()); | 54 CHECK_NE(NULL, info.scope()); |
| 52 Handle<ScopeInfo> scope_info = ScopeInfo::Create(info.scope(), info.zone()); | 55 Handle<ScopeInfo> scope_info = ScopeInfo::Create(info.scope(), info.zone()); |
| 53 info.shared_info()->set_scope_info(*scope_info); | 56 info.shared_info()->set_scope_info(*scope_info); |
| 54 | 57 |
| 55 EnsureDeoptimizationSupport(&info); | 58 EnsureDeoptimizationSupport(&info); |
| 56 | 59 |
| 57 Pipeline pipeline(&info); | 60 Pipeline pipeline(&info); |
| 58 Handle<Code> code = pipeline.GenerateCode(); | 61 Handle<Code> code = pipeline.GenerateCode(); |
| (...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 186 | 189 |
| 187 Handle<Object> undefined() { return isolate->factory()->undefined_value(); } | 190 Handle<Object> undefined() { return isolate->factory()->undefined_value(); } |
| 188 | 191 |
| 189 Handle<Object> null() { return isolate->factory()->null_value(); } | 192 Handle<Object> null() { return isolate->factory()->null_value(); } |
| 190 | 193 |
| 191 Handle<Object> true_value() { return isolate->factory()->true_value(); } | 194 Handle<Object> true_value() { return isolate->factory()->true_value(); } |
| 192 | 195 |
| 193 Handle<Object> false_value() { return isolate->factory()->false_value(); } | 196 Handle<Object> false_value() { return isolate->factory()->false_value(); } |
| 194 | 197 |
| 195 private: | 198 private: |
| 196 bool context_specialization_; | 199 uint32_t flags_; |
| 197 }; | 200 }; |
| 198 } | 201 } |
| 199 } | 202 } |
| 200 } // namespace v8::internal::compiler | 203 } // namespace v8::internal::compiler |
| 201 | 204 |
| 202 #endif // V8_CCTEST_COMPILER_FUNCTION_TESTER_H_ | 205 #endif // V8_CCTEST_COMPILER_FUNCTION_TESTER_H_ |
| OLD | NEW |