fcaa2c2e57
This is a reland of 2f79e03560
Original change's description:
> [builtins] Remove Builtins::Name() accessors
>
> Instead of auto-generating the Name() convenience accessor, use a macro to
> avoid wasting code space.
>
> BUILTIN_CODE(isolate, Name)
>
> expands to
>
> isolate->builtins()->builtin_handle(Builtins::kName);
>
> This reduces the size of libv8.so by 134,752 bytes on a x64 release build.
>
> Bug: v8:6624
> Cq-Include-Trybots: master.tryserver.chromium.linux:linux_chromium_rel_ng
> Change-Id: Idff7ee5c45e344e73412c0f47e92553c7c7ff75f
> Reviewed-on: https://chromium-review.googlesource.com/593607
> Reviewed-by: Andreas Haas <ahaas@chromium.org>
> Reviewed-by: Benedikt Meurer <bmeurer@chromium.org>
> Commit-Queue: Jakob Gruber <jgruber@chromium.org>
> Cr-Commit-Position: refs/heads/master@{#47010}
TBR=bmeurer@chromium.org,ahaas@chromium.org
Bug: v8:6624
Change-Id: I4733731e56dc8873ee06c2b36cac1918c0a658b2
Reviewed-on: https://chromium-review.googlesource.com/594087
Commit-Queue: Jakob Gruber <jgruber@chromium.org>
Reviewed-by: Andreas Haas <ahaas@chromium.org>
Reviewed-by: Jakob Gruber <jgruber@chromium.org>
Cr-Commit-Position: refs/heads/master@{#47037}
61 lines
2.0 KiB
C++
61 lines
2.0 KiB
C++
// Copyright 2016 the V8 project authors. All rights reserved.
|
|
// Use of this source code is governed by a BSD-style license that can be
|
|
// found in the LICENSE file.
|
|
|
|
#include "test/unittests/test-helpers.h"
|
|
|
|
#include "include/v8.h"
|
|
#include "src/api.h"
|
|
#include "src/handles.h"
|
|
#include "src/isolate.h"
|
|
#include "src/objects-inl.h"
|
|
#include "src/objects.h"
|
|
|
|
namespace v8 {
|
|
namespace internal {
|
|
namespace test {
|
|
|
|
Handle<Object> RunJS(v8::Isolate* isolate, const char* script) {
|
|
return Utils::OpenHandle(
|
|
*v8::Script::Compile(
|
|
isolate->GetCurrentContext(),
|
|
v8::String::NewFromUtf8(isolate, script, v8::NewStringType::kNormal)
|
|
.ToLocalChecked())
|
|
.ToLocalChecked()
|
|
->Run(isolate->GetCurrentContext())
|
|
.ToLocalChecked());
|
|
}
|
|
|
|
Handle<String> CreateSource(Isolate* isolate,
|
|
ExternalOneByteString::Resource* maybe_resource) {
|
|
static const char test_script[] = "(x) { x*x; }";
|
|
if (maybe_resource) {
|
|
return isolate->factory()
|
|
->NewExternalStringFromOneByte(maybe_resource)
|
|
.ToHandleChecked();
|
|
}
|
|
return isolate->factory()->NewStringFromAsciiChecked(test_script);
|
|
}
|
|
|
|
Handle<SharedFunctionInfo> CreateSharedFunctionInfo(
|
|
Isolate* isolate,
|
|
v8::String::ExternalOneByteStringResource* maybe_resource) {
|
|
HandleScope scope(isolate);
|
|
Handle<String> source = CreateSource(isolate, maybe_resource);
|
|
Handle<Script> script = isolate->factory()->NewScript(source);
|
|
Handle<FixedArray> infos = isolate->factory()->NewFixedArray(3);
|
|
script->set_shared_function_infos(*infos);
|
|
Handle<SharedFunctionInfo> shared = isolate->factory()->NewSharedFunctionInfo(
|
|
isolate->factory()->NewStringFromAsciiChecked("f"),
|
|
BUILTIN_CODE(isolate, CompileLazy), false);
|
|
shared->set_end_position(source->length());
|
|
shared->set_outer_scope_info(ScopeInfo::Empty(isolate));
|
|
shared->set_function_literal_id(1);
|
|
SharedFunctionInfo::SetScript(shared, script);
|
|
return scope.CloseAndEscape(shared);
|
|
}
|
|
|
|
} // namespace test
|
|
} // namespace internal
|
|
} // namespace v8
|