Commit 9d48eda3 authored by Tobias Tebbi's avatar Tobias Tebbi Committed by Commit Bot

[torque] explicit definitions for contextual variables

Shared library sharing of template-defined global variables is broken on
Windows. This prepares contextual variables to export their globals from
a DLL.

Change-Id: I3092a92db71c4e516218081b97335d451d90bfe2
Reviewed-on: https://chromium-review.googlesource.com/1148049Reviewed-by: 's avatarSigurd Schneider <sigurds@chromium.org>
Commit-Queue: Tobias Tebbi <tebbi@chromium.org>
Cr-Commit-Position: refs/heads/master@{#54628}
parent 76c132de
......@@ -3182,10 +3182,12 @@ if (current_toolchain == v8_snapshot_toolchain) {
"src/torque/implementation-visitor.h",
"src/torque/scope.cc",
"src/torque/scope.h",
"src/torque/source-positions.cc",
"src/torque/source-positions.h",
"src/torque/torque-parser.cc",
"src/torque/torque-parser.h",
"src/torque/torque.cc",
"src/torque/type-oracle.cc",
"src/torque/type-oracle.h",
"src/torque/types.cc",
"src/torque/types.h",
......
......@@ -27,6 +27,8 @@ namespace torque {
template <class Derived, class VarType>
class ContextualVariable {
public:
using VariableType = VarType;
// A {Scope} contains a new object of type {VarType} and gives
// ContextualVariable::Get() access to it. Upon destruction, the contextual
// variable is restored to the state before the {Scope} was created. Scopes
......@@ -67,14 +69,16 @@ class ContextualVariable {
static thread_local VarType* top_;
};
template <class Derived, class VarType>
thread_local VarType* ContextualVariable<Derived, VarType>::top_ = nullptr;
// Usage: DECLARE_CONTEXTUAL_VARIABLE(VarName, VarType)
#define DECLARE_CONTEXTUAL_VARIABLE(VarName, ...) \
struct VarName \
: v8::internal::torque::ContextualVariable<VarName, __VA_ARGS__> {};
#define DEFINE_CONTEXTUAL_VARIABLE(VarName) \
template <> \
thread_local VarName::VariableType* \
ContextualVariable<VarName, VarName::VariableType>::top_ = nullptr;
// By inheriting from {ContextualClass} a class can become a contextual variable
// of itself, which is very similar to a singleton.
template <class T>
......
// 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.
#include "src/torque/source-positions.h"
namespace v8 {
namespace internal {
namespace torque {
DEFINE_CONTEXTUAL_VARIABLE(CurrentSourceFile)
DEFINE_CONTEXTUAL_VARIABLE(CurrentSourcePosition)
DEFINE_CONTEXTUAL_VARIABLE(SourceFileMap)
} // namespace torque
} // namespace internal
} // namespace v8
......@@ -12,6 +12,8 @@ namespace v8 {
namespace internal {
namespace torque {
DEFINE_CONTEXTUAL_VARIABLE(CurrentAst);
using TypeList = std::vector<TypeExpression*>;
using GenericParameters = std::vector<std::string>;
......
// 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.
#include "src/torque/type-oracle.h"
namespace v8 {
namespace internal {
namespace torque {
DEFINE_CONTEXTUAL_VARIABLE(TypeOracle)
} // namespace torque
} // namespace internal
} // namespace v8
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