-
-
Notifications
You must be signed in to change notification settings - Fork 20
/
compat.patch
851 lines (771 loc) · 34.7 KB
/
compat.patch
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
From 8a2572ff7c08ce44ba6ded10fdde3d48905b91c0 Mon Sep 17 00:00:00 2001
From: Gary Mathews <[email protected]>
Date: Thu, 11 Apr 2019 13:05:22 -0700
Subject: [PATCH] compatibility
---
include/v8.h | 122 ++++++++++++---------
src/api.cc | 134 +++++++++++++++++++++--
src/handles.h | 1 +
src/heap/factory.cc | 4 +-
src/objects.cc | 4 +-
src/parsing/scanner-character-streams.cc | 34 +-----
6 files changed, 205 insertions(+), 94 deletions(-)
diff --git a/include/v8.h b/include/v8.h
index b23114f4ff..2c7483b082 100644
--- a/include/v8.h
+++ b/include/v8.h
@@ -118,12 +118,12 @@ class HeapObject;
class Isolate;
class LocalEmbedderHeapTracer;
class NeverReadOnlySpaceObject;
+class Object;
struct ScriptStreamingData;
template<typename T> class CustomArguments;
class PropertyCallbackArguments;
class FunctionCallbackArguments;
class GlobalHandles;
-class ScopedExternalStringLock;
namespace wasm {
class NativeModule;
@@ -860,6 +860,7 @@ class V8_EXPORT HandleScope {
void Initialize(Isolate* isolate);
+ static internal::Object** CreateHandle(internal::Isolate* isolate, internal::Object* value);
static internal::Address* CreateHandle(internal::Isolate* isolate,
internal::Address value);
@@ -900,8 +901,8 @@ class V8_EXPORT EscapableHandleScope : public HandleScope {
*/
template <class T>
V8_INLINE Local<T> Escape(Local<T> value) {
- internal::Address* slot =
- Escape(reinterpret_cast<internal::Address*>(*value));
+ internal::Object** slot =
+ Escape(reinterpret_cast<internal::Object**>(*value));
return Local<T>(reinterpret_cast<T*>(slot));
}
@@ -921,6 +922,7 @@ class V8_EXPORT EscapableHandleScope : public HandleScope {
void operator delete(void*, size_t);
void operator delete[](void*, size_t);
+ internal::Object** Escape(internal::Object** escape_value);
internal::Address* Escape(internal::Address* escape_value);
internal::Address* escape_slot_;
};
@@ -1229,12 +1231,16 @@ class V8_EXPORT Script {
Local<Context> context, Local<String> source,
ScriptOrigin* origin = nullptr);
+ static Local<Script> Compile(v8::Local<String> source, v8::ScriptOrigin* origin);
+ static Local<Script> Compile(v8::Local<String> source, v8::Local<String> file_name);
+
/**
* Runs the script returning the resulting value. It will be run in the
* context in which it was created (ScriptCompiler::CompileBound or
* UnboundScript::BindToCurrentContext()).
*/
V8_WARN_UNUSED_RESULT MaybeLocal<Value> Run(Local<Context> context);
+ Local<Value> Run();
/**
* Returns the corresponding context-unbound script.
@@ -1595,8 +1601,8 @@ class V8_EXPORT Message {
*/
Isolate* GetIsolate() const;
- V8_WARN_UNUSED_RESULT MaybeLocal<String> GetSourceLine(
- Local<Context> context) const;
+ V8_WARN_UNUSED_RESULT MaybeLocal<String> GetSourceLine(Local<Context> context) const;
+ Local<String> GetSourceLine() const;
/**
* Returns the origin for the script from where the function causing the
@@ -1621,6 +1627,7 @@ class V8_EXPORT Message {
* Returns the number, 1-based, of the line where the error occurred.
*/
V8_WARN_UNUSED_RESULT Maybe<int> GetLineNumber(Local<Context> context) const;
+ int GetLineNumber() const;
/**
* Returns the index within the script of the first character where
@@ -2613,21 +2620,12 @@ class V8_EXPORT String : public Name {
class V8_EXPORT ExternalStringResourceBase { // NOLINT
public:
- virtual ~ExternalStringResourceBase() = default;
+ virtual ~ExternalStringResourceBase() {}
- V8_DEPRECATED("Use IsCacheable().", virtual bool IsCompressible() const) {
- return false;
- }
-
- /**
- * If a string is cacheable, the value returned by
- * ExternalStringResource::data() may be cached, otherwise it is not
- * expected to be stable beyond the current top-level task.
- */
- virtual bool IsCacheable() const { return true; }
+ virtual bool IsCompressible() const { return false; }
protected:
- ExternalStringResourceBase() = default;
+ ExternalStringResourceBase() {}
/**
* Internally V8 will call this Dispose method when the external string
@@ -2637,24 +2635,6 @@ class V8_EXPORT String : public Name {
*/
virtual void Dispose() { delete this; }
- /**
- * For a non-cacheable string, the value returned by
- * |ExternalStringResource::data()| has to be stable between |Lock()| and
- * |Unlock()|, that is the string must behave as is |IsCacheable()| returned
- * true.
- *
- * These two functions must be thread-safe, and can be called from anywhere.
- * They also must handle lock depth, in the sense that each can be called
- * several times, from different threads, and unlocking should only happen
- * when the balance of Lock() and Unlock() calls is 0.
- */
- virtual void Lock() const {}
-
- /**
- * Unlocks the string.
- */
- virtual void Unlock() const {}
-
// Disallow copying and assigning.
ExternalStringResourceBase(const ExternalStringResourceBase&) = delete;
void operator=(const ExternalStringResourceBase&) = delete;
@@ -2662,7 +2642,6 @@ class V8_EXPORT String : public Name {
private:
friend class internal::Heap;
friend class v8::String;
- friend class internal::ScopedExternalStringLock;
};
/**
@@ -2854,6 +2833,7 @@ class V8_EXPORT String : public Name {
*/
class V8_EXPORT Utf8Value {
public:
+ Utf8Value(Local<v8::Value> obj);
Utf8Value(Isolate* isolate, Local<v8::Value> obj);
~Utf8Value();
char* operator*() { return str_; }
@@ -2877,6 +2857,7 @@ class V8_EXPORT String : public Name {
*/
class V8_EXPORT Value {
public:
+ Value(Local<v8::Value> obj);
Value(Isolate* isolate, Local<v8::Value> obj);
~Value();
uint16_t* operator*() { return str_; }
@@ -3308,6 +3289,7 @@ class V8_EXPORT Object : public Value {
* See also v8::Object::HasOwnProperty() and
* v8::Object::HasRealNamedProperty().
*/
+ bool Has(Local<Value> key);
V8_WARN_UNUSED_RESULT Maybe<bool> Has(Local<Context> context,
Local<Value> key);
@@ -3322,6 +3304,12 @@ class V8_EXPORT Object : public Value {
/**
* Note: SideEffectType affects the getter only, not the setter.
*/
+ bool SetAccessor(Local<Name> name,
+ AccessorNameGetterCallback getter,
+ AccessorNameSetterCallback setter = 0,
+ Local<Value> data = Local<Value>(),
+ AccessControl settings = DEFAULT,
+ PropertyAttribute attribute = None);
V8_WARN_UNUSED_RESULT Maybe<bool> SetAccessor(
Local<Context> context, Local<Name> name,
AccessorNameGetterCallback getter,
@@ -3489,6 +3477,7 @@ class V8_EXPORT Object : public Value {
*
* See also v8::Object::Has() and v8::Object::HasRealNamedProperty().
*/
+ bool HasOwnProperty(Local<String> key);
V8_WARN_UNUSED_RESULT Maybe<bool> HasOwnProperty(Local<Context> context,
Local<Name> key);
V8_WARN_UNUSED_RESULT Maybe<bool> HasOwnProperty(Local<Context> context,
@@ -3540,6 +3529,7 @@ class V8_EXPORT Object : public Value {
* in the prototype chain.
* This means interceptors in the prototype chain are not called.
*/
+ Local<Value> GetRealNamedProperty(Local<String> key);
V8_WARN_UNUSED_RESULT MaybeLocal<Value> GetRealNamedProperty(
Local<Context> context, Local<Name> key);
@@ -3809,6 +3799,7 @@ class FunctionCallbackInfo {
V8_INLINE int Length() const;
/** Accessor for the available arguments. */
V8_INLINE Local<Value> operator[](int i) const;
+ V8_INLINE Local<Function> Callee() const;
/** Returns the receiver. This corresponds to the "this" value. */
V8_INLINE Local<Object> This() const;
/**
@@ -3845,6 +3836,7 @@ class FunctionCallbackInfo {
static const int kReturnValueIndex = 3;
static const int kDataIndex = 4;
static const int kNewTargetIndex = 5;
+ static const int kCalleeIndex = 6;
V8_INLINE FunctionCallbackInfo(internal::Address* implicit_args,
internal::Address* values, int length);
@@ -3998,6 +3990,8 @@ class V8_EXPORT Function : public Object {
return NewInstance(context, 0, nullptr);
}
+ Local<Object> NewInstance(int argc, Local<Value> argv[]) const;
+
/**
* When side effect checks are enabled, passing kHasNoSideEffect allows the
* constructor to be invoked without throwing. Calls made within the
@@ -5182,6 +5176,7 @@ class V8_EXPORT SharedArrayBuffer : public Object {
*/
class V8_EXPORT Date : public Object {
public:
+ static Local<Value> New(Isolate* isolate, double time);
static V8_WARN_UNUSED_RESULT MaybeLocal<Value> New(Local<Context> context,
double time);
@@ -5465,6 +5460,12 @@ class V8_EXPORT Template : public Data {
friend class FunctionTemplate;
};
+typedef void (*NamedPropertyGetterCallback)(Local<String> property, const PropertyCallbackInfo<Value>& info);
+typedef void (*NamedPropertySetterCallback)(Local<String> property, Local<Value> value, const PropertyCallbackInfo<Value>& info);
+typedef void (*NamedPropertyQueryCallback)(Local<String> property, const PropertyCallbackInfo<Integer>& info);
+typedef void (*NamedPropertyDeleterCallback)(Local<String> property, const PropertyCallbackInfo<Boolean>& info);
+typedef void (*NamedPropertyEnumeratorCallback)(const PropertyCallbackInfo<Array>& info);
+
// TODO(dcarney): Replace GenericNamedPropertyFooCallback with just
// NamedPropertyFooCallback.
@@ -5813,8 +5814,7 @@ class V8_EXPORT FunctionTemplate : public Template {
Isolate* isolate, FunctionCallback callback = nullptr,
Local<Value> data = Local<Value>(),
Local<Signature> signature = Local<Signature>(), int length = 0,
- ConstructorBehavior behavior = ConstructorBehavior::kAllow,
- SideEffectType side_effect_type = SideEffectType::kHasSideEffect);
+ ConstructorBehavior behavior = ConstructorBehavior::kAllow);
/** Get a template included in the snapshot by index. */
static MaybeLocal<FunctionTemplate> FromSnapshot(Isolate* isolate,
@@ -6172,9 +6172,15 @@ class V8_EXPORT ObjectTemplate : public Template {
AccessorNameSetterCallback setter = nullptr,
Local<Value> data = Local<Value>(), AccessControl settings = DEFAULT,
PropertyAttribute attribute = None,
- Local<AccessorSignature> signature = Local<AccessorSignature>(),
- SideEffectType getter_side_effect_type = SideEffectType::kHasSideEffect,
- SideEffectType setter_side_effect_type = SideEffectType::kHasSideEffect);
+ Local<AccessorSignature> signature = Local<AccessorSignature>());
+
+ void SetNamedPropertyHandler(
+ NamedPropertyGetterCallback getter,
+ NamedPropertySetterCallback setter = 0,
+ NamedPropertyQueryCallback query = 0,
+ NamedPropertyDeleterCallback deleter = 0,
+ NamedPropertyEnumeratorCallback enumerator = 0,
+ Local<Value> data = Local<Value>());
/**
* Sets a named property handler on the object template.
@@ -8563,14 +8569,19 @@ class V8_EXPORT V8 {
private:
V8();
+ static internal::Object** GlobalizeReference(internal::Isolate* isolate, internal::Object** handle);
static internal::Address* GlobalizeReference(internal::Isolate* isolate,
internal::Address* handle);
static internal::Address* CopyPersistent(internal::Address* handle);
+ static void DisposeGlobal(internal::Object** global_handle);
static void DisposeGlobal(internal::Address* global_handle);
+ static void MakeWeak(internal::Object** location, void* data, WeakCallbackInfo<void>::Callback weak_callback, WeakCallbackType type);
static void MakeWeak(internal::Address* location, void* data,
WeakCallbackInfo<void>::Callback weak_callback,
WeakCallbackType type);
+ static void MakeWeak(internal::Object*** location_addr);
static void MakeWeak(internal::Address** location_addr);
+ static void* ClearWeak(internal::Object** location);
static void* ClearWeak(internal::Address* location);
static void AnnotateStrongRetainer(internal::Address* location,
const char* label);
@@ -8830,6 +8841,7 @@ class V8_EXPORT TryCatch {
* all TryCatch blocks should be stack allocated because the memory
* location itself is compared against JavaScript try/catch blocks.
*/
+ explicit TryCatch();
explicit TryCatch(Isolate* isolate);
/**
@@ -8887,6 +8899,7 @@ class V8_EXPORT TryCatch {
* Returns the .stack property of the thrown object. If no .stack
* property is present an empty handle is returned.
*/
+ Local<Value> StackTrace() const;
V8_WARN_UNUSED_RESULT MaybeLocal<Value> StackTrace(
Local<Context> context) const;
@@ -9455,7 +9468,7 @@ template <class T>
Local<T> Local<T>::New(Isolate* isolate, T* that) {
if (that == nullptr) return Local<T>();
T* that_ptr = that;
- internal::Address* p = reinterpret_cast<internal::Address*>(that_ptr);
+ internal::Object** p = reinterpret_cast<internal::Object**>(that_ptr);
return Local<T>(reinterpret_cast<T*>(HandleScope::CreateHandle(
reinterpret_cast<internal::Isolate*>(isolate), *p)));
}
@@ -9498,7 +9511,7 @@ void* WeakCallbackInfo<T>::GetInternalField(int index) const {
template <class T>
T* PersistentBase<T>::New(Isolate* isolate, T* that) {
if (that == nullptr) return nullptr;
- internal::Address* p = reinterpret_cast<internal::Address*>(that);
+ internal::Object** p = reinterpret_cast<internal::Object**>(that);
return reinterpret_cast<T*>(
V8::GlobalizeReference(reinterpret_cast<internal::Isolate*>(isolate),
p));
@@ -9547,7 +9560,7 @@ bool PersistentBase<T>::IsWeak() const {
template <class T>
void PersistentBase<T>::Reset() {
if (this->IsEmpty()) return;
- V8::DisposeGlobal(reinterpret_cast<internal::Address*>(this->val_));
+ V8::DisposeGlobal(reinterpret_cast<internal::Object**>(this->val_));
val_ = nullptr;
}
@@ -9579,20 +9592,20 @@ V8_INLINE void PersistentBase<T>::SetWeak(
P* parameter, typename WeakCallbackInfo<P>::Callback callback,
WeakCallbackType type) {
typedef typename WeakCallbackInfo<void>::Callback Callback;
- V8::MakeWeak(reinterpret_cast<internal::Address*>(this->val_), parameter,
+ V8::MakeWeak(reinterpret_cast<internal::Object**>(this->val_), parameter,
reinterpret_cast<Callback>(callback), type);
}
template <class T>
void PersistentBase<T>::SetWeak() {
- V8::MakeWeak(reinterpret_cast<internal::Address**>(&this->val_));
+ V8::MakeWeak(reinterpret_cast<internal::Object***>(&this->val_));
}
template <class T>
template <typename P>
P* PersistentBase<T>::ClearWeak() {
return reinterpret_cast<P*>(
- V8::ClearWeak(reinterpret_cast<internal::Address*>(this->val_)));
+ V8::ClearWeak(reinterpret_cast<internal::Object**>(this->val_)));
}
template <class T>
@@ -9783,6 +9796,11 @@ Local<Value> FunctionCallbackInfo<T>::operator[](int i) const {
return Local<Value>(reinterpret_cast<Value*>(values_ - i));
}
+template<typename T>
+Local<Function> FunctionCallbackInfo<T>::Callee() const {
+ return Local<Function>(reinterpret_cast<Function*>(
+ &implicit_args_[kCalleeIndex]));
+}
template<typename T>
Local<Object> FunctionCallbackInfo<T>::This() const {
@@ -9943,6 +9961,7 @@ AccessorSignature* AccessorSignature::Cast(Data* data) {
Local<Value> Object::GetInternalField(int index) {
#if !defined(V8_ENABLE_CHECKS) && !defined(V8_COMPRESS_POINTERS)
+ typedef internal::Object* O;
typedef internal::Address A;
typedef internal::Internals I;
A obj = *reinterpret_cast<A*>(this);
@@ -9954,10 +9973,10 @@ Local<Value> Object::GetInternalField(int index) {
instance_type == I::kJSSpecialApiObjectType) {
int offset = I::kJSObjectHeaderSizeForEmbedderFields +
(I::kEmbedderDataSlotSize * index);
- A value = I::ReadTaggedAnyField(obj, offset);
+ O value = reinterpret_cast<O>(I::ReadTaggedAnyField(obj, offset));
internal::Isolate* isolate =
internal::IsolateFromNeverReadOnlySpaceObject(obj);
- A* result = HandleScope::CreateHandle(isolate, value);
+ O* result = HandleScope::CreateHandle(isolate, value);
return Local<Value>(reinterpret_cast<Value*>(result));
}
#endif
@@ -10575,12 +10594,13 @@ int64_t Isolate::AdjustAmountOfExternalAllocatedMemory(
Local<Value> Context::GetEmbedderData(int index) {
#if !defined(V8_ENABLE_CHECKS) && !defined(V8_COMPRESS_POINTERS)
+ typedef internal::Object* O;
typedef internal::Address A;
typedef internal::Internals I;
internal::Isolate* isolate = internal::IsolateFromNeverReadOnlySpaceObject(
*reinterpret_cast<A*>(this));
- A* result =
- HandleScope::CreateHandle(isolate, I::ReadEmbedderData<A>(this, index));
+ O* result =
+ HandleScope::CreateHandle(isolate, reinterpret_cast<O>(I::ReadEmbedderData<A>(this, index)));
return Local<Value>(reinterpret_cast<Value*>(result));
#else
return SlowGetEmbedderData(index);
diff --git a/src/api.cc b/src/api.cc
index b1f9c99860..c5a7448771 100644
--- a/src/api.cc
+++ b/src/api.cc
@@ -243,6 +243,11 @@ Local<Context> ContextFromNeverReadOnlySpaceObject(
return reinterpret_cast<v8::Isolate*>(obj->GetIsolate())->GetCurrentContext();
}
+Local<Context> UnsafeContextFromHeapObject(i::Handle<i::Object> obj) {
+ i::MemoryChunk* chunk = i::MemoryChunk::FromHeapObject(i::HeapObject::cast(*obj));
+ return reinterpret_cast<Isolate*>(chunk->heap()->isolate())->GetCurrentContext();
+}
+
class InternalEscapableScope : public v8::EscapableHandleScope {
public:
explicit inline InternalEscapableScope(i::Isolate* isolate)
@@ -993,6 +998,9 @@ void SetResourceConstraints(i::Isolate* isolate,
}
}
+i::Object** V8::GlobalizeReference(i::Isolate* isolate, i::Object** obj) {
+ return reinterpret_cast<i::Object**>(GlobalizeReference(isolate, reinterpret_cast<i::Address*>(obj)));
+}
i::Address* V8::GlobalizeReference(i::Isolate* isolate, i::Address* obj) {
LOG_API(isolate, Persistent, New);
i::Handle<i::Object> result = isolate->global_handles()->Create(*obj);
@@ -1014,16 +1022,25 @@ void V8::RegisterExternallyReferencedObject(i::Address* location,
isolate->heap()->RegisterExternallyReferencedObject(location);
}
+void V8::MakeWeak(i::Object** location, void* parameter, WeakCallbackInfo<void>::Callback weak_callback, WeakCallbackType type) {
+ MakeWeak(reinterpret_cast<i::Address*>(location), parameter, weak_callback, type);
+}
void V8::MakeWeak(i::Address* location, void* parameter,
WeakCallbackInfo<void>::Callback weak_callback,
WeakCallbackType type) {
i::GlobalHandles::MakeWeak(location, parameter, weak_callback, type);
}
+void V8::MakeWeak(i::Object*** location_addr) {
+ MakeWeak(reinterpret_cast<i::Address**>(location_addr));
+}
void V8::MakeWeak(i::Address** location_addr) {
i::GlobalHandles::MakeWeak(location_addr);
}
+void* V8::ClearWeak(i::Object** location) {
+ return i::GlobalHandles::ClearWeakness(reinterpret_cast<i::Address*>(location));
+}
void* V8::ClearWeak(i::Address* location) {
return i::GlobalHandles::ClearWeakness(location);
}
@@ -1032,6 +1049,9 @@ void V8::AnnotateStrongRetainer(i::Address* location, const char* label) {
i::GlobalHandles::AnnotateStrongRetainer(location, label);
}
+void V8::DisposeGlobal(i::Object** location) {
+ DisposeGlobal(reinterpret_cast<i::Address*>(location));
+}
void V8::DisposeGlobal(i::Address* location) {
i::GlobalHandles::Destroy(location);
}
@@ -1105,6 +1125,9 @@ int HandleScope::NumberOfHandles(Isolate* isolate) {
reinterpret_cast<i::Isolate*>(isolate));
}
+i::Object** HandleScope::CreateHandle(i::Isolate* isolate, i::Object* value) {
+ return reinterpret_cast<i::Object**>(CreateHandle(isolate, reinterpret_cast<i::Address>(value)));
+}
i::Address* HandleScope::CreateHandle(i::Isolate* isolate, i::Address value) {
return i::HandleScope::CreateHandle(isolate, value);
}
@@ -1116,6 +1139,9 @@ EscapableHandleScope::EscapableHandleScope(Isolate* v8_isolate) {
Initialize(v8_isolate);
}
+i::Object** EscapableHandleScope::Escape(i::Object** escape_value) {
+ return reinterpret_cast<i::Object**>(Escape(reinterpret_cast<i::Address*>(escape_value)));
+}
i::Address* EscapableHandleScope::Escape(i::Address* escape_value) {
i::Heap* heap = reinterpret_cast<i::Isolate*>(GetIsolate())->heap();
Utils::ApiCheck(i::Object(*escape_slot_)->IsTheHole(heap->isolate()),
@@ -1430,15 +1456,14 @@ static Local<FunctionTemplate> FunctionTemplateNew(
Local<FunctionTemplate> FunctionTemplate::New(
Isolate* isolate, FunctionCallback callback, v8::Local<Value> data,
- v8::Local<Signature> signature, int length, ConstructorBehavior behavior,
- SideEffectType side_effect_type) {
+ v8::Local<Signature> signature, int length, ConstructorBehavior behavior) {
i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate);
// Changes to the environment cannot be captured in the snapshot. Expect no
// function templates when the isolate is created for serialization.
LOG_API(i_isolate, FunctionTemplate, New);
ENTER_V8_NO_SCRIPT_NO_EXCEPTION(i_isolate);
auto templ = FunctionTemplateNew(i_isolate, callback, data, signature, length,
- false, Local<Private>(), side_effect_type);
+ false, Local<Private>(), SideEffectType::kHasSideEffect);
if (behavior == ConstructorBehavior::kThrow) templ->RemovePrototype();
return templ;
}
@@ -1777,12 +1802,10 @@ void ObjectTemplate::SetAccessor(v8::Local<Name> name,
AccessorNameSetterCallback setter,
v8::Local<Value> data, AccessControl settings,
PropertyAttribute attribute,
- v8::Local<AccessorSignature> signature,
- SideEffectType getter_side_effect_type,
- SideEffectType setter_side_effect_type) {
+ v8::Local<AccessorSignature> signature) {
TemplateSetAccessor(this, name, getter, setter, data, settings, attribute,
signature, i::FLAG_disable_old_api_accessors, false,
- getter_side_effect_type, setter_side_effect_type);
+ SideEffectType::kHasSideEffect, SideEffectType::kHasSideEffect);
}
template <typename Getter, typename Setter, typename Query, typename Descriptor,
@@ -1865,6 +1888,15 @@ static void ObjectTemplateSetNamedPropertyHandler(
i::FunctionTemplateInfo::SetNamedPropertyHandler(isolate, cons, obj);
}
+void ObjectTemplate::SetNamedPropertyHandler(
+ NamedPropertyGetterCallback getter, NamedPropertySetterCallback setter,
+ NamedPropertyQueryCallback query, NamedPropertyDeleterCallback remover,
+ NamedPropertyEnumeratorCallback enumerator, Local<Value> data) {
+ ObjectTemplateSetNamedPropertyHandler(
+ this, getter, setter, query, nullptr, remover, enumerator, nullptr, data,
+ PropertyHandlerFlags::kOnlyInterceptStrings);
+}
+
void ObjectTemplate::SetHandler(
const NamedPropertyHandlerConfiguration& config) {
ObjectTemplateSetNamedPropertyHandler(
@@ -2138,6 +2170,14 @@ MaybeLocal<Value> Script::Run(Local<Context> context) {
RETURN_ESCAPED(result);
}
+Local<Value> Script::Run() {
+ auto self = Utils::OpenHandle(this, true);
+ // If execution is terminating, Compile(..)->Run() requires this
+ // check.
+ if (self.is_null()) return Local<Value>();
+ auto context = UnsafeContextFromHeapObject(self);
+ RETURN_TO_LOCAL_UNCHECKED(Run(context), Value);
+}
Local<Value> ScriptOrModule::GetResourceName() {
i::Handle<i::Script> obj = Utils::OpenHandle(this);
@@ -2613,9 +2653,39 @@ MaybeLocal<Script> Script::Compile(Local<Context> context, Local<String> source,
return ScriptCompiler::Compile(context, &script_source);
}
+Local<Script> Script::Compile(v8::Local<String> source,
+ v8::ScriptOrigin* origin) {
+ auto str = Utils::OpenHandle(*source);
+ auto context = UnsafeContextFromHeapObject(str);
+ RETURN_TO_LOCAL_UNCHECKED(Compile(context, source, origin), Script);
+}
+
+Local<Script> Script::Compile(v8::Local<String> source,
+ v8::Local<String> file_name) {
+ auto str = Utils::OpenHandle(*source);
+ auto context = UnsafeContextFromHeapObject(str);
+ ScriptOrigin origin(file_name);
+ return Compile(context, source, &origin).FromMaybe(Local<Script>());
+}
// --- E x c e p t i o n s ---
+v8::TryCatch::TryCatch()
+ : isolate_(i::Isolate::Current()),
+ next_(isolate_->try_catch_handler()),
+ is_verbose_(false),
+ can_continue_(true),
+ capture_message_(true),
+ rethrow_(false),
+ has_terminated_(false) {
+ ResetInternal();
+ // Special handling for simulators which have a separate JS stack.
+ js_stack_comparable_address_ =
+ reinterpret_cast<void*>(
+ i::SimulatorStack::RegisterJSStackComparableAddress(isolate_));
+ isolate_->RegisterTryCatchHandler(this);
+}
+
v8::TryCatch::TryCatch(v8::Isolate* isolate)
: isolate_(reinterpret_cast<i::Isolate*>(isolate)),
next_(isolate_->try_catch_handler()),
@@ -2718,6 +2788,10 @@ MaybeLocal<Value> v8::TryCatch::StackTrace(Local<Context> context) const {
RETURN_ESCAPED(result);
}
+v8::Local<Value> v8::TryCatch::StackTrace() const {
+ auto context = reinterpret_cast<v8::Isolate*>(isolate_)->GetCurrentContext();
+ RETURN_TO_LOCAL_UNCHECKED(StackTrace(context), Value);
+}
v8::Local<v8::Message> v8::TryCatch::Message() const {
i::Object message(reinterpret_cast<i::Address>(message_obj_));
@@ -2812,6 +2886,10 @@ Maybe<int> Message::GetLineNumber(Local<Context> context) const {
return Just(msg->GetLineNumber());
}
+int Message::GetLineNumber() const {
+ auto context = UnsafeContextFromHeapObject(Utils::OpenHandle(this));
+ return GetLineNumber(context).FromMaybe(0);
+}
int Message::GetStartPosition() const {
auto self = Utils::OpenHandle(this);
@@ -2885,6 +2963,10 @@ MaybeLocal<String> Message::GetSourceLine(Local<Context> context) const {
RETURN_ESCAPED(Utils::ToLocal(msg->GetSourceLine()));
}
+Local<String> Message::GetSourceLine() const {
+ auto context = UnsafeContextFromHeapObject(Utils::OpenHandle(this));
+ RETURN_TO_LOCAL_UNCHECKED(GetSourceLine(context), String)
+}
void Message::PrintCurrentStackTrace(Isolate* isolate, FILE* out) {
i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate);
@@ -4483,6 +4565,10 @@ Maybe<bool> v8::Object::DeletePrivate(Local<Context> context,
return result;
}
+bool v8::Object::Has(v8::Local<Value> key) {
+ auto context = ContextFromNeverReadOnlySpaceObject(Utils::OpenHandle(this));
+ return Has(context, key).FromMaybe(false);
+}
Maybe<bool> v8::Object::Has(Local<Context> context, Local<Value> key) {
auto isolate = reinterpret_cast<i::Isolate*>(context->GetIsolate());
ENTER_V8(isolate, context, Object, Has, Nothing<bool>(), i::HandleScope);
@@ -4581,6 +4667,15 @@ Maybe<bool> Object::SetAccessor(Local<Context> context, Local<Name> name,
getter_side_effect_type, setter_side_effect_type);
}
+bool Object::SetAccessor(Local<Name> name, AccessorNameGetterCallback getter,
+ AccessorNameSetterCallback setter,
+ v8::Local<Value> data, AccessControl settings,
+ PropertyAttribute attribute) {
+ auto context = UnsafeContextFromHeapObject(Utils::OpenHandle(this));
+ return ObjectSetAccessor(context, this, name, getter, setter,
+ data, settings, attribute, i::FLAG_disable_old_api_accessors,
+ false, SideEffectType::kHasSideEffect, SideEffectType::kHasSideEffect).FromMaybe(false);
+}
void Object::SetAccessorProperty(Local<Name> name, Local<Function> getter,
Local<Function> setter,
@@ -4647,6 +4742,11 @@ Maybe<bool> v8::Object::HasOwnProperty(Local<Context> context, uint32_t index) {
return result;
}
+bool v8::Object::HasOwnProperty(Local<String> key) {
+ auto context = UnsafeContextFromHeapObject(Utils::OpenHandle(this));
+ return HasOwnProperty(context, key).FromMaybe(false);
+}
+
Maybe<bool> v8::Object::HasRealNamedProperty(Local<Context> context,
Local<Name> key) {
auto isolate = reinterpret_cast<i::Isolate*>(context->GetIsolate());
@@ -4789,6 +4889,10 @@ MaybeLocal<Value> v8::Object::GetRealNamedProperty(Local<Context> context,
RETURN_ESCAPED(result);
}
+Local<Value> v8::Object::GetRealNamedProperty(Local<String> key) {
+ auto context = UnsafeContextFromHeapObject(Utils::OpenHandle(this));
+ RETURN_TO_LOCAL_UNCHECKED(GetRealNamedProperty(context, key), Value);
+}
Maybe<PropertyAttribute> v8::Object::GetRealNamedPropertyAttributes(
Local<Context> context, Local<Name> key) {
@@ -4911,6 +5015,12 @@ MaybeLocal<Object> Function::NewInstance(Local<Context> context, int argc,
SideEffectType::kHasSideEffect);
}
+Local<v8::Object> Function::NewInstance(int argc,
+ v8::Local<v8::Value> argv[]) const {
+ auto context = UnsafeContextFromHeapObject(Utils::OpenHandle(this));
+ RETURN_TO_LOCAL_UNCHECKED(NewInstance(context, argc, argv), Object);
+}
+
MaybeLocal<Object> Function::NewInstanceWithSideEffectType(
Local<Context> context, int argc, v8::Local<v8::Value> argv[],
SideEffectType side_effect_type) const {
@@ -6765,6 +6875,10 @@ MaybeLocal<v8::Value> v8::Date::New(Local<Context> context, double time) {
RETURN_ESCAPED(result);
}
+Local<v8::Value> v8::Date::New(Isolate* isolate, double time) {
+ auto context = isolate->GetCurrentContext();
+ RETURN_TO_LOCAL_UNCHECKED(New(context, time), Value);
+}
double v8::Date::ValueOf() const {
i::Handle<i::Object> obj = Utils::OpenHandle(this);
@@ -8929,6 +9043,9 @@ String::Utf8Value::Utf8Value(v8::Isolate* isolate, v8::Local<v8::Value> obj)
str->WriteUtf8(isolate, str_);
}
+String::Utf8Value::Utf8Value(v8::Local<v8::Value> obj)
+ : String::Utf8Value::Utf8Value(Isolate::GetCurrent(), obj) {}
+
String::Utf8Value::~Utf8Value() {
i::DeleteArray(str_);
}
@@ -8948,6 +9065,9 @@ String::Value::Value(v8::Isolate* isolate, v8::Local<v8::Value> obj)
str->Write(isolate, str_);
}
+String::Value::Value(v8::Local<v8::Value> obj)
+ : String::Value::Value(v8::Isolate::GetCurrent(), obj) {}
+
String::Value::~Value() {
i::DeleteArray(str_);
}
diff --git a/src/handles.h b/src/handles.h
index 2115f4a878..d2ecb0c949 100644
--- a/src/handles.h
+++ b/src/handles.h
@@ -197,6 +197,7 @@ class HandleScope {
V8_INLINE static Address* GetHandle(Isolate* isolate, Address value);
// Creates a new handle with the given value.
+ V8_INLINE static Object** CreateHandle(Isolate* isolate, Object* value);
V8_INLINE static Address* CreateHandle(Isolate* isolate, Address value);
// Deallocates any extensions used by the current scope.
diff --git a/src/heap/factory.cc b/src/heap/factory.cc
index f82d8937c3..a9da23ce37 100644
--- a/src/heap/factory.cc
+++ b/src/heap/factory.cc
@@ -1309,7 +1309,7 @@ MaybeHandle<String> Factory::NewExternalStringFromOneByte(
if (length == 0) return empty_string();
Handle<Map> map;
- if (!resource->IsCacheable()) {
+ if (resource->IsCompressible()) {
map = uncached_external_one_byte_string_map();
} else {
map = external_one_byte_string_map();
@@ -1339,7 +1339,7 @@ MaybeHandle<String> Factory::NewExternalStringFromTwoByte(
length <= kOneByteCheckLengthLimit &&
String::IsOneByte(resource->data(), static_cast<int>(length));
Handle<Map> map;
- if (!resource->IsCacheable()) {
+ if (resource->IsCompressible()) {
map = is_one_byte ? uncached_external_string_with_one_byte_data_map()
: uncached_external_string_map();
} else {
diff --git a/src/objects.cc b/src/objects.cc
index 119c6aed72..51810c3545 100644
--- a/src/objects.cc
+++ b/src/objects.cc
@@ -2661,7 +2661,7 @@ bool String::MakeExternal(v8::String::ExternalStringResource* resource) {
// Externalizing twice leaks the external resource, so it's
// prohibited by the API.
DCHECK(this->SupportsExternalization());
- DCHECK(resource->IsCacheable());
+ DCHECK(!resource->IsCompressible());
#ifdef ENABLE_SLOW_DCHECKS
if (FLAG_enable_slow_asserts) {
// Assert that the resource and the string are equivalent.
@@ -2743,7 +2743,7 @@ bool String::MakeExternal(v8::String::ExternalOneByteStringResource* resource) {
// Externalizing twice leaks the external resource, so it's
// prohibited by the API.
DCHECK(this->SupportsExternalization());
- DCHECK(resource->IsCacheable());
+ DCHECK(!resource->IsCompressible());
#ifdef ENABLE_SLOW_DCHECKS
if (FLAG_enable_slow_asserts) {
// Assert that the resource and the string are equivalent.
diff --git a/src/parsing/scanner-character-streams.cc b/src/parsing/scanner-character-streams.cc
index 32dcaacbf5..9518d44638 100644
--- a/src/parsing/scanner-character-streams.cc
+++ b/src/parsing/scanner-character-streams.cc
@@ -18,33 +18,6 @@
namespace v8 {
namespace internal {
-class ScopedExternalStringLock {
- public:
- explicit ScopedExternalStringLock(ExternalString string) {
- DCHECK(!string.is_null());
- if (string->IsExternalOneByteString()) {
- resource_ = ExternalOneByteString::cast(string)->resource();
- } else {
- DCHECK(string->IsExternalTwoByteString());
- resource_ = ExternalTwoByteString::cast(string)->resource();
- }
- DCHECK(resource_);
- resource_->Lock();
- }
-
- // Copying a lock increases the locking depth.
- ScopedExternalStringLock(const ScopedExternalStringLock& other) V8_NOEXCEPT
- : resource_(other.resource_) {
- resource_->Lock();
- }
-
- ~ScopedExternalStringLock() { resource_->Unlock(); }
-
- private:
- // Not nullptr.
- const v8::String::ExternalStringResourceBase* resource_;
-};
-
namespace {
const unibrow::uchar kUtf8Bom = 0xFEFF;
} // namespace
@@ -114,13 +87,11 @@ class ExternalStringStream {
public:
ExternalStringStream(ExternalString string, size_t start_offset,
size_t length)
- : lock_(string),
- data_(string->GetChars() + start_offset),
+ : data_(string->GetChars() + start_offset),
length_(length) {}
ExternalStringStream(const ExternalStringStream& other) V8_NOEXCEPT
- : lock_(other.lock_),
- data_(other.data_),
+ : data_(other.data_),
length_(other.length_) {}
// The no_gc argument is only here because of the templated way this class
@@ -134,7 +105,6 @@ class ExternalStringStream {
static const bool kCanAccessHeap = false;
private:
- ScopedExternalStringLock lock_;
const Char* const data_;
const size_t length_;
};
--
2.17.2 (Apple Git-113)