| 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 "test/cctest/compiler/function-tester.h" | 5 #include "test/cctest/compiler/function-tester.h" | 
| 6 | 6 | 
| 7 #include "src/ast/ast-numbering.h" | 7 #include "src/ast/ast-numbering.h" | 
| 8 #include "src/compilation-info.h" | 8 #include "src/compilation-info.h" | 
| 9 #include "src/compiler.h" | 9 #include "src/compiler.h" | 
| 10 #include "src/compiler/linkage.h" | 10 #include "src/compiler/linkage.h" | 
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 91   TryCatch try_catch(reinterpret_cast<v8::Isolate*>(isolate)); | 91   TryCatch try_catch(reinterpret_cast<v8::Isolate*>(isolate)); | 
| 92   MaybeHandle<Object> no_result = Call(a, b); | 92   MaybeHandle<Object> no_result = Call(a, b); | 
| 93   CHECK(isolate->has_pending_exception()); | 93   CHECK(isolate->has_pending_exception()); | 
| 94   CHECK(try_catch.HasCaught()); | 94   CHECK(try_catch.HasCaught()); | 
| 95   CHECK(no_result.is_null()); | 95   CHECK(no_result.is_null()); | 
| 96   isolate->OptionalRescheduleException(true); | 96   isolate->OptionalRescheduleException(true); | 
| 97   CHECK(!try_catch.Message().IsEmpty()); | 97   CHECK(!try_catch.Message().IsEmpty()); | 
| 98   return try_catch.Message(); | 98   return try_catch.Message(); | 
| 99 } | 99 } | 
| 100 | 100 | 
|  | 101 void FunctionTester::CheckCall(Handle<Object> expected, Handle<Object> a, | 
|  | 102                                Handle<Object> b, Handle<Object> c, | 
|  | 103                                Handle<Object> d) { | 
|  | 104   Handle<Object> result = Call(a, b, c, d).ToHandleChecked(); | 
|  | 105   CHECK(expected->SameValue(*result)); | 
|  | 106 } | 
|  | 107 | 
|  | 108 Handle<JSFunction> FunctionTester::NewFunction(const char* source) { | 
|  | 109   return Handle<JSFunction>::cast(v8::Utils::OpenHandle( | 
|  | 110       *v8::Local<v8::Function>::Cast(CompileRun(source)))); | 
|  | 111 } | 
|  | 112 | 
|  | 113 Handle<JSObject> FunctionTester::NewObject(const char* source) { | 
|  | 114   return Handle<JSObject>::cast( | 
|  | 115       v8::Utils::OpenHandle(*v8::Local<v8::Object>::Cast(CompileRun(source)))); | 
|  | 116 } | 
|  | 117 | 
| 101 Handle<String> FunctionTester::Val(const char* string) { | 118 Handle<String> FunctionTester::Val(const char* string) { | 
| 102   return isolate->factory()->InternalizeUtf8String(string); | 119   return isolate->factory()->InternalizeUtf8String(string); | 
| 103 } | 120 } | 
| 104 | 121 | 
| 105 Handle<Object> FunctionTester::Val(double value) { | 122 Handle<Object> FunctionTester::Val(double value) { | 
| 106   return isolate->factory()->NewNumber(value); | 123   return isolate->factory()->NewNumber(value); | 
| 107 } | 124 } | 
| 108 | 125 | 
| 109 Handle<Object> FunctionTester::infinity() { | 126 Handle<Object> FunctionTester::infinity() { | 
| 110   return isolate->factory()->infinity_value(); | 127   return isolate->factory()->infinity_value(); | 
| (...skipping 12 matching lines...) Expand all  Loading... | 
| 123 } | 140 } | 
| 124 | 141 | 
| 125 Handle<Object> FunctionTester::true_value() { | 142 Handle<Object> FunctionTester::true_value() { | 
| 126   return isolate->factory()->true_value(); | 143   return isolate->factory()->true_value(); | 
| 127 } | 144 } | 
| 128 | 145 | 
| 129 Handle<Object> FunctionTester::false_value() { | 146 Handle<Object> FunctionTester::false_value() { | 
| 130   return isolate->factory()->false_value(); | 147   return isolate->factory()->false_value(); | 
| 131 } | 148 } | 
| 132 | 149 | 
|  | 150 Handle<JSFunction> FunctionTester::ForMachineGraph(Graph* graph, | 
|  | 151                                                    int param_count) { | 
|  | 152   JSFunction* p = NULL; | 
|  | 153   {  // because of the implicit handle scope of FunctionTester. | 
|  | 154     FunctionTester f(graph, param_count); | 
|  | 155     p = *f.function; | 
|  | 156   } | 
|  | 157   return Handle<JSFunction>(p);  // allocated in outer handle scope. | 
|  | 158 } | 
|  | 159 | 
| 133 Handle<JSFunction> FunctionTester::Compile(Handle<JSFunction> function) { | 160 Handle<JSFunction> FunctionTester::Compile(Handle<JSFunction> function) { | 
| 134   Zone zone(function->GetIsolate()->allocator()); | 161   Zone zone(function->GetIsolate()->allocator()); | 
| 135   ParseInfo parse_info(&zone, function); | 162   ParseInfo parse_info(&zone, function); | 
| 136   CompilationInfo info(&parse_info, function); | 163   CompilationInfo info(&parse_info, function); | 
| 137   info.MarkAsDeoptimizationEnabled(); | 164   info.MarkAsDeoptimizationEnabled(); | 
| 138 | 165 | 
| 139   if (!FLAG_turbo_from_bytecode) { | 166   if (!FLAG_turbo_from_bytecode) { | 
| 140     CHECK(Parser::ParseStatic(info.parse_info())); | 167     CHECK(Parser::ParseStatic(info.parse_info())); | 
| 141   } | 168   } | 
| 142   info.SetOptimizing(); | 169   info.SetOptimizing(); | 
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 175 | 202 | 
| 176   Handle<Code> code = Pipeline::GenerateCodeForTesting(&info, graph); | 203   Handle<Code> code = Pipeline::GenerateCodeForTesting(&info, graph); | 
| 177   CHECK(!code.is_null()); | 204   CHECK(!code.is_null()); | 
| 178   function->ReplaceCode(*code); | 205   function->ReplaceCode(*code); | 
| 179   return function; | 206   return function; | 
| 180 } | 207 } | 
| 181 | 208 | 
| 182 }  // namespace compiler | 209 }  // namespace compiler | 
| 183 }  // namespace internal | 210 }  // namespace internal | 
| 184 }  // namespace v8 | 211 }  // namespace v8 | 
| OLD | NEW | 
|---|