LCOV - code coverage report
Current view: top level - test/cctest/interpreter - interpreter-tester.cc (source / functions) Hit Total Coverage
Test: app.info Lines: 25 30 83.3 %
Date: 2017-10-20 Functions: 10 13 76.9 %

          Line data    Source code
       1             : // Copyright 2015 the V8 project authors. All rights reserved.
       2             : // Use of this source code is governed by a BSD-style license that can be
       3             : // found in the LICENSE file.
       4             : 
       5             : #include "test/cctest/interpreter/interpreter-tester.h"
       6             : 
       7             : #include "src/objects-inl.h"
       8             : 
       9             : namespace v8 {
      10             : namespace internal {
      11             : namespace interpreter {
      12             : 
      13       24144 : MaybeHandle<Object> CallInterpreter(Isolate* isolate,
      14             :                                     Handle<JSFunction> function) {
      15             :   return Execution::Call(isolate, function,
      16       24216 :                          isolate->factory()->undefined_value(), 0, nullptr);
      17             : }
      18             : 
      19           0 : InterpreterTester::InterpreterTester(
      20             :     Isolate* isolate, const char* source, MaybeHandle<BytecodeArray> bytecode,
      21             :     MaybeHandle<FeedbackMetadata> feedback_metadata, const char* filter)
      22             :     : isolate_(isolate),
      23             :       source_(source),
      24             :       bytecode_(bytecode),
      25       25704 :       feedback_metadata_(feedback_metadata) {
      26       25704 :   i::FLAG_always_opt = false;
      27           0 : }
      28             : 
      29       22524 : InterpreterTester::InterpreterTester(
      30             :     Isolate* isolate, Handle<BytecodeArray> bytecode,
      31             :     MaybeHandle<FeedbackMetadata> feedback_metadata, const char* filter)
      32             :     : InterpreterTester(isolate, nullptr, bytecode, feedback_metadata, filter) {
      33       22524 : }
      34             : 
      35        3180 : InterpreterTester::InterpreterTester(Isolate* isolate, const char* source,
      36             :                                      const char* filter)
      37             :     : InterpreterTester(isolate, source, MaybeHandle<BytecodeArray>(),
      38        3180 :                         MaybeHandle<FeedbackMetadata>(), filter) {}
      39             : 
      40       25704 : InterpreterTester::~InterpreterTester() {}
      41             : 
      42          72 : Local<Message> InterpreterTester::CheckThrowsReturnMessage() {
      43          72 :   TryCatch try_catch(reinterpret_cast<v8::Isolate*>(isolate_));
      44             :   auto callable = GetCallable<>();
      45          72 :   MaybeHandle<Object> no_result = callable();
      46          72 :   CHECK(isolate_->has_pending_exception());
      47          72 :   CHECK(try_catch.HasCaught());
      48          72 :   CHECK(no_result.is_null());
      49          72 :   isolate_->OptionalRescheduleException(true);
      50         144 :   CHECK(!try_catch.Message().IsEmpty());
      51         144 :   return try_catch.Message();
      52             : }
      53             : 
      54         120 : Handle<Object> InterpreterTester::NewObject(const char* script) {
      55         120 :   return v8::Utils::OpenHandle(*CompileRun(script));
      56             : }
      57             : 
      58           0 : Handle<String> InterpreterTester::GetName(Isolate* isolate, const char* name) {
      59           0 :   Handle<String> result = isolate->factory()->NewStringFromAsciiChecked(name);
      60           0 :   return isolate->factory()->string_table()->LookupString(isolate, result);
      61             : }
      62             : 
      63        1776 : std::string InterpreterTester::SourceForBody(const char* body) {
      64       12432 :   return "function " + function_name() + "() {\n" + std::string(body) + "\n}";
      65             : }
      66             : 
      67         846 : std::string InterpreterTester::function_name() {
      68       24594 :   return std::string(kFunctionName);
      69             : }
      70             : 
      71             : const char InterpreterTester::kFunctionName[] = "f";
      72             : 
      73             : }  // namespace interpreter
      74             : }  // namespace internal
      75       71154 : }  // namespace v8

Generated by: LCOV version 1.10