LCOV - code coverage report
Current view: top level - src/objects - template-objects.cc (source / functions) Hit Total Coverage
Test: app.info Lines: 12 12 100.0 %
Date: 2019-02-19 Functions: 3 3 100.0 %

          Line data    Source code
       1             : // Copyright 2017 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 "src/objects/template-objects.h"
       6             : 
       7             : #include "src/heap/factory.h"
       8             : #include "src/isolate.h"
       9             : #include "src/objects-inl.h"
      10             : #include "src/property-descriptor.h"
      11             : 
      12             : namespace v8 {
      13             : namespace internal {
      14             : 
      15             : // static
      16        2757 : Handle<JSArray> TemplateObjectDescription::CreateTemplateObject(
      17             :     Isolate* isolate, Handle<TemplateObjectDescription> description) {
      18             :   // Create the raw object from the {raw_strings}.
      19        5514 :   Handle<FixedArray> raw_strings(description->raw_strings(), isolate);
      20             :   Handle<JSArray> raw_object = isolate->factory()->NewJSArrayWithElements(
      21        2757 :       raw_strings, PACKED_ELEMENTS, raw_strings->length(), TENURED);
      22             : 
      23             :   // Create the template object from the {cooked_strings}.
      24        5514 :   Handle<FixedArray> cooked_strings(description->cooked_strings(), isolate);
      25             :   Handle<JSArray> template_object = isolate->factory()->NewJSArrayWithElements(
      26        2757 :       cooked_strings, PACKED_ELEMENTS, cooked_strings->length(), TENURED);
      27             : 
      28             :   // Freeze the {raw_object}.
      29        5514 :   JSObject::SetIntegrityLevel(raw_object, FROZEN, kThrowOnError).ToChecked();
      30             : 
      31             :   // Install a "raw" data property for {raw_object} on {template_object}.
      32             :   PropertyDescriptor raw_desc;
      33             :   raw_desc.set_value(raw_object);
      34             :   raw_desc.set_configurable(false);
      35             :   raw_desc.set_enumerable(false);
      36             :   raw_desc.set_writable(false);
      37             :   JSArray::DefineOwnProperty(isolate, template_object,
      38             :                              isolate->factory()->raw_string(), &raw_desc,
      39        2757 :                              Just(kThrowOnError))
      40        5514 :       .ToChecked();
      41             : 
      42             :   // Freeze the {template_object} as well.
      43        2757 :   JSObject::SetIntegrityLevel(template_object, FROZEN, kThrowOnError)
      44        5514 :       .ToChecked();
      45             : 
      46        2757 :   return template_object;
      47             : }
      48             : 
      49             : }  // namespace internal
      50      178779 : }  // namespace v8

Generated by: LCOV version 1.10