libv8 7.3.492.27.1-universal-darwin19

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 85c968b347a85f75319ee23f44550865bb3df73f1f5097c00de925da925255c8
4
+ data.tar.gz: 6610df94a3c56734df4f995a49bc86e2f3be3489c851435415f3c246aa5cc8d2
5
+ SHA512:
6
+ metadata.gz: a5aac86a594eb651f45f03759420b22f493b70df669157a2c1d9c7f89fccb80bc0b49a26569d64ead253bf5e85807b2bca5ab7798dc547a9efe554b9715048db
7
+ data.tar.gz: 8442a408099f1294b02d5d3891bd720cb5e812c5c59f64a4bc779da10e4f963025fab81cc8a9c4c5e1285e662784b9335c1e58fdc40eb14c61bb055d87043174
@@ -0,0 +1 @@
1
+ --- !ruby/object:Libv8::Location::Vendor {}
@@ -0,0 +1,89 @@
1
+ require 'yaml'
2
+ require 'pathname'
3
+ require File.expand_path '../paths', __FILE__
4
+
5
+ module Libv8
6
+ class Location
7
+ def install!
8
+ File.open(Pathname(__FILE__).dirname.join('.location.yml'), "w") do |f|
9
+ f.write self.to_yaml
10
+ end
11
+ return 0
12
+ end
13
+
14
+ def self.load!
15
+ File.open(Pathname(__FILE__).dirname.join('.location.yml')) do |f|
16
+ YAML.load f
17
+ end
18
+ end
19
+
20
+ class Vendor < Location
21
+ def install!
22
+ require File.expand_path '../builder', __FILE__
23
+ builder = Libv8::Builder.new
24
+ exit_status = builder.build_libv8!
25
+ super if exit_status == 0
26
+ verify_installation!
27
+ return exit_status
28
+ end
29
+
30
+ def configure(context = MkmfContext.new)
31
+ context.incflags.insert 0, Libv8::Paths.include_paths.map{ |p| "-I#{p}" }.join(" ") + " "
32
+ context.ldflags.insert 0, Libv8::Paths.object_paths.join(" ") + " "
33
+ end
34
+
35
+ def verify_installation!
36
+ include_paths = Libv8::Paths.include_paths
37
+ unless include_paths.detect { |p| Pathname(p).join('v8.h').exist? }
38
+ fail HeaderNotFound, "Unable to locate 'v8.h' in the libv8 header paths: #{include_paths.inspect}"
39
+ end
40
+ Libv8::Paths.object_paths.each do |p|
41
+ fail ArchiveNotFound, p unless File.exist? p
42
+ end
43
+ end
44
+
45
+ class HeaderNotFound < StandardError; end
46
+
47
+ class ArchiveNotFound < StandardError
48
+ def initialize(filename)
49
+ super "libv8 did not install properly, expected binary v8 archive '#{filename}'to exist, but it was not found"
50
+ end
51
+ end
52
+ end
53
+
54
+ class System < Location
55
+ def configure(context = MkmfContext.new)
56
+ context.send(:dir_config, 'v8')
57
+ context.send(:find_header, 'v8.h') or fail NotFoundError
58
+ context.send(:find_header, 'libplatform/libplatform.h') or fail NotFoundError
59
+ context.send(:have_library, 'v8') or fail NotFoundError
60
+ end
61
+
62
+ class NotFoundError < StandardError
63
+ def initialize(*args)
64
+ super(<<-EOS)
65
+ By using --with-system-v8, you have chosen to use the version
66
+ of V8 found on your system and *not* the one that is bundled with
67
+ the libv8 rubygem.
68
+
69
+ However, your system version of v8 could not be located.
70
+
71
+ Please make sure your system version of v8 that is compatible
72
+ with #{Libv8::VERSION} installed. You may need to use the
73
+ --with-v8-dir option if it is installed in a non-standard location
74
+ EOS
75
+ end
76
+ end
77
+ end
78
+
79
+ class MkmfContext
80
+ def incflags
81
+ $INCFLAGS
82
+ end
83
+
84
+ def ldflags
85
+ $LDFLAGS
86
+ end
87
+ end
88
+ end
89
+ end
@@ -0,0 +1,28 @@
1
+ require 'rbconfig'
2
+ require 'shellwords'
3
+
4
+ module Libv8
5
+ module Paths
6
+ module_function
7
+
8
+ def include_paths
9
+ [Shellwords.escape(File.join(vendored_source_path, 'include'))]
10
+ end
11
+
12
+ def object_paths
13
+ [Shellwords.escape(File.join(vendored_source_path,
14
+ 'out.gn',
15
+ 'libv8',
16
+ 'obj',
17
+ "libv8_monolith.#{config['LIBEXT']}"))]
18
+ end
19
+
20
+ def config
21
+ RbConfig::MAKEFILE_CONFIG
22
+ end
23
+
24
+ def vendored_source_path
25
+ File.expand_path "../../../vendor/v8", __FILE__
26
+ end
27
+ end
28
+ end
data/lib/libv8.rb ADDED
@@ -0,0 +1,9 @@
1
+ require 'libv8/version'
2
+ require 'libv8/location'
3
+
4
+ module Libv8
5
+ def self.configure_makefile
6
+ location = Location.load!
7
+ location.configure
8
+ end
9
+ end
@@ -0,0 +1,3 @@
1
+ module Libv8
2
+ VERSION = "7.3.492.27.1"
3
+ end
@@ -0,0 +1,29 @@
1
+ // Copyright 2016 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
+ #ifndef V8_LIBPLATFORM_LIBPLATFORM_EXPORT_H_
6
+ #define V8_LIBPLATFORM_LIBPLATFORM_EXPORT_H_
7
+
8
+ #if defined(_WIN32)
9
+
10
+ #ifdef BUILDING_V8_PLATFORM_SHARED
11
+ #define V8_PLATFORM_EXPORT __declspec(dllexport)
12
+ #elif USING_V8_PLATFORM_SHARED
13
+ #define V8_PLATFORM_EXPORT __declspec(dllimport)
14
+ #else
15
+ #define V8_PLATFORM_EXPORT
16
+ #endif // BUILDING_V8_PLATFORM_SHARED
17
+
18
+ #else // defined(_WIN32)
19
+
20
+ // Setup for Linux shared library export.
21
+ #ifdef BUILDING_V8_PLATFORM_SHARED
22
+ #define V8_PLATFORM_EXPORT __attribute__((visibility("default")))
23
+ #else
24
+ #define V8_PLATFORM_EXPORT
25
+ #endif
26
+
27
+ #endif // defined(_WIN32)
28
+
29
+ #endif // V8_LIBPLATFORM_LIBPLATFORM_EXPORT_H_
@@ -0,0 +1,91 @@
1
+ // Copyright 2014 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
+ #ifndef V8_LIBPLATFORM_LIBPLATFORM_H_
6
+ #define V8_LIBPLATFORM_LIBPLATFORM_H_
7
+
8
+ #include "libplatform/libplatform-export.h"
9
+ #include "libplatform/v8-tracing.h"
10
+ #include "v8-platform.h" // NOLINT(build/include)
11
+ #include "v8config.h" // NOLINT(build/include)
12
+
13
+ namespace v8 {
14
+ namespace platform {
15
+
16
+ enum class IdleTaskSupport { kDisabled, kEnabled };
17
+ enum class InProcessStackDumping { kDisabled, kEnabled };
18
+
19
+ enum class MessageLoopBehavior : bool {
20
+ kDoNotWait = false,
21
+ kWaitForWork = true
22
+ };
23
+
24
+ /**
25
+ * Returns a new instance of the default v8::Platform implementation.
26
+ *
27
+ * The caller will take ownership of the returned pointer. |thread_pool_size|
28
+ * is the number of worker threads to allocate for background jobs. If a value
29
+ * of zero is passed, a suitable default based on the current number of
30
+ * processors online will be chosen.
31
+ * If |idle_task_support| is enabled then the platform will accept idle
32
+ * tasks (IdleTasksEnabled will return true) and will rely on the embedder
33
+ * calling v8::platform::RunIdleTasks to process the idle tasks.
34
+ * If |tracing_controller| is nullptr, the default platform will create a
35
+ * v8::platform::TracingController instance and use it.
36
+ */
37
+ V8_PLATFORM_EXPORT std::unique_ptr<v8::Platform> NewDefaultPlatform(
38
+ int thread_pool_size = 0,
39
+ IdleTaskSupport idle_task_support = IdleTaskSupport::kDisabled,
40
+ InProcessStackDumping in_process_stack_dumping =
41
+ InProcessStackDumping::kDisabled,
42
+ std::unique_ptr<v8::TracingController> tracing_controller = {});
43
+
44
+ V8_PLATFORM_EXPORT V8_DEPRECATED(
45
+ "Use NewDefaultPlatform instead",
46
+ v8::Platform* CreateDefaultPlatform(
47
+ int thread_pool_size = 0,
48
+ IdleTaskSupport idle_task_support = IdleTaskSupport::kDisabled,
49
+ InProcessStackDumping in_process_stack_dumping =
50
+ InProcessStackDumping::kDisabled,
51
+ v8::TracingController* tracing_controller = nullptr));
52
+
53
+ /**
54
+ * Pumps the message loop for the given isolate.
55
+ *
56
+ * The caller has to make sure that this is called from the right thread.
57
+ * Returns true if a task was executed, and false otherwise. Unless requested
58
+ * through the |behavior| parameter, this call does not block if no task is
59
+ * pending. The |platform| has to be created using |NewDefaultPlatform|.
60
+ */
61
+ V8_PLATFORM_EXPORT bool PumpMessageLoop(
62
+ v8::Platform* platform, v8::Isolate* isolate,
63
+ MessageLoopBehavior behavior = MessageLoopBehavior::kDoNotWait);
64
+
65
+ /**
66
+ * Runs pending idle tasks for at most |idle_time_in_seconds| seconds.
67
+ *
68
+ * The caller has to make sure that this is called from the right thread.
69
+ * This call does not block if no task is pending. The |platform| has to be
70
+ * created using |NewDefaultPlatform|.
71
+ */
72
+ V8_PLATFORM_EXPORT void RunIdleTasks(v8::Platform* platform,
73
+ v8::Isolate* isolate,
74
+ double idle_time_in_seconds);
75
+
76
+ /**
77
+ * Attempts to set the tracing controller for the given platform.
78
+ *
79
+ * The |platform| has to be created using |NewDefaultPlatform|.
80
+ *
81
+ */
82
+ V8_PLATFORM_EXPORT V8_DEPRECATE_SOON(
83
+ "Access the DefaultPlatform directly",
84
+ void SetTracingController(
85
+ v8::Platform* platform,
86
+ v8::platform::tracing::TracingController* tracing_controller));
87
+
88
+ } // namespace platform
89
+ } // namespace v8
90
+
91
+ #endif // V8_LIBPLATFORM_LIBPLATFORM_H_
@@ -0,0 +1,297 @@
1
+ // Copyright 2016 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
+ #ifndef V8_LIBPLATFORM_V8_TRACING_H_
6
+ #define V8_LIBPLATFORM_V8_TRACING_H_
7
+
8
+ #include <fstream>
9
+ #include <memory>
10
+ #include <unordered_set>
11
+ #include <vector>
12
+
13
+ #include "libplatform/libplatform-export.h"
14
+ #include "v8-platform.h" // NOLINT(build/include)
15
+
16
+ namespace v8 {
17
+
18
+ namespace base {
19
+ class Mutex;
20
+ } // namespace base
21
+
22
+ namespace platform {
23
+ namespace tracing {
24
+
25
+ const int kTraceMaxNumArgs = 2;
26
+
27
+ class V8_PLATFORM_EXPORT TraceObject {
28
+ public:
29
+ union ArgValue {
30
+ bool as_bool;
31
+ uint64_t as_uint;
32
+ int64_t as_int;
33
+ double as_double;
34
+ const void* as_pointer;
35
+ const char* as_string;
36
+ };
37
+
38
+ TraceObject() = default;
39
+ ~TraceObject();
40
+ void Initialize(
41
+ char phase, const uint8_t* category_enabled_flag, const char* name,
42
+ const char* scope, uint64_t id, uint64_t bind_id, int num_args,
43
+ const char** arg_names, const uint8_t* arg_types,
44
+ const uint64_t* arg_values,
45
+ std::unique_ptr<v8::ConvertableToTraceFormat>* arg_convertables,
46
+ unsigned int flags, int64_t timestamp, int64_t cpu_timestamp);
47
+ void UpdateDuration(int64_t timestamp, int64_t cpu_timestamp);
48
+ void InitializeForTesting(
49
+ char phase, const uint8_t* category_enabled_flag, const char* name,
50
+ const char* scope, uint64_t id, uint64_t bind_id, int num_args,
51
+ const char** arg_names, const uint8_t* arg_types,
52
+ const uint64_t* arg_values,
53
+ std::unique_ptr<v8::ConvertableToTraceFormat>* arg_convertables,
54
+ unsigned int flags, int pid, int tid, int64_t ts, int64_t tts,
55
+ uint64_t duration, uint64_t cpu_duration);
56
+
57
+ int pid() const { return pid_; }
58
+ int tid() const { return tid_; }
59
+ char phase() const { return phase_; }
60
+ const uint8_t* category_enabled_flag() const {
61
+ return category_enabled_flag_;
62
+ }
63
+ const char* name() const { return name_; }
64
+ const char* scope() const { return scope_; }
65
+ uint64_t id() const { return id_; }
66
+ uint64_t bind_id() const { return bind_id_; }
67
+ int num_args() const { return num_args_; }
68
+ const char** arg_names() { return arg_names_; }
69
+ uint8_t* arg_types() { return arg_types_; }
70
+ ArgValue* arg_values() { return arg_values_; }
71
+ std::unique_ptr<v8::ConvertableToTraceFormat>* arg_convertables() {
72
+ return arg_convertables_;
73
+ }
74
+ unsigned int flags() const { return flags_; }
75
+ int64_t ts() { return ts_; }
76
+ int64_t tts() { return tts_; }
77
+ uint64_t duration() { return duration_; }
78
+ uint64_t cpu_duration() { return cpu_duration_; }
79
+
80
+ private:
81
+ int pid_;
82
+ int tid_;
83
+ char phase_;
84
+ const char* name_;
85
+ const char* scope_;
86
+ const uint8_t* category_enabled_flag_;
87
+ uint64_t id_;
88
+ uint64_t bind_id_;
89
+ int num_args_ = 0;
90
+ const char* arg_names_[kTraceMaxNumArgs];
91
+ uint8_t arg_types_[kTraceMaxNumArgs];
92
+ ArgValue arg_values_[kTraceMaxNumArgs];
93
+ std::unique_ptr<v8::ConvertableToTraceFormat>
94
+ arg_convertables_[kTraceMaxNumArgs];
95
+ char* parameter_copy_storage_ = nullptr;
96
+ unsigned int flags_;
97
+ int64_t ts_;
98
+ int64_t tts_;
99
+ uint64_t duration_;
100
+ uint64_t cpu_duration_;
101
+
102
+ // Disallow copy and assign
103
+ TraceObject(const TraceObject&) = delete;
104
+ void operator=(const TraceObject&) = delete;
105
+ };
106
+
107
+ class V8_PLATFORM_EXPORT TraceWriter {
108
+ public:
109
+ TraceWriter() = default;
110
+ virtual ~TraceWriter() = default;
111
+ virtual void AppendTraceEvent(TraceObject* trace_event) = 0;
112
+ virtual void Flush() = 0;
113
+
114
+ static TraceWriter* CreateJSONTraceWriter(std::ostream& stream);
115
+ static TraceWriter* CreateJSONTraceWriter(std::ostream& stream,
116
+ const std::string& tag);
117
+
118
+ private:
119
+ // Disallow copy and assign
120
+ TraceWriter(const TraceWriter&) = delete;
121
+ void operator=(const TraceWriter&) = delete;
122
+ };
123
+
124
+ class V8_PLATFORM_EXPORT TraceBufferChunk {
125
+ public:
126
+ explicit TraceBufferChunk(uint32_t seq);
127
+
128
+ void Reset(uint32_t new_seq);
129
+ bool IsFull() const { return next_free_ == kChunkSize; }
130
+ TraceObject* AddTraceEvent(size_t* event_index);
131
+ TraceObject* GetEventAt(size_t index) { return &chunk_[index]; }
132
+
133
+ uint32_t seq() const { return seq_; }
134
+ size_t size() const { return next_free_; }
135
+
136
+ static const size_t kChunkSize = 64;
137
+
138
+ private:
139
+ size_t next_free_ = 0;
140
+ TraceObject chunk_[kChunkSize];
141
+ uint32_t seq_;
142
+
143
+ // Disallow copy and assign
144
+ TraceBufferChunk(const TraceBufferChunk&) = delete;
145
+ void operator=(const TraceBufferChunk&) = delete;
146
+ };
147
+
148
+ class V8_PLATFORM_EXPORT TraceBuffer {
149
+ public:
150
+ TraceBuffer() = default;
151
+ virtual ~TraceBuffer() = default;
152
+
153
+ virtual TraceObject* AddTraceEvent(uint64_t* handle) = 0;
154
+ virtual TraceObject* GetEventByHandle(uint64_t handle) = 0;
155
+ virtual bool Flush() = 0;
156
+
157
+ static const size_t kRingBufferChunks = 1024;
158
+
159
+ static TraceBuffer* CreateTraceBufferRingBuffer(size_t max_chunks,
160
+ TraceWriter* trace_writer);
161
+
162
+ private:
163
+ // Disallow copy and assign
164
+ TraceBuffer(const TraceBuffer&) = delete;
165
+ void operator=(const TraceBuffer&) = delete;
166
+ };
167
+
168
+ // Options determines how the trace buffer stores data.
169
+ enum TraceRecordMode {
170
+ // Record until the trace buffer is full.
171
+ RECORD_UNTIL_FULL,
172
+
173
+ // Record until the user ends the trace. The trace buffer is a fixed size
174
+ // and we use it as a ring buffer during recording.
175
+ RECORD_CONTINUOUSLY,
176
+
177
+ // Record until the trace buffer is full, but with a huge buffer size.
178
+ RECORD_AS_MUCH_AS_POSSIBLE,
179
+
180
+ // Echo to console. Events are discarded.
181
+ ECHO_TO_CONSOLE,
182
+ };
183
+
184
+ class V8_PLATFORM_EXPORT TraceConfig {
185
+ public:
186
+ typedef std::vector<std::string> StringList;
187
+
188
+ static TraceConfig* CreateDefaultTraceConfig();
189
+
190
+ TraceConfig() : enable_systrace_(false), enable_argument_filter_(false) {}
191
+ TraceRecordMode GetTraceRecordMode() const { return record_mode_; }
192
+ bool IsSystraceEnabled() const { return enable_systrace_; }
193
+ bool IsArgumentFilterEnabled() const { return enable_argument_filter_; }
194
+
195
+ void SetTraceRecordMode(TraceRecordMode mode) { record_mode_ = mode; }
196
+ void EnableSystrace() { enable_systrace_ = true; }
197
+ void EnableArgumentFilter() { enable_argument_filter_ = true; }
198
+
199
+ void AddIncludedCategory(const char* included_category);
200
+
201
+ bool IsCategoryGroupEnabled(const char* category_group) const;
202
+
203
+ private:
204
+ TraceRecordMode record_mode_;
205
+ bool enable_systrace_ : 1;
206
+ bool enable_argument_filter_ : 1;
207
+ StringList included_categories_;
208
+
209
+ // Disallow copy and assign
210
+ TraceConfig(const TraceConfig&) = delete;
211
+ void operator=(const TraceConfig&) = delete;
212
+ };
213
+
214
+ #if defined(_MSC_VER)
215
+ #define V8_PLATFORM_NON_EXPORTED_BASE(code) \
216
+ __pragma(warning(suppress : 4275)) code
217
+ #else
218
+ #define V8_PLATFORM_NON_EXPORTED_BASE(code) code
219
+ #endif // defined(_MSC_VER)
220
+
221
+ class V8_PLATFORM_EXPORT TracingController
222
+ : public V8_PLATFORM_NON_EXPORTED_BASE(v8::TracingController) {
223
+ public:
224
+ enum Mode { DISABLED = 0, RECORDING_MODE };
225
+
226
+ // The pointer returned from GetCategoryGroupEnabledInternal() points to a
227
+ // value with zero or more of the following bits. Used in this class only.
228
+ // The TRACE_EVENT macros should only use the value as a bool.
229
+ // These values must be in sync with macro values in TraceEvent.h in Blink.
230
+ enum CategoryGroupEnabledFlags {
231
+ // Category group enabled for the recording mode.
232
+ ENABLED_FOR_RECORDING = 1 << 0,
233
+ // Category group enabled by SetEventCallbackEnabled().
234
+ ENABLED_FOR_EVENT_CALLBACK = 1 << 2,
235
+ // Category group enabled to export events to ETW.
236
+ ENABLED_FOR_ETW_EXPORT = 1 << 3
237
+ };
238
+
239
+ TracingController();
240
+ ~TracingController() override;
241
+ void Initialize(TraceBuffer* trace_buffer);
242
+
243
+ // v8::TracingController implementation.
244
+ const uint8_t* GetCategoryGroupEnabled(const char* category_group) override;
245
+ uint64_t AddTraceEvent(
246
+ char phase, const uint8_t* category_enabled_flag, const char* name,
247
+ const char* scope, uint64_t id, uint64_t bind_id, int32_t num_args,
248
+ const char** arg_names, const uint8_t* arg_types,
249
+ const uint64_t* arg_values,
250
+ std::unique_ptr<v8::ConvertableToTraceFormat>* arg_convertables,
251
+ unsigned int flags) override;
252
+ uint64_t AddTraceEventWithTimestamp(
253
+ char phase, const uint8_t* category_enabled_flag, const char* name,
254
+ const char* scope, uint64_t id, uint64_t bind_id, int32_t num_args,
255
+ const char** arg_names, const uint8_t* arg_types,
256
+ const uint64_t* arg_values,
257
+ std::unique_ptr<v8::ConvertableToTraceFormat>* arg_convertables,
258
+ unsigned int flags, int64_t timestamp) override;
259
+ void UpdateTraceEventDuration(const uint8_t* category_enabled_flag,
260
+ const char* name, uint64_t handle) override;
261
+ void AddTraceStateObserver(
262
+ v8::TracingController::TraceStateObserver* observer) override;
263
+ void RemoveTraceStateObserver(
264
+ v8::TracingController::TraceStateObserver* observer) override;
265
+
266
+ void StartTracing(TraceConfig* trace_config);
267
+ void StopTracing();
268
+
269
+ static const char* GetCategoryGroupName(const uint8_t* category_enabled_flag);
270
+
271
+ protected:
272
+ virtual int64_t CurrentTimestampMicroseconds();
273
+ virtual int64_t CurrentCpuTimestampMicroseconds();
274
+
275
+ private:
276
+ const uint8_t* GetCategoryGroupEnabledInternal(const char* category_group);
277
+ void UpdateCategoryGroupEnabledFlag(size_t category_index);
278
+ void UpdateCategoryGroupEnabledFlags();
279
+
280
+ std::unique_ptr<TraceBuffer> trace_buffer_;
281
+ std::unique_ptr<TraceConfig> trace_config_;
282
+ std::unique_ptr<base::Mutex> mutex_;
283
+ std::unordered_set<v8::TracingController::TraceStateObserver*> observers_;
284
+ Mode mode_ = DISABLED;
285
+
286
+ // Disallow copy and assign
287
+ TracingController(const TracingController&) = delete;
288
+ void operator=(const TracingController&) = delete;
289
+ };
290
+
291
+ #undef V8_PLATFORM_NON_EXPORTED_BASE
292
+
293
+ } // namespace tracing
294
+ } // namespace platform
295
+ } // namespace v8
296
+
297
+ #endif // V8_LIBPLATFORM_V8_TRACING_H_