| 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 | 
| (...skipping 14 matching lines...) Expand all  Loading... | 
| 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, uint32_t flags = 0) | 29   explicit FunctionTester(const char* source, uint32_t flags = 0) | 
| 30       : isolate(main_isolate()), | 30       : isolate(main_isolate()), | 
| 31         function((FLAG_allow_natives_syntax = true, NewFunction(source))), | 31         function((FLAG_allow_natives_syntax = true, NewFunction(source))), | 
| 32         flags_(flags) { | 32         flags_(flags) { | 
| 33     Compile(function); | 33     Compile(function); | 
| 34     const uint32_t supported_flags = CompilationInfo::kContextSpecializing | | 34     const uint32_t supported_flags = CompilationInfo::kContextSpecializing | | 
| 35                                      CompilationInfo::kInliningEnabled; | 35                                      CompilationInfo::kInliningEnabled | | 
|  | 36                                      CompilationInfo::kTypingEnabled; | 
| 36     CHECK_EQ(0, flags_ & ~supported_flags); | 37     CHECK_EQ(0, flags_ & ~supported_flags); | 
| 37   } | 38   } | 
| 38 | 39 | 
| 39   Isolate* isolate; | 40   Isolate* isolate; | 
| 40   Handle<JSFunction> function; | 41   Handle<JSFunction> function; | 
| 41 | 42 | 
| 42   Handle<JSFunction> Compile(Handle<JSFunction> function) { | 43   Handle<JSFunction> Compile(Handle<JSFunction> function) { | 
| 43 #if V8_TURBOFAN_TARGET | 44 #if V8_TURBOFAN_TARGET | 
| 44     CompilationInfoWithZone info(function); | 45     CompilationInfoWithZone info(function); | 
| 45 | 46 | 
| 46     CHECK(Parser::Parse(&info)); | 47     CHECK(Parser::Parse(&info)); | 
| 47     StrictMode strict_mode = info.function()->strict_mode(); | 48     StrictMode strict_mode = info.function()->strict_mode(); | 
| 48     info.SetStrictMode(strict_mode); | 49     info.SetStrictMode(strict_mode); | 
| 49     info.SetOptimizing(BailoutId::None(), Handle<Code>(function->code())); | 50     info.SetOptimizing(BailoutId::None(), Handle<Code>(function->code())); | 
| 50     if (flags_ & CompilationInfo::kContextSpecializing) { | 51     if (flags_ & CompilationInfo::kContextSpecializing) { | 
| 51       info.MarkAsContextSpecializing(); | 52       info.MarkAsContextSpecializing(); | 
| 52     } | 53     } | 
| 53     if (flags_ & CompilationInfo::kInliningEnabled) { | 54     if (flags_ & CompilationInfo::kInliningEnabled) { | 
| 54       info.MarkAsInliningEnabled(); | 55       info.MarkAsInliningEnabled(); | 
| 55     } | 56     } | 
|  | 57     if (flags_ & CompilationInfo::kTypingEnabled) { | 
|  | 58       info.MarkAsTypingEnabled(); | 
|  | 59     } | 
| 56     CHECK(Rewriter::Rewrite(&info)); | 60     CHECK(Rewriter::Rewrite(&info)); | 
| 57     CHECK(Scope::Analyze(&info)); | 61     CHECK(Scope::Analyze(&info)); | 
| 58     CHECK_NE(NULL, info.scope()); | 62     CHECK_NE(NULL, info.scope()); | 
| 59     Handle<ScopeInfo> scope_info = ScopeInfo::Create(info.scope(), info.zone()); | 63     Handle<ScopeInfo> scope_info = ScopeInfo::Create(info.scope(), info.zone()); | 
| 60     info.shared_info()->set_scope_info(*scope_info); | 64     info.shared_info()->set_scope_info(*scope_info); | 
| 61 | 65 | 
| 62     EnsureDeoptimizationSupport(&info); | 66     EnsureDeoptimizationSupport(&info); | 
| 63 | 67 | 
| 64     Pipeline pipeline(&info); | 68     Pipeline pipeline(&info); | 
| 65     Handle<Code> code = pipeline.GenerateCode(); | 69     Handle<Code> code = pipeline.GenerateCode(); | 
| (...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 200   Handle<Object> false_value() { return isolate->factory()->false_value(); } | 204   Handle<Object> false_value() { return isolate->factory()->false_value(); } | 
| 201 | 205 | 
| 202  private: | 206  private: | 
| 203   uint32_t flags_; | 207   uint32_t flags_; | 
| 204 }; | 208 }; | 
| 205 } | 209 } | 
| 206 } | 210 } | 
| 207 }  // namespace v8::internal::compiler | 211 }  // namespace v8::internal::compiler | 
| 208 | 212 | 
| 209 #endif  // V8_CCTEST_COMPILER_FUNCTION_TESTER_H_ | 213 #endif  // V8_CCTEST_COMPILER_FUNCTION_TESTER_H_ | 
| OLD | NEW | 
|---|