Commit 014eb820 authored by Alexander Timokhin's avatar Alexander Timokhin Committed by Commit Bot

Reland "Don't use |v8_initializers| code in |v8_base|"

This is a reland of 2e36e9ea

Was reverted because of v8_presubmit.py issue in
https://chromium-review.googlesource.com/c/v8/v8/+/1374292

Original change's description:
> Don't use |v8_initializers| code in |v8_base|
>
> Removing |CodeStubAssembler| from |v8_base| source list (see
> https://chromium-review.googlesource.com/c/v8/v8/+/1346329) leads to
> linkage problems with some build configurations because it was explicitly
> and implicitly included in |v8_base| code.
>
> This CL decouple this code and fixes problems.
>
> Bug: v8:7777
> Change-Id: I58de5c62914bc77645ed6cc9114409890bc13189
> Reviewed-on: https://chromium-review.googlesource.com/c/1372067
> Reviewed-by: Jakob Kummerow <jkummerow@chromium.org>
> Reviewed-by: Benedikt Meurer <bmeurer@chromium.org>
> Reviewed-by: Jakob Gruber <jgruber@chromium.org>
> Commit-Queue: Jakob Gruber <jgruber@chromium.org>
> Cr-Commit-Position: refs/heads/master@{#58200}

Bug: v8:7777
Change-Id: Iaa00e73c7dbd8c413fbf15a17709aa12eda9a706
Reviewed-on: https://chromium-review.googlesource.com/c/1375654Reviewed-by: 's avatarBenedikt Meurer <bmeurer@chromium.org>
Reviewed-by: 's avatarJakob Gruber <jgruber@chromium.org>
Commit-Queue: Jakob Gruber <jgruber@chromium.org>
Cr-Commit-Position: refs/heads/master@{#58209}
parent c4fdb272
......@@ -1707,6 +1707,7 @@ v8_source_set("v8_base") {
"src/builtins/builtins-number.cc",
"src/builtins/builtins-object.cc",
"src/builtins/builtins-promise.cc",
"src/builtins/builtins-promise.h",
"src/builtins/builtins-reflect.cc",
"src/builtins/builtins-regexp.cc",
"src/builtins/builtins-sharedarraybuffer.cc",
......
......@@ -5,7 +5,6 @@
#include "src/builtins/builtins-utils-inl.h"
#include "src/builtins/builtins.h"
#include "src/code-factory.h"
#include "src/code-stub-assembler.h"
#include "src/conversions.h"
#include "src/counters.h"
#include "src/date.h"
......
......@@ -5,7 +5,6 @@
#include "src/builtins/builtins-utils-inl.h"
#include "src/builtins/builtins.h"
#include "src/code-factory.h"
#include "src/code-stub-assembler.h"
#include "src/counters.h"
#include "src/keys.h"
#include "src/lookup.h"
......
This diff is collapsed.
......@@ -6,7 +6,6 @@
#define V8_BUILTINS_BUILTINS_PROMISE_GEN_H_
#include "src/code-stub-assembler.h"
#include "src/contexts.h"
#include "src/objects/promise.h"
#include "torque-generated/builtins-base-from-dsl-gen.h"
#include "torque-generated/builtins-iterator-from-dsl-gen.h"
......@@ -18,59 +17,6 @@ typedef compiler::CodeAssemblerState CodeAssemblerState;
class PromiseBuiltinsAssembler : public CodeStubAssembler {
public:
enum PromiseResolvingFunctionContextSlot {
// The promise which resolve/reject callbacks fulfill.
kPromiseSlot = Context::MIN_CONTEXT_SLOTS,
// Whether the callback was already invoked.
kAlreadyResolvedSlot,
// Whether to trigger a debug event or not. Used in catch
// prediction.
kDebugEventSlot,
kPromiseContextLength,
};
// TODO(bmeurer): Move this to a proper context map in contexts.h?
// Similar to the AwaitContext that we introduced for await closures.
enum PromiseAllResolveElementContextSlots {
// Remaining elements count
kPromiseAllResolveElementRemainingSlot = Context::MIN_CONTEXT_SLOTS,
// Promise capability from Promise.all
kPromiseAllResolveElementCapabilitySlot,
// Values array from Promise.all
kPromiseAllResolveElementValuesArraySlot,
kPromiseAllResolveElementLength
};
enum FunctionContextSlot {
kCapabilitySlot = Context::MIN_CONTEXT_SLOTS,
kCapabilitiesContextLength,
};
// This is used by the Promise.prototype.finally builtin to store
// onFinally callback and the Promise constructor.
// TODO(gsathya): For native promises we can create a variant of
// this without extra space for the constructor to save memory.
enum PromiseFinallyContextSlot {
kOnFinallySlot = Context::MIN_CONTEXT_SLOTS,
kConstructorSlot,
kPromiseFinallyContextLength,
};
// This is used by the ThenFinally and CatchFinally builtins to
// store the value to return or reason to throw.
enum PromiseValueThunkOrReasonContextSlot {
kValueSlot = Context::MIN_CONTEXT_SLOTS,
kPromiseValueThunkOrReasonContextLength,
};
explicit PromiseBuiltinsAssembler(compiler::CodeAssemblerState* state)
: CodeStubAssembler(state) {}
// These allocate and initialize a promise with pending state and
......
......@@ -2,6 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "src/builtins/builtins-promise.h"
#include "src/builtins/builtins-utils-inl.h"
#include "src/builtins/builtins.h"
#include "src/counters.h"
......
// Copyright 2018 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.
#ifndef V8_BUILTINS_BUILTINS_PROMISE_H_
#define V8_BUILTINS_BUILTINS_PROMISE_H_
#include "src/contexts.h"
namespace v8 {
namespace internal {
class PromiseBuiltins {
public:
enum PromiseResolvingFunctionContextSlot {
// The promise which resolve/reject callbacks fulfill.
kPromiseSlot = Context::MIN_CONTEXT_SLOTS,
// Whether the callback was already invoked.
kAlreadyResolvedSlot,
// Whether to trigger a debug event or not. Used in catch
// prediction.
kDebugEventSlot,
kPromiseContextLength,
};
// TODO(bmeurer): Move this to a proper context map in contexts.h?
// Similar to the AwaitContext that we introduced for await closures.
enum PromiseAllResolveElementContextSlots {
// Remaining elements count
kPromiseAllResolveElementRemainingSlot = Context::MIN_CONTEXT_SLOTS,
// Promise capability from Promise.all
kPromiseAllResolveElementCapabilitySlot,
// Values array from Promise.all
kPromiseAllResolveElementValuesArraySlot,
kPromiseAllResolveElementLength
};
enum FunctionContextSlot {
kCapabilitySlot = Context::MIN_CONTEXT_SLOTS,
kCapabilitiesContextLength,
};
// This is used by the Promise.prototype.finally builtin to store
// onFinally callback and the Promise constructor.
// TODO(gsathya): For native promises we can create a variant of
// this without extra space for the constructor to save memory.
enum PromiseFinallyContextSlot {
kOnFinallySlot = Context::MIN_CONTEXT_SLOTS,
kConstructorSlot,
kPromiseFinallyContextLength,
};
// This is used by the ThenFinally and CatchFinally builtins to
// store the value to return or reason to throw.
enum PromiseValueThunkOrReasonContextSlot {
kValueSlot = Context::MIN_CONTEXT_SLOTS,
kPromiseValueThunkOrReasonContextLength,
};
private:
DISALLOW_IMPLICIT_CONSTRUCTORS(PromiseBuiltins);
};
} // namespace internal
} // namespace v8
#endif // V8_BUILTINS_BUILTINS_PROMISE_H_
......@@ -5,7 +5,7 @@
#include "src/compiler/js-call-reducer.h"
#include "src/api-inl.h"
#include "src/builtins/builtins-promise-gen.h"
#include "src/builtins/builtins-promise.h"
#include "src/builtins/builtins-utils.h"
#include "src/code-factory.h"
#include "src/compiler/access-builder.h"
......@@ -5602,21 +5602,20 @@ Reduction JSCallReducer::ReducePromiseConstructor(Node* node) {
Node* promise_context = effect = graph()->NewNode(
javascript()->CreateFunctionContext(
handle(native_context().object()->scope_info(), isolate()),
PromiseBuiltinsAssembler::kPromiseContextLength -
Context::MIN_CONTEXT_SLOTS,
PromiseBuiltins::kPromiseContextLength - Context::MIN_CONTEXT_SLOTS,
FUNCTION_SCOPE),
context, effect, control);
effect =
graph()->NewNode(simplified()->StoreField(AccessBuilder::ForContextSlot(
PromiseBuiltinsAssembler::kPromiseSlot)),
promise_context, promise, effect, control);
effect = graph()->NewNode(
simplified()->StoreField(AccessBuilder::ForContextSlot(
PromiseBuiltinsAssembler::kAlreadyResolvedSlot)),
simplified()->StoreField(
AccessBuilder::ForContextSlot(PromiseBuiltins::kPromiseSlot)),
promise_context, promise, effect, control);
effect = graph()->NewNode(
simplified()->StoreField(
AccessBuilder::ForContextSlot(PromiseBuiltins::kAlreadyResolvedSlot)),
promise_context, jsgraph()->FalseConstant(), effect, control);
effect = graph()->NewNode(
simplified()->StoreField(AccessBuilder::ForContextSlot(
PromiseBuiltinsAssembler::kDebugEventSlot)),
simplified()->StoreField(
AccessBuilder::ForContextSlot(PromiseBuiltins::kDebugEventSlot)),
promise_context, jsgraph()->TrueConstant(), effect, control);
// Allocate the closure for the resolve case.
......@@ -5922,18 +5921,18 @@ Reduction JSCallReducer::ReducePromisePrototypeFinally(Node* node) {
context = etrue = graph()->NewNode(
javascript()->CreateFunctionContext(
handle(native_context().object()->scope_info(), isolate()),
PromiseBuiltinsAssembler::kPromiseFinallyContextLength -
PromiseBuiltins::kPromiseFinallyContextLength -
Context::MIN_CONTEXT_SLOTS,
FUNCTION_SCOPE),
context, etrue, if_true);
etrue =
graph()->NewNode(simplified()->StoreField(AccessBuilder::ForContextSlot(
PromiseBuiltinsAssembler::kOnFinallySlot)),
context, on_finally, etrue, if_true);
etrue =
graph()->NewNode(simplified()->StoreField(AccessBuilder::ForContextSlot(
PromiseBuiltinsAssembler::kConstructorSlot)),
context, constructor, etrue, if_true);
etrue = graph()->NewNode(
simplified()->StoreField(
AccessBuilder::ForContextSlot(PromiseBuiltins::kOnFinallySlot)),
context, on_finally, etrue, if_true);
etrue = graph()->NewNode(
simplified()->StoreField(
AccessBuilder::ForContextSlot(PromiseBuiltins::kConstructorSlot)),
context, constructor, etrue, if_true);
// Allocate the closure for the reject case.
SharedFunctionInfoRef catch_finally =
......
......@@ -22,7 +22,7 @@
#include "src/base/sys-info.h"
#include "src/base/utils/random-number-generator.h"
#include "src/bootstrapper.h"
#include "src/builtins/builtins-promise-gen.h"
#include "src/builtins/builtins-promise.h"
#include "src/builtins/constants-table-builder.h"
#include "src/cancelable-task.h"
#include "src/compilation-cache.h"
......@@ -763,7 +763,7 @@ void CaptureAsyncStackTrace(Isolate* isolate, Handle<JSPromise> promise,
// find the promise capability that's being resolved when all
// the concurrent promises resolve.
int const index =
PromiseBuiltinsAssembler::kPromiseAllResolveElementCapabilitySlot;
PromiseBuiltins::kPromiseAllResolveElementCapabilitySlot;
Handle<PromiseCapability> capability(
PromiseCapability::cast(context->get(index)), isolate);
if (!capability->promise()->IsJSPromise()) return;
......
......@@ -7,6 +7,7 @@
#include "src/api-inl.h"
#include "src/base/utils/random-number-generator.h"
#include "src/builtins/builtins-promise-gen.h"
#include "src/builtins/builtins-promise.h"
#include "src/builtins/builtins-string-gen.h"
#include "src/char-predicates.h"
#include "src/code-factory.h"
......@@ -2358,9 +2359,9 @@ TEST(CreatePromiseResolvingFunctionsContext) {
CHECK_EQ(isolate->native_context()->scope_info(), context_js->scope_info());
CHECK_EQ(ReadOnlyRoots(isolate).the_hole_value(), context_js->extension());
CHECK_EQ(*isolate->native_context(), context_js->native_context());
CHECK(context_js->get(PromiseBuiltinsAssembler::kPromiseSlot)->IsJSPromise());
CHECK(context_js->get(PromiseBuiltins::kPromiseSlot)->IsJSPromise());
CHECK_EQ(ReadOnlyRoots(isolate).false_value(),
context_js->get(PromiseBuiltinsAssembler::kDebugEventSlot));
context_js->get(PromiseBuiltins::kDebugEventSlot));
}
TEST(CreatePromiseResolvingFunctions) {
......@@ -2518,13 +2519,12 @@ TEST(CreatePromiseGetCapabilitiesExecutorContext) {
ft.Call(isolate->factory()->undefined_value()).ToHandleChecked();
CHECK(result_obj->IsContext());
Handle<Context> context_js = Handle<Context>::cast(result_obj);
CHECK_EQ(PromiseBuiltinsAssembler::kCapabilitiesContextLength,
context_js->length());
CHECK_EQ(PromiseBuiltins::kCapabilitiesContextLength, context_js->length());
CHECK_EQ(isolate->native_context()->scope_info(), context_js->scope_info());
CHECK_EQ(ReadOnlyRoots(isolate).the_hole_value(), context_js->extension());
CHECK_EQ(*isolate->native_context(), context_js->native_context());
CHECK(context_js->get(PromiseBuiltinsAssembler::kCapabilitySlot)
->IsPromiseCapability());
CHECK(
context_js->get(PromiseBuiltins::kCapabilitySlot)->IsPromiseCapability());
}
TEST(NewPromiseCapability) {
......@@ -2571,10 +2571,8 @@ TEST(NewPromiseCapability) {
CHECK_EQ(isolate->native_context()->scope_info(), context->scope_info());
CHECK_EQ(ReadOnlyRoots(isolate).the_hole_value(), context->extension());
CHECK_EQ(*isolate->native_context(), context->native_context());
CHECK_EQ(PromiseBuiltinsAssembler::kPromiseContextLength,
context->length());
CHECK_EQ(context->get(PromiseBuiltinsAssembler::kPromiseSlot),
result->promise());
CHECK_EQ(PromiseBuiltins::kPromiseContextLength, context->length());
CHECK_EQ(context->get(PromiseBuiltins::kPromiseSlot), result->promise());
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment