Skip to content

Commit d50e1ff

Browse files
committedSep 3, 2018
deps: backport String::Write{OneByte,Utf8} with isolate
These overloads were added in V8 6.9 and the ones without the isolate parameter were removed in V8 7.0. Refs: v8/v8@8a011b5 PR-URL: #22531 Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Daniel Bevenius <[email protected]> Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: James M Snell <[email protected]>
1 parent 9478f29 commit d50e1ff

File tree

3 files changed

+46
-25
lines changed

3 files changed

+46
-25
lines changed
 

‎common.gypi

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929

3030
# Reset this number to 0 on major V8 upgrades.
3131
# Increment by one for each non-official patch applied to deps/v8.
32-
'v8_embedder_string': '-node.20',
32+
'v8_embedder_string': '-node.21',
3333

3434
# Enable disassembler for `--print-code` v8 options
3535
'v8_enable_disassembler': 1,

‎deps/v8/include/v8.h

+16-11
Original file line numberDiff line numberDiff line change
@@ -2634,20 +2634,25 @@ class V8_EXPORT String : public Name {
26342634
};
26352635

26362636
// 16-bit character codes.
2637-
int Write(uint16_t* buffer,
2638-
int start = 0,
2639-
int length = -1,
2637+
int Write(Isolate* isolate, uint16_t* buffer, int start = 0, int length = -1,
26402638
int options = NO_OPTIONS) const;
2639+
V8_DEPRECATE_SOON("Use Isolate* version",
2640+
int Write(uint16_t* buffer, int start = 0, int length = -1,
2641+
int options = NO_OPTIONS) const);
26412642
// One byte characters.
2642-
int WriteOneByte(uint8_t* buffer,
2643-
int start = 0,
2644-
int length = -1,
2645-
int options = NO_OPTIONS) const;
2643+
int WriteOneByte(Isolate* isolate, uint8_t* buffer, int start = 0,
2644+
int length = -1, int options = NO_OPTIONS) const;
2645+
V8_DEPRECATE_SOON("Use Isolate* version",
2646+
int WriteOneByte(uint8_t* buffer, int start = 0,
2647+
int length = -1, int options = NO_OPTIONS)
2648+
const);
26462649
// UTF-8 encoded characters.
2647-
int WriteUtf8(char* buffer,
2648-
int length = -1,
2649-
int* nchars_ref = NULL,
2650-
int options = NO_OPTIONS) const;
2650+
int WriteUtf8(Isolate* isolate, char* buffer, int length = -1,
2651+
int* nchars_ref = NULL, int options = NO_OPTIONS) const;
2652+
V8_DEPRECATE_SOON("Use Isolate* version",
2653+
int WriteUtf8(char* buffer, int length = -1,
2654+
int* nchars_ref = NULL,
2655+
int options = NO_OPTIONS) const);
26512656

26522657
/**
26532658
* A zero length string.

‎deps/v8/src/api.cc

+29-13
Original file line numberDiff line numberDiff line change
@@ -5702,12 +5702,10 @@ static bool RecursivelySerializeToUtf8(i::String* current,
57025702
}
57035703

57045704

5705-
int String::WriteUtf8(char* buffer,
5706-
int capacity,
5707-
int* nchars_ref,
5708-
int options) const {
5705+
int String::WriteUtf8(Isolate* v8_isolate, char* buffer, int capacity,
5706+
int* nchars_ref, int options) const {
57095707
i::Handle<i::String> str = Utils::OpenHandle(this);
5710-
i::Isolate* isolate = str->GetIsolate();
5708+
i::Isolate* isolate = reinterpret_cast<i::Isolate*>(v8_isolate);
57115709
LOG_API(isolate, String, WriteUtf8);
57125710
ENTER_V8_NO_SCRIPT_NO_EXCEPTION(isolate);
57135711
str = i::String::Flatten(str); // Flatten the string for efficiency.
@@ -5748,14 +5746,18 @@ int String::WriteUtf8(char* buffer,
57485746
return writer.CompleteWrite(write_null, nchars_ref);
57495747
}
57505748

5749+
int String::WriteUtf8(char* buffer, int capacity, int* nchars_ref,
5750+
int options) const {
5751+
i::Handle<i::String> str = Utils::OpenHandle(this);
5752+
i::Isolate* isolate = str->GetIsolate();
5753+
return WriteUtf8(reinterpret_cast<Isolate*>(isolate), buffer, capacity,
5754+
nchars_ref, options);
5755+
}
57515756

5752-
template<typename CharType>
5753-
static inline int WriteHelper(const String* string,
5754-
CharType* buffer,
5755-
int start,
5756-
int length,
5757+
template <typename CharType>
5758+
static inline int WriteHelper(i::Isolate* isolate, const String* string,
5759+
CharType* buffer, int start, int length,
57575760
int options) {
5758-
i::Isolate* isolate = Utils::OpenHandle(string)->GetIsolate();
57595761
LOG_API(isolate, String, Write);
57605762
ENTER_V8_NO_SCRIPT_NO_EXCEPTION(isolate);
57615763
DCHECK(start >= 0 && length >= -1);
@@ -5778,15 +5780,29 @@ int String::WriteOneByte(uint8_t* buffer,
57785780
int start,
57795781
int length,
57805782
int options) const {
5781-
return WriteHelper(this, buffer, start, length, options);
5783+
i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
5784+
return WriteHelper(isolate, this, buffer, start, length, options);
5785+
}
5786+
5787+
int String::WriteOneByte(Isolate* isolate, uint8_t* buffer, int start,
5788+
int length, int options) const {
5789+
return WriteHelper(reinterpret_cast<i::Isolate*>(isolate), this, buffer,
5790+
start, length, options);
57825791
}
57835792

57845793

57855794
int String::Write(uint16_t* buffer,
57865795
int start,
57875796
int length,
57885797
int options) const {
5789-
return WriteHelper(this, buffer, start, length, options);
5798+
i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
5799+
return WriteHelper(isolate, this, buffer, start, length, options);
5800+
}
5801+
5802+
int String::Write(Isolate* isolate, uint16_t* buffer, int start, int length,
5803+
int options) const {
5804+
return WriteHelper(reinterpret_cast<i::Isolate*>(isolate), this, buffer,
5805+
start, length, options);
57905806
}
57915807

57925808

0 commit comments

Comments
 (0)