Turn libplatform into a component
BUG=v8:5412 R=jgruber@chromium.org,machenbach@chromium.org CQ_INCLUDE_TRYBOTS=master.tryserver.chromium.linux:linux_chromium_compile_dbg_ng;master.tryserver.chromium.android:android_clang_dbg_recipe Review-Url: https://codereview.chromium.org/2372983003 Cr-Commit-Position: refs/heads/master@{#40111}
This commit is contained in:
parent
b374d719e7
commit
c59cf8cd21
11
BUILD.gn
11
BUILD.gn
@ -128,6 +128,9 @@ config("internal_config_base") {
|
||||
# This config should be applied to code using the libplatform.
|
||||
config("libplatform_config") {
|
||||
include_dirs = [ "include" ]
|
||||
if (is_component_build) {
|
||||
defines = [ "USING_V8_PLATFORM_SHARED" ]
|
||||
}
|
||||
}
|
||||
|
||||
# This config should be applied to code using the libbase.
|
||||
@ -2300,9 +2303,10 @@ v8_component("v8_libbase") {
|
||||
# TODO(jochen): Add support for qnx, freebsd, openbsd, netbsd, and solaris.
|
||||
}
|
||||
|
||||
v8_source_set("v8_libplatform") {
|
||||
v8_component("v8_libplatform") {
|
||||
sources = [
|
||||
"//base/trace_event/common/trace_event_common.h",
|
||||
"include/libplatform/libplatform-export.h",
|
||||
"include/libplatform/libplatform.h",
|
||||
"include/libplatform/v8-tracing.h",
|
||||
"src/libplatform/default-platform.cc",
|
||||
@ -2322,6 +2326,10 @@ v8_source_set("v8_libplatform") {
|
||||
|
||||
configs = [ ":internal_config_base" ]
|
||||
|
||||
if (is_component_build) {
|
||||
defines = [ "BUILDING_V8_PLATFORM_SHARED" ]
|
||||
}
|
||||
|
||||
public_configs = [ ":libplatform_config" ]
|
||||
|
||||
deps = [
|
||||
@ -2359,6 +2367,7 @@ v8_source_set("fuzzer_support") {
|
||||
]
|
||||
|
||||
public_deps = [
|
||||
":v8_libbase",
|
||||
":v8_libplatform",
|
||||
]
|
||||
}
|
||||
|
@ -1,3 +1,7 @@
|
||||
include_rules = [
|
||||
"+libplatform/libplatform-export.h",
|
||||
]
|
||||
|
||||
specific_include_rules = {
|
||||
"libplatform\.h": [
|
||||
"+libplatform/v8-tracing.h",
|
||||
|
29
include/libplatform/libplatform-export.h
Normal file
29
include/libplatform/libplatform-export.h
Normal file
@ -0,0 +1,29 @@
|
||||
// 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.
|
||||
|
||||
#ifndef V8_LIBPLATFORM_LIBPLATFORM_EXPORT_H_
|
||||
#define V8_LIBPLATFORM_LIBPLATFORM_EXPORT_H_
|
||||
|
||||
#if defined(_WIN32)
|
||||
|
||||
#ifdef BUILDING_V8_PLATFORM_SHARED
|
||||
#define V8_PLATFORM_EXPORT __declspec(dllexport)
|
||||
#elif USING_V8_PLATFORM_SHARED
|
||||
#define V8_PLATFORM_EXPORT __declspec(dllimport)
|
||||
#else
|
||||
#define V8_PLATFORM_EXPORT
|
||||
#endif // BUILDING_V8_PLATFORM_SHARED
|
||||
|
||||
#else // defined(_WIN32)
|
||||
|
||||
// Setup for Linux shared library export.
|
||||
#ifdef BUILDING_V8_PLATFORM_SHARED
|
||||
#define V8_PLATFORM_EXPORT __attribute__((visibility("default")))
|
||||
#else
|
||||
#define V8_PLATFORM_EXPORT
|
||||
#endif
|
||||
|
||||
#endif // defined(_WIN32)
|
||||
|
||||
#endif // V8_LIBPLATFORM_LIBPLATFORM_EXPORT_H_
|
@ -5,6 +5,7 @@
|
||||
#ifndef V8_LIBPLATFORM_LIBPLATFORM_H_
|
||||
#define V8_LIBPLATFORM_LIBPLATFORM_H_
|
||||
|
||||
#include "libplatform/libplatform-export.h"
|
||||
#include "libplatform/v8-tracing.h"
|
||||
#include "v8-platform.h" // NOLINT(build/include)
|
||||
|
||||
@ -19,8 +20,8 @@ namespace platform {
|
||||
* of zero is passed, a suitable default based on the current number of
|
||||
* processors online will be chosen.
|
||||
*/
|
||||
v8::Platform* CreateDefaultPlatform(int thread_pool_size = 0);
|
||||
|
||||
V8_PLATFORM_EXPORT v8::Platform* CreateDefaultPlatform(
|
||||
int thread_pool_size = 0);
|
||||
|
||||
/**
|
||||
* Pumps the message loop for the given isolate.
|
||||
@ -30,14 +31,15 @@ v8::Platform* CreateDefaultPlatform(int thread_pool_size = 0);
|
||||
* not block if no task is pending. The |platform| has to be created using
|
||||
* |CreateDefaultPlatform|.
|
||||
*/
|
||||
bool PumpMessageLoop(v8::Platform* platform, v8::Isolate* isolate);
|
||||
V8_PLATFORM_EXPORT bool PumpMessageLoop(v8::Platform* platform,
|
||||
v8::Isolate* isolate);
|
||||
|
||||
/**
|
||||
* Attempts to set the tracing controller for the given platform.
|
||||
*
|
||||
* The |platform| has to be created using |CreateDefaultPlatform|.
|
||||
*/
|
||||
void SetTracingController(
|
||||
V8_PLATFORM_EXPORT void SetTracingController(
|
||||
v8::Platform* platform,
|
||||
v8::platform::tracing::TracingController* tracing_controller);
|
||||
|
||||
|
@ -10,6 +10,7 @@
|
||||
#include <unordered_set>
|
||||
#include <vector>
|
||||
|
||||
#include "libplatform/libplatform-export.h"
|
||||
#include "v8-platform.h" // NOLINT(build/include)
|
||||
|
||||
namespace v8 {
|
||||
@ -23,7 +24,7 @@ namespace tracing {
|
||||
|
||||
const int kTraceMaxNumArgs = 2;
|
||||
|
||||
class TraceObject {
|
||||
class V8_PLATFORM_EXPORT TraceObject {
|
||||
public:
|
||||
union ArgValue {
|
||||
bool as_bool;
|
||||
@ -103,7 +104,7 @@ class TraceObject {
|
||||
void operator=(const TraceObject&) = delete;
|
||||
};
|
||||
|
||||
class TraceWriter {
|
||||
class V8_PLATFORM_EXPORT TraceWriter {
|
||||
public:
|
||||
TraceWriter() {}
|
||||
virtual ~TraceWriter() {}
|
||||
@ -118,7 +119,7 @@ class TraceWriter {
|
||||
void operator=(const TraceWriter&) = delete;
|
||||
};
|
||||
|
||||
class TraceBufferChunk {
|
||||
class V8_PLATFORM_EXPORT TraceBufferChunk {
|
||||
public:
|
||||
explicit TraceBufferChunk(uint32_t seq);
|
||||
|
||||
@ -142,7 +143,7 @@ class TraceBufferChunk {
|
||||
void operator=(const TraceBufferChunk&) = delete;
|
||||
};
|
||||
|
||||
class TraceBuffer {
|
||||
class V8_PLATFORM_EXPORT TraceBuffer {
|
||||
public:
|
||||
TraceBuffer() {}
|
||||
virtual ~TraceBuffer() {}
|
||||
@ -178,7 +179,7 @@ enum TraceRecordMode {
|
||||
ECHO_TO_CONSOLE,
|
||||
};
|
||||
|
||||
class TraceConfig {
|
||||
class V8_PLATFORM_EXPORT TraceConfig {
|
||||
public:
|
||||
typedef std::vector<std::string> StringList;
|
||||
|
||||
@ -216,7 +217,7 @@ class TraceConfig {
|
||||
void operator=(const TraceConfig&) = delete;
|
||||
};
|
||||
|
||||
class TracingController {
|
||||
class V8_PLATFORM_EXPORT TracingController {
|
||||
public:
|
||||
enum Mode { DISABLED = 0, RECORDING_MODE };
|
||||
|
||||
|
@ -60,4 +60,46 @@
|
||||
#define STATIC_CONST_MEMBER_DEFINITION
|
||||
#endif
|
||||
|
||||
#if V8_CC_MSVC
|
||||
|
||||
#include <sal.h>
|
||||
|
||||
// Macros for suppressing and disabling warnings on MSVC.
|
||||
//
|
||||
// Warning numbers are enumerated at:
|
||||
// http://msdn.microsoft.com/en-us/library/8x5x43k7(VS.80).aspx
|
||||
//
|
||||
// The warning pragma:
|
||||
// http://msdn.microsoft.com/en-us/library/2c8f766e(VS.80).aspx
|
||||
//
|
||||
// Using __pragma instead of #pragma inside macros:
|
||||
// http://msdn.microsoft.com/en-us/library/d9x1s805.aspx
|
||||
|
||||
// MSVC_SUPPRESS_WARNING disables warning |n| for the remainder of the line and
|
||||
// for the next line of the source file.
|
||||
#define MSVC_SUPPRESS_WARNING(n) __pragma(warning(suppress : n))
|
||||
|
||||
// Allows exporting a class that inherits from a non-exported base class.
|
||||
// This uses suppress instead of push/pop because the delimiter after the
|
||||
// declaration (either "," or "{") has to be placed before the pop macro.
|
||||
//
|
||||
// Example usage:
|
||||
// class EXPORT_API Foo : NON_EXPORTED_BASE(public Bar) {
|
||||
//
|
||||
// MSVC Compiler warning C4275:
|
||||
// non dll-interface class 'Bar' used as base for dll-interface class 'Foo'.
|
||||
// Note that this is intended to be used only when no access to the base class'
|
||||
// static data is done through derived classes or inline methods. For more info,
|
||||
// see http://msdn.microsoft.com/en-us/library/3tdb471s(VS.80).aspx
|
||||
#define NON_EXPORTED_BASE(code) \
|
||||
MSVC_SUPPRESS_WARNING(4275) \
|
||||
code
|
||||
|
||||
#else // Not MSVC
|
||||
|
||||
#define MSVC_SUPPRESS_WARNING(n)
|
||||
#define NON_EXPORTED_BASE(code) code
|
||||
|
||||
#endif // V8_CC_MSVC
|
||||
|
||||
#endif // V8_BASE_COMPILER_SPECIFIC_H_
|
||||
|
@ -7,6 +7,7 @@
|
||||
#include <algorithm>
|
||||
#include <queue>
|
||||
|
||||
#include "include/libplatform/libplatform.h"
|
||||
#include "src/base/logging.h"
|
||||
#include "src/base/platform/platform.h"
|
||||
#include "src/base/platform/time.h"
|
||||
|
@ -11,8 +11,10 @@
|
||||
#include <queue>
|
||||
#include <vector>
|
||||
|
||||
#include "include/libplatform/libplatform-export.h"
|
||||
#include "include/libplatform/v8-tracing.h"
|
||||
#include "include/v8-platform.h"
|
||||
#include "src/base/compiler-specific.h"
|
||||
#include "src/base/macros.h"
|
||||
#include "src/base/platform/mutex.h"
|
||||
#include "src/libplatform/task-queue.h"
|
||||
@ -28,7 +30,7 @@ namespace tracing {
|
||||
class TracingController;
|
||||
}
|
||||
|
||||
class DefaultPlatform : public Platform {
|
||||
class V8_PLATFORM_EXPORT DefaultPlatform : public NON_EXPORTED_BASE(Platform) {
|
||||
public:
|
||||
DefaultPlatform();
|
||||
virtual ~DefaultPlatform();
|
||||
|
@ -7,6 +7,7 @@
|
||||
|
||||
#include <queue>
|
||||
|
||||
#include "include/libplatform/libplatform-export.h"
|
||||
#include "src/base/macros.h"
|
||||
#include "src/base/platform/mutex.h"
|
||||
#include "src/base/platform/semaphore.h"
|
||||
@ -18,7 +19,7 @@ class Task;
|
||||
|
||||
namespace platform {
|
||||
|
||||
class TaskQueue {
|
||||
class V8_PLATFORM_EXPORT TaskQueue {
|
||||
public:
|
||||
TaskQueue();
|
||||
~TaskQueue();
|
||||
|
@ -7,6 +7,8 @@
|
||||
|
||||
#include <queue>
|
||||
|
||||
#include "include/libplatform/libplatform-export.h"
|
||||
#include "src/base/compiler-specific.h"
|
||||
#include "src/base/macros.h"
|
||||
#include "src/base/platform/platform.h"
|
||||
|
||||
@ -16,7 +18,7 @@ namespace platform {
|
||||
|
||||
class TaskQueue;
|
||||
|
||||
class WorkerThread : public base::Thread {
|
||||
class V8_PLATFORM_EXPORT WorkerThread : public NON_EXPORTED_BASE(base::Thread) {
|
||||
public:
|
||||
explicit WorkerThread(TaskQueue* queue);
|
||||
virtual ~WorkerThread();
|
||||
|
@ -2061,7 +2061,7 @@
|
||||
},
|
||||
{
|
||||
'target_name': 'v8_libplatform',
|
||||
'type': 'static_library',
|
||||
'type': '<(component)',
|
||||
'variables': {
|
||||
'optimize': 'max',
|
||||
},
|
||||
@ -2075,6 +2075,7 @@
|
||||
],
|
||||
'sources': [
|
||||
'../include/libplatform/libplatform.h',
|
||||
'../include/libplatform/libplatform-export.h',
|
||||
'../include/libplatform/v8-tracing.h',
|
||||
'libplatform/default-platform.cc',
|
||||
'libplatform/default-platform.h',
|
||||
@ -2096,6 +2097,12 @@
|
||||
}, {
|
||||
'toolsets': ['target'],
|
||||
}],
|
||||
['component=="shared_library"', {
|
||||
'direct_dependent_settings': {
|
||||
'defines': [ 'USING_V8_PLATFORM_SHARED' ],
|
||||
},
|
||||
'defines': [ 'BUILDING_V8_PLATFORM_SHARED' ],
|
||||
}]
|
||||
],
|
||||
'direct_dependent_settings': {
|
||||
'include_dirs': [
|
||||
|
Loading…
Reference in New Issue
Block a user