[GetIsolate] Remove GetIsolate from String in src/objects.cc

Bug: v8:7786
Cq-Include-Trybots: luci.chromium.try:linux_chromium_rel_ng;luci.v8.try:v8_linux_noi18n_rel_ng
Change-Id: I98ac4de406630c14280927240e9471049af3e790
Reviewed-on: https://chromium-review.googlesource.com/1108118
Reviewed-by: Jakob Gruber <jgruber@chromium.org>
Reviewed-by: Toon Verwaest <verwaest@chromium.org>
Reviewed-by: Michael Starzinger <mstarzinger@chromium.org>
Commit-Queue: Leszek Swirski <leszeks@chromium.org>
Cr-Commit-Position: refs/heads/master@{#53920}
This commit is contained in:
Leszek Swirski 2018-06-20 17:32:59 +01:00 committed by Commit Bot
parent 9587d2ca31
commit b8cf9627b9
49 changed files with 266 additions and 227 deletions

View File

@ -46,11 +46,11 @@ Handle<AccessorInfo> Accessors::MakeAccessor(
return info;
}
static V8_INLINE bool CheckForName(Handle<Name> name,
static V8_INLINE bool CheckForName(Isolate* isolate, Handle<Name> name,
Handle<String> property_name, int offset,
FieldIndex::Encoding encoding,
FieldIndex* index) {
if (Name::Equals(name, property_name)) {
if (Name::Equals(isolate, name, property_name)) {
*index = FieldIndex::ForInObjectOffset(offset, encoding);
return true;
}
@ -64,11 +64,11 @@ bool Accessors::IsJSObjectFieldAccessor(Isolate* isolate, Handle<Map> map,
Handle<Name> name, FieldIndex* index) {
switch (map->instance_type()) {
case JS_ARRAY_TYPE:
return CheckForName(name, isolate->factory()->length_string(),
return CheckForName(isolate, name, isolate->factory()->length_string(),
JSArray::kLengthOffset, FieldIndex::kTagged, index);
default:
if (map->instance_type() < FIRST_NONSTRING_TYPE) {
return CheckForName(name, isolate->factory()->length_string(),
return CheckForName(isolate, name, isolate->factory()->length_string(),
String::kLengthOffset, FieldIndex::kTagged, index);
}

View File

@ -3136,7 +3136,7 @@ bool StackFrame::IsWasm() const { return Utils::OpenHandle(this)->is_wasm(); }
MaybeLocal<Value> JSON::Parse(Isolate* v8_isolate, Local<String> json_string) {
PREPARE_FOR_EXECUTION(v8_isolate->GetCurrentContext(), JSON, Parse, Value);
i::Handle<i::String> string = Utils::OpenHandle(*json_string);
i::Handle<i::String> source = i::String::Flatten(string);
i::Handle<i::String> source = i::String::Flatten(isolate, string);
i::Handle<i::Object> undefined = isolate->factory()->undefined_value();
auto maybe = source->IsSeqOneByteString()
? i::JsonParser<true>::Parse(isolate, source, undefined)
@ -3151,7 +3151,7 @@ MaybeLocal<Value> JSON::Parse(Local<Context> context,
Local<String> json_string) {
PREPARE_FOR_EXECUTION(context, JSON, Parse, Value);
i::Handle<i::String> string = Utils::OpenHandle(*json_string);
i::Handle<i::String> source = i::String::Flatten(string);
i::Handle<i::String> source = i::String::Flatten(isolate, string);
i::Handle<i::Object> undefined = isolate->factory()->undefined_value();
auto maybe = source->IsSeqOneByteString()
? i::JsonParser<true>::Parse(isolate, source, undefined)
@ -3585,7 +3585,10 @@ bool Value::IsBoolean() const {
bool Value::IsExternal() const {
return Utils::OpenHandle(this)->IsExternal();
i::Handle<i::Object> obj = Utils::OpenHandle(this);
if (!obj->IsHeapObject()) return false;
i::Handle<i::HeapObject> heap_obj = i::Handle<i::HeapObject>::cast(obj);
return heap_obj->IsExternal(heap_obj->GetIsolate());
}
@ -3798,7 +3801,7 @@ void i::Internals::CheckInitializedImpl(v8::Isolate* external_isolate) {
void External::CheckCast(v8::Value* that) {
Utils::ApiCheck(Utils::OpenHandle(that)->IsExternal(), "v8::External::Cast",
Utils::ApiCheck(that->IsExternal(), "v8::External::Cast",
"Could not convert to external");
}
@ -5510,10 +5513,10 @@ bool String::ContainsOnlyOneByte() const {
return helper.Check(*str);
}
// TODO(v8:7786): Deprecate this function and pass the isolate in instead.
int String::Utf8Length() const {
i::Handle<i::String> str = Utils::OpenHandle(this);
str = i::String::Flatten(str);
str = i::String::Flatten(str->GetIsolate(), str);
int length = str->length();
if (length == 0) return 0;
i::DisallowHeapAllocation no_gc;
@ -5744,7 +5747,7 @@ int String::WriteUtf8(char* buffer,
i::Isolate* isolate = str->GetIsolate();
LOG_API(isolate, String, WriteUtf8);
ENTER_V8_NO_SCRIPT_NO_EXCEPTION(isolate);
str = i::String::Flatten(str); // Flatten the string for efficiency.
str = i::String::Flatten(isolate, str); // Flatten the string for efficiency.
const int string_length = str->length();
bool write_null = !(options & NO_NULL_TERMINATION);
bool replace_invalid_utf8 = (options & REPLACE_INVALID_UTF8);
@ -5794,7 +5797,7 @@ static inline int WriteHelper(const String* string,
ENTER_V8_NO_SCRIPT_NO_EXCEPTION(isolate);
DCHECK(start >= 0 && length >= -1);
i::Handle<i::String> str = Utils::OpenHandle(string);
str = i::String::Flatten(str);
str = i::String::Flatten(isolate, str);
int end = start + length;
if ((length == -1) || (length > str->length() - start) )
end = str->length();

View File

@ -1474,11 +1474,11 @@ Scope* Scope::GetOuterScopeWithContext() {
}
Handle<StringSet> DeclarationScope::CollectNonLocals(
ParseInfo* info, Handle<StringSet> non_locals) {
Isolate* isolate, ParseInfo* info, Handle<StringSet> non_locals) {
VariableProxy* free_variables = FetchFreeVariables(this, info);
for (VariableProxy* proxy = free_variables; proxy != nullptr;
proxy = proxy->next_unresolved()) {
non_locals = StringSet::Add(non_locals, proxy->name());
non_locals = StringSet::Add(isolate, non_locals, proxy->name());
}
return non_locals;
}

View File

@ -869,7 +869,7 @@ class V8_EXPORT_PRIVATE DeclarationScope : public Scope {
// Does nothing if ScopeInfo is already allocated.
static void AllocateScopeInfos(ParseInfo* info, Isolate* isolate);
Handle<StringSet> CollectNonLocals(ParseInfo* info,
Handle<StringSet> CollectNonLocals(Isolate* isolate, ParseInfo* info,
Handle<StringSet> non_locals);
// Determine if we can use lazy compilation for this scope.

View File

@ -105,7 +105,7 @@ const char* kShortMonths[] = {"Jan", "Feb", "Mar", "Apr", "May", "Jun",
// ES6 section 20.3.1.16 Date Time String Format
double ParseDateTimeString(Isolate* isolate, Handle<String> str) {
str = String::Flatten(str);
str = String::Flatten(isolate, str);
// TODO(bmeurer): Change DateParser to not use the FixedArray.
Handle<FixedArray> tmp =
isolate->factory()->NewFixedArray(DateParser::OUTPUT_SIZE);

View File

@ -53,7 +53,7 @@ MaybeHandle<Object> CreateDynamicFunction(Isolate* isolate,
Handle<String> param;
ASSIGN_RETURN_ON_EXCEPTION(
isolate, param, Object::ToString(isolate, args.at(i)), Object);
param = String::Flatten(param);
param = String::Flatten(isolate, param);
builder.AppendString(param);
if (!FLAG_harmony_function_tostring) {
// If the formal parameters string include ) - an illegal

View File

@ -33,7 +33,7 @@ namespace internal {
BUILTIN(StringPrototypeToUpperCaseIntl) {
HandleScope scope(isolate);
TO_THIS_STRING(string, "String.prototype.toUpperCase");
string = String::Flatten(string);
string = String::Flatten(isolate, string);
return ConvertCase(string, true, isolate);
}
@ -53,16 +53,19 @@ BUILTIN(StringPrototypeNormalizeIntl) {
ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, form,
Object::ToString(isolate, form_input));
if (String::Equals(form, isolate->factory()->NFC_string())) {
if (String::Equals(isolate, form, isolate->factory()->NFC_string())) {
form_name = "nfc";
form_mode = UNORM2_COMPOSE;
} else if (String::Equals(form, isolate->factory()->NFD_string())) {
} else if (String::Equals(isolate, form,
isolate->factory()->NFD_string())) {
form_name = "nfc";
form_mode = UNORM2_DECOMPOSE;
} else if (String::Equals(form, isolate->factory()->NFKC_string())) {
} else if (String::Equals(isolate, form,
isolate->factory()->NFKC_string())) {
form_name = "nfkc";
form_mode = UNORM2_COMPOSE;
} else if (String::Equals(form, isolate->factory()->NFKD_string())) {
} else if (String::Equals(isolate, form,
isolate->factory()->NFKD_string())) {
form_name = "nfkc";
form_mode = UNORM2_DECOMPOSE;
} else {
@ -75,7 +78,7 @@ BUILTIN(StringPrototypeNormalizeIntl) {
}
int length = string->length();
string = String::Flatten(string);
string = String::Flatten(isolate, string);
icu::UnicodeString result;
std::unique_ptr<uc16[]> sap;
UErrorCode status = U_ZERO_ERROR;

View File

@ -21,7 +21,7 @@ BUILTIN(JsonParse) {
Handle<String> string;
ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, string,
Object::ToString(isolate, source));
string = String::Flatten(string);
string = String::Flatten(isolate, string);
RETURN_RESULT_OR_FAILURE(
isolate, string->IsSeqOneByteString()
? JsonParser<true>::Parse(isolate, string, reviver)

View File

@ -148,8 +148,8 @@ BUILTIN(StringPrototypeEndsWith) {
int start = end - search_string->length();
if (start < 0) return isolate->heap()->false_value();
str = String::Flatten(str);
search_string = String::Flatten(search_string);
str = String::Flatten(isolate, str);
search_string = String::Flatten(isolate, search_string);
DisallowHeapAllocation no_gc; // ensure vectors stay valid
String::FlatContent str_content = str->GetFlatContent();
@ -219,8 +219,8 @@ BUILTIN(StringPrototypeLocaleCompare) {
int d = str1->Get(0) - str2->Get(0);
if (d != 0) return Smi::FromInt(d);
str1 = String::Flatten(str1);
str2 = String::Flatten(str2);
str1 = String::Flatten(isolate, str1);
str2 = String::Flatten(isolate, str2);
DisallowHeapAllocation no_gc;
String::FlatContent flat1 = str1->GetFlatContent();
@ -252,13 +252,13 @@ BUILTIN(StringPrototypeNormalize) {
ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, form,
Object::ToString(isolate, form_input));
if (!(String::Equals(form,
if (!(String::Equals(isolate, form,
isolate->factory()->NewStringFromStaticChars("NFC")) ||
String::Equals(form,
String::Equals(isolate, form,
isolate->factory()->NewStringFromStaticChars("NFD")) ||
String::Equals(form,
String::Equals(isolate, form,
isolate->factory()->NewStringFromStaticChars("NFKC")) ||
String::Equals(form,
String::Equals(isolate, form,
isolate->factory()->NewStringFromStaticChars("NFKD")))) {
Handle<String> valid_forms =
isolate->factory()->NewStringFromStaticChars("NFC, NFD, NFKC, NFKD");
@ -307,8 +307,9 @@ BUILTIN(StringPrototypeStartsWith) {
return isolate->heap()->false_value();
}
FlatStringReader str_reader(isolate, String::Flatten(str));
FlatStringReader search_reader(isolate, String::Flatten(search_string));
FlatStringReader str_reader(isolate, String::Flatten(isolate, str));
FlatStringReader search_reader(isolate,
String::Flatten(isolate, search_string));
for (int i = 0; i < search_string->length(); i++) {
if (str_reader.Get(start + i) != search_reader.Get(i)) {
@ -430,7 +431,7 @@ template <class Converter>
V8_WARN_UNUSED_RESULT static Object* ConvertCase(
Handle<String> s, Isolate* isolate,
unibrow::Mapping<Converter, 128>* mapping) {
s = String::Flatten(s);
s = String::Flatten(isolate, s);
int length = s->length();
// Assume that the string is not empty; we need this assumption later
if (length == 0) return *s;

View File

@ -115,7 +115,7 @@ bool CompilationCacheScript::HasOrigin(Handle<SharedFunctionInfo> function_info,
if (resource_options.Flags() != script->origin_options().Flags())
return false;
// Compare the two name strings for equality.
return String::Equals(Handle<String>::cast(name),
return String::Equals(isolate(), Handle<String>::cast(name),
Handle<String>(String::cast(script->name())));
}

View File

@ -129,7 +129,7 @@ void UnoptimizedCompileJob::PrepareOnMainThread(Isolate* isolate) {
source, shared_->StartPosition(), shared_->EndPosition()));
parse_info_->set_character_stream(std::move(stream));
} else {
source = String::Flatten(source);
source = String::Flatten(isolate, source);
const void* data;
int offset = 0;
int length = source->length();

View File

@ -629,13 +629,13 @@ bool AccessInfoFactory::LookupSpecialFieldAccessor(
Type field_type = Type::NonInternal();
MachineRepresentation field_representation = MachineRepresentation::kTagged;
if (map->IsStringMap()) {
DCHECK(Name::Equals(factory()->length_string(), name));
DCHECK(Name::Equals(isolate(), factory()->length_string(), name));
// The String::length property is always a smi in the range
// [0, String::kMaxLength].
field_type = type_cache_.kStringLengthType;
field_representation = MachineRepresentation::kTaggedSigned;
} else if (map->IsJSArrayMap()) {
DCHECK(Name::Equals(factory()->length_string(), name));
DCHECK(Name::Equals(isolate(), factory()->length_string(), name));
// The JSArray::length property is a smi in the range
// [0, FixedDoubleArray::kMaxLength] in case of fast double
// elements, a smi in the range [0, FixedArray::kMaxLength]

View File

@ -976,7 +976,7 @@ Reduction JSTypedLowering::ReduceJSToNumberOrNumericInput(Node* input) {
if (m.HasValue() && m.Value()->IsString()) {
Handle<Object> input_value = m.Value();
return Replace(jsgraph()->Constant(
String::ToNumber(Handle<String>::cast(input_value))));
String::ToNumber(isolate(), Handle<String>::cast(input_value))));
}
}
if (input_type.IsHeapConstant()) {

View File

@ -941,7 +941,7 @@ class StringToBigIntHelper : public StringToIntHelper {
};
MaybeHandle<BigInt> StringToBigInt(Isolate* isolate, Handle<String> string) {
string = String::Flatten(string);
string = String::Flatten(isolate, string);
StringToBigIntHelper helper(isolate, string);
return helper.GetResult();
}
@ -1330,9 +1330,10 @@ char* DoubleToRadixCString(double value, int radix) {
// ES6 18.2.4 parseFloat(string)
double StringToDouble(UnicodeCache* unicode_cache, Handle<String> string,
int flags, double empty_string_val) {
Handle<String> flattened = String::Flatten(string);
double StringToDouble(Isolate* isolate, UnicodeCache* unicode_cache,
Handle<String> string, int flags,
double empty_string_val) {
Handle<String> flattened = String::Flatten(isolate, string);
{
DisallowHeapAllocation no_gc;
String::FlatContent flat = flattened->GetFlatContent();

View File

@ -170,8 +170,9 @@ inline uint32_t NumberToUint32(Object* number);
inline int64_t NumberToInt64(Object* number);
inline uint64_t PositiveNumberToUint64(Object* number);
double StringToDouble(UnicodeCache* unicode_cache, Handle<String> string,
int flags, double empty_string_val = 0.0);
double StringToDouble(Isolate* isolate, UnicodeCache* unicode_cache,
Handle<String> string, int flags,
double empty_string_val = 0.0);
inline bool TryNumberToSize(Object* number, size_t* result);

View File

@ -146,7 +146,7 @@ void ScopeIterator::TryParseAndRetrieveScopes(ScopeIterator::Option option) {
if (option == COLLECT_NON_LOCALS) {
DCHECK(non_locals_.is_null());
non_locals_ = info_->literal()->scope()->CollectNonLocals(
info_, StringSet::New(isolate_));
isolate_, info_, StringSet::New(isolate_));
}
CHECK(DeclarationScope::Analyze(info_));
@ -771,7 +771,7 @@ bool ScopeIterator::SetLocalVariableValue(Handle<String> variable_name,
// TODO(verwaest): Walk parameters backwards, not forwards.
// TODO(verwaest): Use VariableMap rather than locals() list for lookup.
for (Variable* var : *current_scope_->locals()) {
if (String::Equals(var->name(), variable_name)) {
if (String::Equals(isolate_, var->name(), variable_name)) {
int index = var->index();
switch (var->location()) {
case VariableLocation::LOOKUP:

View File

@ -419,10 +419,9 @@ class TokensCompareOutput : public Comparator::Output {
// never has terminating new line character.
class LineEndsWrapper {
public:
explicit LineEndsWrapper(Handle<String> string)
: ends_array_(String::CalculateLineEnds(string, false)),
string_len_(string->length()) {
}
explicit LineEndsWrapper(Isolate* isolate, Handle<String> string)
: ends_array_(String::CalculateLineEnds(isolate, string, false)),
string_len_(string->length()) {}
int length() {
return ends_array_->length() + 1;
}
@ -1568,11 +1567,11 @@ Handle<Object> LiveEditFunctionTracker::SerializeFunctionScope(Scope* scope) {
void LiveEdit::CompareStrings(Isolate* isolate, Handle<String> s1,
Handle<String> s2,
std::vector<SourceChangeRange>* changes) {
s1 = String::Flatten(s1);
s2 = String::Flatten(s2);
s1 = String::Flatten(isolate, s1);
s2 = String::Flatten(isolate, s2);
LineEndsWrapper line_ends1(s1);
LineEndsWrapper line_ends2(s2);
LineEndsWrapper line_ends1(isolate, s1);
LineEndsWrapper line_ends2(isolate, s2);
LineArrayCompareInput input(s1, s2, line_ends1, line_ends2);
TokenizingLineArrayCompareOutput output(isolate, line_ends1, line_ends2, s1,

View File

@ -4184,7 +4184,7 @@ class StringWrapperElementsAccessor
uint32_t length = static_cast<uint32_t>(string->length());
if (entry < length) {
return isolate->factory()->LookupSingleCharacterStringFromCode(
String::Flatten(string)->Get(entry));
String::Flatten(isolate, string)->Get(entry));
}
return BackingStoreAccessor::GetImpl(isolate, holder->elements(),
entry - length);
@ -4266,7 +4266,7 @@ class StringWrapperElementsAccessor
AddKeyConversion convert) {
Isolate* isolate = receiver->GetIsolate();
Handle<String> string(GetString(*receiver), isolate);
string = String::Flatten(string);
string = String::Flatten(isolate, string);
uint32_t length = static_cast<uint32_t>(string->length());
for (uint32_t i = 0; i < length; i++) {
accumulator->AddKey(

View File

@ -1167,7 +1167,7 @@ Handle<String> Factory::NewProperSubString(Handle<String> str, int begin,
#endif
DCHECK(begin > 0 || end < str->length());
str = String::Flatten(str);
str = String::Flatten(isolate(), str);
int length = end - begin;
if (length <= 0) return empty_string();
@ -1301,7 +1301,7 @@ Handle<ExternalOneByteString> Factory::NewNativeSourceString(
Handle<JSStringIterator> Factory::NewJSStringIterator(Handle<String> string) {
Handle<Map> map(isolate()->native_context()->string_iterator_map(),
isolate());
Handle<String> flat_string = String::Flatten(string);
Handle<String> flat_string = String::Flatten(isolate(), string);
Handle<JSStringIterator> iterator =
Handle<JSStringIterator>::cast(NewJSObjectFromMap(map));
iterator->set_string(*flat_string);
@ -3374,7 +3374,7 @@ Handle<SharedFunctionInfo> Factory::NewSharedFunctionInfo(
Handle<String> shared_name;
bool has_shared_name = maybe_name.ToHandle(&shared_name);
if (has_shared_name) {
shared_name = String::Flatten(shared_name, TENURED);
shared_name = String::Flatten(isolate(), shared_name, TENURED);
}
Handle<Map> map = shared_function_info_map();
@ -3742,9 +3742,11 @@ Handle<RegExpMatchInfo> Factory::NewRegExpMatchInfo() {
}
Handle<Object> Factory::GlobalConstantFor(Handle<Name> name) {
if (Name::Equals(name, undefined_string())) return undefined_value();
if (Name::Equals(name, NaN_string())) return nan_value();
if (Name::Equals(name, Infinity_string())) return infinity_value();
if (Name::Equals(isolate(), name, undefined_string())) {
return undefined_value();
}
if (Name::Equals(isolate(), name, NaN_string())) return nan_value();
if (Name::Equals(isolate(), name, Infinity_string())) return infinity_value();
return Handle<Object>::null();
}

View File

@ -143,7 +143,7 @@ JsonParser<seq_one_byte>::JsonParser(Isolate* isolate, Handle<String> source)
isolate_),
position_(-1),
properties_(&zone_) {
source_ = String::Flatten(source_);
source_ = String::Flatten(isolate, source_);
pretenure_ = (source_length_ >= kPretenureTreshold) ? TENURED : NOT_TENURED;
// Optimized fast case where we only have Latin1 characters.

View File

@ -704,7 +704,7 @@ void JsonStringifier::SerializeDeferredKey(bool deferred_comma,
}
void JsonStringifier::SerializeString(Handle<String> object) {
object = String::Flatten(object);
object = String::Flatten(isolate_, object);
if (builder_.CurrentEncoding() == String::ONE_BYTE_ENCODING) {
if (object->IsOneByteRepresentationUnderneath()) {
SerializeString_<uint8_t, uint8_t>(object);

View File

@ -769,11 +769,17 @@ Handle<FixedArray> KeyAccumulator::GetOwnEnumPropertyKeys(
namespace {
struct NameComparator {
class NameComparator {
public:
explicit NameComparator(Isolate* isolate) : isolate_(isolate) {}
bool operator()(uint32_t hash1, uint32_t hash2, const Handle<Name>& key1,
const Handle<Name>& key2) const {
return Name::Equals(key1, key2);
return Name::Equals(isolate_, key1, key2);
}
private:
Isolate* isolate_;
};
} // namespace
@ -872,7 +878,7 @@ Maybe<bool> KeyAccumulator::CollectOwnJSProxyKeys(Handle<JSReceiver> receiver,
base::TemplateHashMapImpl<Handle<Name>, int, NameComparator,
ZoneAllocationPolicy>
unchecked_result_keys(ZoneHashMap::kDefaultHashMapCapacity,
NameComparator(), alloc);
NameComparator(isolate_), alloc);
int unchecked_result_keys_size = 0;
for (int i = 0; i < trap_result->length(); ++i) {
Handle<Name> key(Name::cast(trap_result->get(i)), isolate_);

View File

@ -525,10 +525,10 @@ int StringIndexOf(Isolate* isolate, Handle<String> subject,
// 2. subject == pattern.
bool StringEndsWithMethodName(Isolate* isolate, Handle<String> subject,
Handle<String> pattern) {
if (String::Equals(subject, pattern)) return true;
if (String::Equals(isolate, subject, pattern)) return true;
FlatStringReader subject_reader(isolate, String::Flatten(subject));
FlatStringReader pattern_reader(isolate, String::Flatten(pattern));
FlatStringReader subject_reader(isolate, String::Flatten(isolate, subject));
FlatStringReader pattern_reader(isolate, String::Flatten(isolate, pattern));
int pattern_index = pattern_reader.length() - 1;
int subject_index = subject_reader.length() - 1;
@ -1041,7 +1041,7 @@ Handle<String> MessageTemplate::FormatMessage(Isolate* isolate,
// here to improve the efficiency of converting it to a C string and
// other operations that are likely to take place (see GetLocalizedMessage
// for example).
return String::Flatten(result_string);
return String::Flatten(isolate, result_string);
}

View File

@ -184,8 +184,8 @@ bool HeapObject::IsJSGeneratorObject() const {
bool HeapObject::IsClassBoilerplate() const { return IsFixedArrayExact(); }
bool HeapObject::IsExternal() const {
return map()->FindRootMap() == GetHeap()->external_map();
bool HeapObject::IsExternal(Isolate* isolate) const {
return map()->FindRootMap() == isolate->heap()->external_map();
}
#define IS_TYPE_FUNCTION_DEF(type_) \

View File

@ -196,7 +196,7 @@ MaybeHandle<Object> Object::ConvertToNumberOrNumeric(Isolate* isolate,
return input;
}
if (input->IsString()) {
return String::ToNumber(Handle<String>::cast(input));
return String::ToNumber(isolate, Handle<String>::cast(input));
}
if (input->IsOddball()) {
return Oddball::ToNumber(Handle<Oddball>::cast(input));
@ -559,8 +559,8 @@ Maybe<ComparisonResult> Object::Compare(Isolate* isolate, Handle<Object> x,
}
if (x->IsString() && y->IsString()) {
// ES6 section 7.2.11 Abstract Relational Comparison step 5.
return Just(
String::Compare(Handle<String>::cast(x), Handle<String>::cast(y)));
return Just(String::Compare(isolate, Handle<String>::cast(x),
Handle<String>::cast(y)));
}
if (x->IsBigInt() && y->IsString()) {
return Just(BigInt::CompareToString(isolate, Handle<BigInt>::cast(x),
@ -603,7 +603,8 @@ Maybe<bool> Object::Equals(Isolate* isolate, Handle<Object> x,
} else if (y->IsBoolean()) {
return Just(NumberEquals(*x, Handle<Oddball>::cast(y)->to_number()));
} else if (y->IsString()) {
return Just(NumberEquals(x, String::ToNumber(Handle<String>::cast(y))));
return Just(NumberEquals(
x, String::ToNumber(isolate, Handle<String>::cast(y))));
} else if (y->IsBigInt()) {
return Just(BigInt::EqualToNumber(Handle<BigInt>::cast(y), x));
} else if (y->IsJSReceiver()) {
@ -616,13 +617,13 @@ Maybe<bool> Object::Equals(Isolate* isolate, Handle<Object> x,
}
} else if (x->IsString()) {
if (y->IsString()) {
return Just(
String::Equals(Handle<String>::cast(x), Handle<String>::cast(y)));
return Just(String::Equals(isolate, Handle<String>::cast(x),
Handle<String>::cast(y)));
} else if (y->IsNumber()) {
x = String::ToNumber(Handle<String>::cast(x));
x = String::ToNumber(isolate, Handle<String>::cast(x));
return Just(NumberEquals(x, y));
} else if (y->IsBoolean()) {
x = String::ToNumber(Handle<String>::cast(x));
x = String::ToNumber(isolate, Handle<String>::cast(x));
return Just(NumberEquals(*x, Handle<Oddball>::cast(y)->to_number()));
} else if (y->IsBigInt()) {
return Just(BigInt::EqualToString(isolate, Handle<BigInt>::cast(y),
@ -641,7 +642,7 @@ Maybe<bool> Object::Equals(Isolate* isolate, Handle<Object> x,
} else if (y->IsNumber()) {
return Just(NumberEquals(Handle<Oddball>::cast(x)->to_number(), *y));
} else if (y->IsString()) {
y = String::ToNumber(Handle<String>::cast(y));
y = String::ToNumber(isolate, Handle<String>::cast(y));
return Just(NumberEquals(Handle<Oddball>::cast(x)->to_number(), *y));
} else if (y->IsBigInt()) {
x = Oddball::ToNumber(Handle<Oddball>::cast(x));
@ -2512,7 +2513,7 @@ void Smi::SmiPrint(std::ostream& os) const { // NOLINT
os << value();
}
Handle<String> String::SlowFlatten(Handle<ConsString> cons,
Handle<String> String::SlowFlatten(Isolate* isolate, Handle<ConsString> cons,
PretenureFlag pretenure) {
DCHECK_NE(cons->second()->length(), 0);
@ -2522,14 +2523,13 @@ Handle<String> String::SlowFlatten(Handle<ConsString> cons,
// String::Flatten only in those cases where String::SlowFlatten is not
// called again.
if (cons->second()->IsConsString() && !cons->second()->IsFlat()) {
cons = handle(ConsString::cast(cons->second()));
cons = handle(ConsString::cast(cons->second()), isolate);
} else {
return String::Flatten(handle(cons->second()));
return String::Flatten(isolate, handle(cons->second(), isolate));
}
}
DCHECK(AllowHeapAllocation::IsAllowed());
Isolate* isolate = cons->GetIsolate();
int length = cons->length();
PretenureFlag tenure = isolate->heap()->InNewSpace(*cons) ? pretenure
: TENURED;
@ -3734,7 +3734,7 @@ Handle<String> JSReceiver::GetConstructorName(Handle<JSReceiver> receiver) {
Handle<Context> JSReceiver::GetCreationContext() {
JSReceiver* receiver = this;
// Externals are JSObjects with null as a constructor.
DCHECK(!receiver->IsExternal());
DCHECK(!receiver->IsExternal(GetIsolate()));
Object* constructor = receiver->map()->GetConstructor();
JSFunction* function;
if (constructor->IsJSFunction()) {
@ -10621,9 +10621,9 @@ bool DescriptorArray::IsEqualTo(DescriptorArray* other) {
#endif
// static
Handle<String> String::Trim(Handle<String> string, TrimMode mode) {
Isolate* const isolate = string->GetIsolate();
string = String::Flatten(string);
Handle<String> String::Trim(Isolate* isolate, Handle<String> string,
TrimMode mode) {
string = String::Flatten(isolate, string);
int const length = string->length();
// Perform left trimming if requested.
@ -10649,7 +10649,15 @@ Handle<String> String::Trim(Handle<String> string, TrimMode mode) {
return isolate->factory()->NewSubString(string, left, right);
}
bool String::LooksValid() { return GetIsolate()->heap()->Contains(this); }
bool String::LooksValid() {
// TODO(leszeks): Maybe remove this check entirely, Heap::Contains uses
// basically the same logic as the way we access the heap in the first place.
MemoryChunk* chunk = MemoryChunk::FromHeapObject(this);
// RO_SPACE objects should always be valid.
if (chunk->owner()->identity() == RO_SPACE) return true;
if (chunk->heap() == nullptr) return false;
return chunk->heap()->Contains(this);
}
// static
MaybeHandle<String> Name::ToFunctionName(Handle<Name> name) {
@ -10707,11 +10715,9 @@ int ParseDecimalInteger(const uint8_t* s, int from, int to) {
} // namespace
// static
Handle<Object> String::ToNumber(Handle<String> subject) {
Isolate* const isolate = subject->GetIsolate();
Handle<Object> String::ToNumber(Isolate* isolate, Handle<String> subject) {
// Flatten {subject} string first.
subject = String::Flatten(subject);
subject = String::Flatten(isolate, subject);
// Fast array index case.
uint32_t index;
@ -10765,7 +10771,7 @@ Handle<Object> String::ToNumber(Handle<String> subject) {
// Slower case.
int flags = ALLOW_HEX | ALLOW_OCTAL | ALLOW_BINARY;
return isolate->factory()->NewNumber(
StringToDouble(isolate->unicode_cache(), subject, flags));
StringToDouble(isolate, isolate->unicode_cache(), subject, flags));
}
@ -11266,16 +11272,15 @@ static void CalculateLineEndsImpl(Isolate* isolate, std::vector<int>* line_ends,
}
}
Handle<FixedArray> String::CalculateLineEnds(Handle<String> src,
Handle<FixedArray> String::CalculateLineEnds(Isolate* isolate,
Handle<String> src,
bool include_ending_line) {
src = Flatten(src);
src = Flatten(isolate, src);
// Rough estimate of line count based on a roughly estimated average
// length of (unpacked) code.
int line_count_estimate = src->length() >> 4;
std::vector<int> line_ends;
line_ends.reserve(line_count_estimate);
Isolate* isolate = src->GetIsolate();
{ DisallowHeapAllocation no_allocation; // ensure vectors stay valid.
// Dispatch on type of strings.
String::FlatContent content = src->GetFlatContent();
@ -11504,8 +11509,8 @@ bool String::SlowEquals(String* other) {
return comparator.Equals(this, other);
}
bool String::SlowEquals(Handle<String> one, Handle<String> two) {
bool String::SlowEquals(Isolate* isolate, Handle<String> one,
Handle<String> two) {
// Fast check: negative check with lengths.
int one_length = one->length();
if (one_length != two->length()) return false;
@ -11514,9 +11519,11 @@ bool String::SlowEquals(Handle<String> one, Handle<String> two) {
// Fast check: if at least one ThinString is involved, dereference it/them
// and restart.
if (one->IsThinString() || two->IsThinString()) {
if (one->IsThinString()) one = handle(ThinString::cast(*one)->actual());
if (two->IsThinString()) two = handle(ThinString::cast(*two)->actual());
return String::Equals(one, two);
if (one->IsThinString())
one = handle(ThinString::cast(*one)->actual(), isolate);
if (two->IsThinString())
two = handle(ThinString::cast(*two)->actual(), isolate);
return String::Equals(isolate, one, two);
}
// Fast check: if hash code is computed for both strings
@ -11543,8 +11550,8 @@ bool String::SlowEquals(Handle<String> one, Handle<String> two) {
// before we try to flatten the strings.
if (one->Get(0) != two->Get(0)) return false;
one = String::Flatten(one);
two = String::Flatten(two);
one = String::Flatten(isolate, one);
two = String::Flatten(isolate, two);
DisallowHeapAllocation no_gc;
String::FlatContent flat1 = one->GetFlatContent();
@ -11564,7 +11571,8 @@ bool String::SlowEquals(Handle<String> one, Handle<String> two) {
// static
ComparisonResult String::Compare(Handle<String> x, Handle<String> y) {
ComparisonResult String::Compare(Isolate* isolate, Handle<String> x,
Handle<String> y) {
// A few fast case tests before we flatten.
if (x.is_identical_to(y)) {
return ComparisonResult::kEqual;
@ -11583,8 +11591,8 @@ ComparisonResult String::Compare(Handle<String> x, Handle<String> y) {
}
// Slow case.
x = String::Flatten(x);
y = String::Flatten(y);
x = String::Flatten(isolate, x);
y = String::Flatten(isolate, y);
DisallowHeapAllocation no_gc;
ComparisonResult result = ComparisonResult::kEqual;
@ -11675,8 +11683,8 @@ int String::IndexOf(Isolate* isolate, Handle<String> receiver,
uint32_t receiver_length = receiver->length();
if (start_index + search_length > receiver_length) return -1;
receiver = String::Flatten(receiver);
search = String::Flatten(search);
receiver = String::Flatten(isolate, receiver);
search = String::Flatten(isolate, search);
DisallowHeapAllocation no_gc; // ensure vectors stay valid
// Extract flattened substrings of cons strings before getting encoding.
@ -11704,7 +11712,7 @@ MaybeHandle<String> String::GetSubstitution(Isolate* isolate, Match* match,
const int replacement_length = replacement->length();
const int captures_length = match->CaptureCount();
replacement = String::Flatten(replacement);
replacement = String::Flatten(isolate, replacement);
Handle<String> dollar_string =
factory->LookupSingleCharacterStringFromCode('$');
@ -11936,8 +11944,8 @@ Object* String::LastIndexOf(Isolate* isolate, Handle<Object> receiver,
return Smi::FromInt(start_index);
}
receiver_string = String::Flatten(receiver_string);
search_string = String::Flatten(search_string);
receiver_string = String::Flatten(isolate, receiver_string);
search_string = String::Flatten(isolate, search_string);
int last_index = -1;
DisallowHeapAllocation no_gc; // ensure vectors stay valid
@ -13334,7 +13342,7 @@ void Script::InitLineEnds(Handle<Script> script) {
} else {
DCHECK(src_obj->IsString());
Handle<String> src(String::cast(src_obj), isolate);
Handle<FixedArray> array = String::CalculateLineEnds(src, true);
Handle<FixedArray> array = String::CalculateLineEnds(isolate, src, true);
script->set_line_ends(*array);
}
@ -16377,7 +16385,7 @@ MaybeHandle<JSRegExp> JSRegExp::Initialize(Handle<JSRegExp> regexp,
// suggested by ECMA-262, 5th, section 15.10.4.1.
if (source->length() == 0) source = factory->query_colon_string();
source = String::Flatten(source);
source = String::Flatten(isolate, source);
Handle<String> escaped_source;
ASSIGN_RETURN_ON_EXCEPTION(isolate, escaped_source,
@ -16738,7 +16746,7 @@ bool CanonicalNumericIndexString(Isolate* isolate, Handle<Object> s,
if (s->IsSmi()) {
result = s;
} else {
result = String::ToNumber(Handle<String>::cast(s));
result = String::ToNumber(isolate, Handle<String>::cast(s));
if (!result->IsMinusZero()) {
Handle<String> str = Object::ToString(isolate, result).ToHandleChecked();
// Avoid treating strings like "2E1" and "20" as the same key.
@ -17035,7 +17043,7 @@ void MakeStringThin(String* string, String* internalized, Isolate* isolate) {
// static
Handle<String> StringTable::LookupString(Isolate* isolate,
Handle<String> string) {
string = String::Flatten(string);
string = String::Flatten(isolate, string);
if (string->IsInternalizedString()) return string;
InternalizedStringKey key(string);
@ -17304,11 +17312,11 @@ Handle<StringSet> StringSet::New(Isolate* isolate) {
return HashTable::New(isolate, 0);
}
Handle<StringSet> StringSet::Add(Handle<StringSet> stringset,
Handle<StringSet> StringSet::Add(Isolate* isolate, Handle<StringSet> stringset,
Handle<String> name) {
if (!stringset->Has(name)) {
stringset = EnsureCapacity(stringset, 1);
uint32_t hash = ShapeT::Hash(name->GetIsolate(), *name);
uint32_t hash = ShapeT::Hash(isolate, *name);
int entry = stringset->FindInsertionEntry(hash);
stringset->set(EntryToIndex(entry), *name);
stringset->ElementAdded();

View File

@ -1060,7 +1060,6 @@ template <class C> inline bool Is(Object* obj);
V(DescriptorArray) \
V(EphemeronHashTable) \
V(EnumCache) \
V(External) \
V(ExternalOneByteString) \
V(ExternalString) \
V(ExternalTwoByteString) \
@ -1236,6 +1235,8 @@ class Object {
HEAP_OBJECT_TYPE_LIST(IS_TYPE_FUNCTION_DECL)
#undef IS_TYPE_FUNCTION_DECL
INLINE(bool IsExternal(Isolate* isolate) const);
#define IS_TYPE_FUNCTION_DECL(Type, Value) \
INLINE(bool Is##Type(Isolate* isolate) const);
ODDBALL_LIST(IS_TYPE_FUNCTION_DECL)
@ -1828,6 +1829,8 @@ class HeapObject: public Object {
HEAP_OBJECT_TYPE_LIST(IS_TYPE_FUNCTION_DECL)
#undef IS_TYPE_FUNCTION_DECL
INLINE(bool IsExternal(Isolate* isolate) const);
#define IS_TYPE_FUNCTION_DECL(Type, Value) \
INLINE(bool Is##Type(Isolate* isolate) const);
ODDBALL_LIST(IS_TYPE_FUNCTION_DECL)

View File

@ -868,12 +868,11 @@ Handle<JSModuleNamespace> Module::GetModuleNamespace(Isolate* isolate,
DCHECK_EQ(static_cast<int>(names.size()), exports->NumberOfElements());
// Sort them alphabetically.
struct {
bool operator()(Handle<String> a, Handle<String> b) {
return String::Compare(a, b) == ComparisonResult::kLessThan;
}
} StringLess;
std::sort(names.begin(), names.end(), StringLess);
std::sort(names.begin(), names.end(),
[&isolate](Handle<String> a, Handle<String> b) {
return String::Compare(isolate, a, b) ==
ComparisonResult::kLessThan;
});
// Create the namespace object (initially empty).
Handle<JSModuleNamespace> ns = isolate->factory()->NewJSModuleNamespace();

View File

@ -69,13 +69,13 @@ bool Name::Equals(Name* other) {
return String::cast(this)->SlowEquals(String::cast(other));
}
bool Name::Equals(Handle<Name> one, Handle<Name> two) {
bool Name::Equals(Isolate* isolate, Handle<Name> one, Handle<Name> two) {
if (one.is_identical_to(two)) return true;
if ((one->IsInternalizedString() && two->IsInternalizedString()) ||
one->IsSymbol() || two->IsSymbol()) {
return false;
}
return String::SlowEquals(Handle<String>::cast(one),
return String::SlowEquals(isolate, Handle<String>::cast(one),
Handle<String>::cast(two));
}

View File

@ -29,7 +29,8 @@ class Name : public HeapObject {
// Equality operations.
inline bool Equals(Name* other);
inline static bool Equals(Handle<Name> one, Handle<Name> two);
inline static bool Equals(Isolate* isolate, Handle<Name> one,
Handle<Name> two);
// Conversion.
inline bool AsArrayIndex(uint32_t* index);

View File

@ -289,21 +289,22 @@ bool String::Equals(String* other) {
return SlowEquals(other);
}
bool String::Equals(Handle<String> one, Handle<String> two) {
bool String::Equals(Isolate* isolate, Handle<String> one, Handle<String> two) {
if (one.is_identical_to(two)) return true;
if (one->IsInternalizedString() && two->IsInternalizedString()) {
return false;
}
return SlowEquals(one, two);
return SlowEquals(isolate, one, two);
}
Handle<String> String::Flatten(Handle<String> string, PretenureFlag pretenure) {
Handle<String> String::Flatten(Isolate* isolate, Handle<String> string,
PretenureFlag pretenure) {
if (string->IsConsString()) {
Handle<ConsString> cons = Handle<ConsString>::cast(string);
if (cons->IsFlat()) {
string = handle(cons->first());
} else {
return SlowFlatten(cons, pretenure);
return SlowFlatten(isolate, cons, pretenure);
}
}
if (string->IsThinString()) {

View File

@ -103,7 +103,7 @@ class StringSetShape : public BaseShape<String*> {
class StringSet : public HashTable<StringSet, StringSetShape> {
public:
static Handle<StringSet> New(Isolate* isolate);
static Handle<StringSet> Add(Handle<StringSet> blacklist,
static Handle<StringSet> Add(Isolate* isolate, Handle<StringSet> blacklist,
Handle<String> name);
bool Has(Handle<String> name);

View File

@ -190,7 +190,7 @@ class String : public Name {
INLINE(uint16_t Get(int index));
// ES6 section 7.1.3.1 ToNumber Applied to the String Type
static Handle<Object> ToNumber(Handle<String> subject);
static Handle<Object> ToNumber(Isolate* isolate, Handle<String> subject);
// Flattens the string. Checks first inline to see if it is
// necessary. Does nothing if the string is not a cons string.
@ -205,7 +205,7 @@ class String : public Name {
// Degenerate cons strings are handled specially by the garbage
// collector (see IsShortcutCandidate).
static inline Handle<String> Flatten(Handle<String> string,
static inline Handle<String> Flatten(Isolate* isolate, Handle<String> string,
PretenureFlag pretenure = NOT_TENURED);
// Tries to return the content of a flat string as a structure holding either
@ -230,7 +230,8 @@ class String : public Name {
// for strings containing supplementary characters, lexicographic ordering on
// sequences of UTF-16 code unit values differs from that on sequences of code
// point values.
V8_WARN_UNUSED_RESULT static ComparisonResult Compare(Handle<String> x,
V8_WARN_UNUSED_RESULT static ComparisonResult Compare(Isolate* isolate,
Handle<String> x,
Handle<String> y);
// Perform ES6 21.1.3.8, including checking arguments.
@ -278,7 +279,8 @@ class String : public Name {
// String equality operations.
inline bool Equals(String* other);
inline static bool Equals(Handle<String> one, Handle<String> two);
inline static bool Equals(Isolate* isolate, Handle<String> one,
Handle<String> two);
bool IsUtf8EqualTo(Vector<const char> str, bool allow_prefix_match = false);
// Dispatches to Is{One,Two}ByteEqualTo.
@ -316,7 +318,8 @@ class String : public Name {
// Trimming.
enum TrimMode { kTrim, kTrimStart, kTrimEnd };
static Handle<String> Trim(Handle<String> string, TrimMode mode);
static Handle<String> Trim(Isolate* isolate, Handle<String> string,
TrimMode mode);
DECL_CAST(String)
@ -437,7 +440,8 @@ class String : public Name {
static inline ConsString* VisitFlat(Visitor* visitor, String* string,
int offset = 0);
static Handle<FixedArray> CalculateLineEnds(Handle<String> string,
static Handle<FixedArray> CalculateLineEnds(Isolate* isolate,
Handle<String> string,
bool include_ending_line);
private:
@ -445,14 +449,15 @@ class String : public Name {
friend class StringTableInsertionKey;
friend class InternalizedStringKey;
static Handle<String> SlowFlatten(Handle<ConsString> cons,
static Handle<String> SlowFlatten(Isolate* isolate, Handle<ConsString> cons,
PretenureFlag tenure);
// Slow case of String::Equals. This implementation works on any strings
// but it is most efficient on strings that are almost flat.
bool SlowEquals(String* other);
static bool SlowEquals(Handle<String> one, Handle<String> two);
static bool SlowEquals(Isolate* isolate, Handle<String> one,
Handle<String> two);
// Slow case of AsArrayIndex.
V8_EXPORT_PRIVATE bool SlowAsArrayIndex(uint32_t* index);

View File

@ -25,7 +25,7 @@ bool ParseProgram(ParseInfo* info, Isolate* isolate) {
// Create a character stream for the parser.
Handle<String> source(String::cast(info->script()->source()), isolate);
source = String::Flatten(source);
source = String::Flatten(isolate, source);
isolate->counters()->total_parse_size()->Increment(source->length());
std::unique_ptr<Utf16CharacterStream> stream(ScannerStream::For(source));
info->set_character_stream(std::move(stream));
@ -60,7 +60,7 @@ bool ParseFunction(ParseInfo* info, Handle<SharedFunctionInfo> shared_info,
// Create a character stream for the parser.
Handle<String> source(String::cast(info->script()->source()), isolate);
source = String::Flatten(source);
source = String::Flatten(isolate, source);
isolate->counters()->total_parse_size()->Increment(source->length());
std::unique_ptr<Utf16CharacterStream> stream(ScannerStream::For(
source, shared_info->StartPosition(), shared_info->EndPosition()));

View File

@ -233,7 +233,7 @@ void HeapProfiler::QueryObjects(Handle<Context> context,
HeapIterator heap_iterator(heap());
HeapObject* heap_obj;
while ((heap_obj = heap_iterator.next()) != nullptr) {
if (!heap_obj->IsJSObject() || heap_obj->IsExternal()) continue;
if (!heap_obj->IsJSObject() || heap_obj->IsExternal(isolate())) continue;
v8::Local<v8::Object> v8_obj(
Utils::ToLocal(handle(JSObject::cast(heap_obj), isolate())));
if (!predicate->Filter(v8_obj)) continue;

View File

@ -226,7 +226,7 @@ int RegExpImpl::AtomExecRaw(Isolate* isolate, Handle<JSRegExp> regexp,
DCHECK_LE(0, index);
DCHECK_LE(index, subject->length());
subject = String::Flatten(subject);
subject = String::Flatten(isolate, subject);
DisallowHeapAllocation no_gc; // ensure vectors stay valid
String* needle = String::cast(regexp->DataAt(JSRegExp::kAtomPatternIndex));
@ -325,7 +325,7 @@ bool RegExpImpl::CompileIrregexp(Isolate* isolate, Handle<JSRegExp> re,
JSRegExp::Flags flags = re->GetFlags();
Handle<String> pattern(re->Pattern());
pattern = String::Flatten(pattern);
pattern = String::Flatten(isolate, pattern);
RegExpCompileData compile_data;
FlatStringReader reader(isolate, pattern);
if (!RegExpParser::ParseRegExp(isolate, &zone, &reader, flags,
@ -518,7 +518,7 @@ MaybeHandle<Object> RegExpImpl::IrregexpExec(
int previous_index, Handle<RegExpMatchInfo> last_match_info) {
DCHECK_EQ(regexp->TypeTag(), JSRegExp::IRREGEXP);
subject = String::Flatten(subject);
subject = String::Flatten(isolate, subject);
// Prepare space for the return values.
#if defined(V8_INTERPRETED_REGEXP) && defined(DEBUG)
@ -6644,7 +6644,7 @@ RegExpEngine::CompilationResult RegExpEngine::Compile(
// Sample some characters from the middle of the string.
static const int kSampleSize = 128;
sample_subject = String::Flatten(sample_subject);
sample_subject = String::Flatten(isolate, sample_subject);
int chars_sampled = 0;
int half_way = (sample_subject->length() - kSampleSize) / 2;
for (int i = Max(0, half_way);

View File

@ -385,8 +385,8 @@ RUNTIME_FUNCTION(Runtime_InternalCompare) {
icu::Collator* collator = Collator::UnpackCollator(isolate, collator_holder);
CHECK_NOT_NULL(collator);
string1 = String::Flatten(string1);
string2 = String::Flatten(string2);
string1 = String::Flatten(isolate, string1);
string2 = String::Flatten(isolate, string2);
UCollationResult result;
UErrorCode status = U_ZERO_ERROR;
@ -537,7 +537,7 @@ RUNTIME_FUNCTION(Runtime_BreakIteratorAdoptText) {
delete u_text;
int length = text->length();
text = String::Flatten(text);
text = String::Flatten(isolate, text);
DisallowHeapAllocation no_gc;
String::FlatContent flat = text->GetFlatContent();
std::unique_ptr<uc16[]> sap;
@ -627,7 +627,7 @@ RUNTIME_FUNCTION(Runtime_StringToLowerCaseIntl) {
HandleScope scope(isolate);
DCHECK_EQ(args.length(), 1);
CONVERT_ARG_HANDLE_CHECKED(String, s, 0);
s = String::Flatten(s);
s = String::Flatten(isolate, s);
return ConvertToLower(s, isolate);
}
@ -635,7 +635,7 @@ RUNTIME_FUNCTION(Runtime_StringToUpperCaseIntl) {
HandleScope scope(isolate);
DCHECK_EQ(args.length(), 1);
CONVERT_ARG_HANDLE_CHECKED(String, s, 0);
s = String::Flatten(s);
s = String::Flatten(isolate, s);
return ConvertToUpper(s, isolate);
}
@ -649,8 +649,8 @@ RUNTIME_FUNCTION(Runtime_StringLocaleConvertCase) {
// Primary language tag can be up to 8 characters long in theory.
// https://tools.ietf.org/html/bcp47#section-2.2.1
DCHECK_LE(lang_arg->length(), 8);
lang_arg = String::Flatten(lang_arg);
s = String::Flatten(s);
lang_arg = String::Flatten(isolate, lang_arg);
s = String::Flatten(isolate, s);
// All the languages requiring special-handling have two-letter codes.
// Note that we have to check for '!= 2' here because private-use language

View File

@ -25,7 +25,7 @@ RUNTIME_FUNCTION(Runtime_StringToNumber) {
HandleScope handle_scope(isolate);
DCHECK_EQ(1, args.length());
CONVERT_ARG_HANDLE_CHECKED(String, subject, 0);
return *String::ToNumber(subject);
return *String::ToNumber(isolate, subject);
}
@ -40,7 +40,7 @@ RUNTIME_FUNCTION(Runtime_StringParseInt) {
Handle<String> subject;
ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, subject,
Object::ToString(isolate, string));
subject = String::Flatten(subject);
subject = String::Flatten(isolate, subject);
// Convert {radix} to Int32.
if (!radix->IsNumber()) {
@ -62,9 +62,9 @@ RUNTIME_FUNCTION(Runtime_StringParseFloat) {
DCHECK_EQ(1, args.length());
CONVERT_ARG_HANDLE_CHECKED(String, subject, 0);
double value =
StringToDouble(isolate->unicode_cache(), subject, ALLOW_TRAILING_JUNK,
std::numeric_limits<double>::quiet_NaN());
double value = StringToDouble(isolate, isolate->unicode_cache(), subject,
ALLOW_TRAILING_JUNK,
std::numeric_limits<double>::quiet_NaN());
return *isolate->factory()->NewNumber(value);
}

View File

@ -130,7 +130,7 @@ static MaybeHandle<Object> KeyedGetObjectProperty(Isolate* isolate,
if (index >= 0 && index < str->length()) {
Factory* factory = isolate->factory();
return factory->LookupSingleCharacterStringFromCode(
String::Flatten(str)->Get(index));
String::Flatten(isolate, str)->Get(index));
}
}

View File

@ -799,7 +799,7 @@ Object* StringReplaceGlobalRegExpWithStringHelper(
Handle<String> replacement, Handle<RegExpMatchInfo> last_match_info) {
CHECK(regexp->GetFlags() & JSRegExp::kGlobal);
subject = String::Flatten(subject);
subject = String::Flatten(isolate, subject);
if (replacement->length() == 0) {
if (subject->HasOnlyOneByteChars()) {
@ -811,7 +811,7 @@ Object* StringReplaceGlobalRegExpWithStringHelper(
}
}
replacement = String::Flatten(replacement);
replacement = String::Flatten(isolate, replacement);
return StringReplaceGlobalRegExpWithString(isolate, subject, regexp,
replacement, last_match_info);
@ -850,8 +850,8 @@ RUNTIME_FUNCTION(Runtime_StringSplit) {
// isn't empty, we can never create more parts than ~half the length
// of the subject.
subject = String::Flatten(subject);
pattern = String::Flatten(pattern);
subject = String::Flatten(isolate, subject);
pattern = String::Flatten(isolate, pattern);
std::vector<int>* indices = GetRewoundRegexpIndicesList(isolate);
@ -938,7 +938,7 @@ class MatchInfoBackedMatch : public String::Match {
Handle<String> subject,
Handle<RegExpMatchInfo> match_info)
: isolate_(isolate), match_info_(match_info) {
subject_ = String::Flatten(subject);
subject_ = String::Flatten(isolate, subject);
if (regexp->TypeTag() == JSRegExp::IRREGEXP) {
Object* o = regexp->CaptureNameMap();
@ -1027,7 +1027,7 @@ class VectorBackedMatch : public String::Match {
match_(match),
match_position_(match_position),
captures_(captures) {
subject_ = String::Flatten(subject);
subject_ = String::Flatten(isolate, subject);
DCHECK(groups_obj->IsUndefined(isolate) || groups_obj->IsJSReceiver());
has_named_captures_ = !groups_obj->IsUndefined(isolate);
@ -1311,7 +1311,7 @@ V8_WARN_UNUSED_RESULT MaybeHandle<String> RegExpReplace(
Handle<String> replace;
ASSIGN_RETURN_ON_EXCEPTION(isolate, replace,
Object::ToString(isolate, replace_obj), String);
replace = String::Flatten(replace);
replace = String::Flatten(isolate, replace);
Handle<RegExpMatchInfo> last_match_info = isolate->regexp_last_match_info();
@ -1408,7 +1408,7 @@ RUNTIME_FUNCTION(Runtime_RegExpExecMultiple) {
CONVERT_ARG_HANDLE_CHECKED(JSArray, result_array, 3);
CHECK(result_array->HasObjectElements());
subject = String::Flatten(subject);
subject = String::Flatten(isolate, subject);
CHECK(regexp->GetFlags() & JSRegExp::kGlobal);
if (regexp->CaptureCount() == 0) {
@ -1730,7 +1730,7 @@ RUNTIME_FUNCTION(Runtime_RegExpReplace) {
Factory* factory = isolate->factory();
string = String::Flatten(string);
string = String::Flatten(isolate, string);
// Fast-path for unmodified JSRegExps.
if (RegExpUtils::IsUnmodifiedRegExp(isolate, recv)) {

View File

@ -125,7 +125,7 @@ RUNTIME_FUNCTION(Runtime_StringReplaceOneCharWithString) {
}
if (isolate->has_pending_exception()) return isolate->heap()->exception();
subject = String::Flatten(subject);
subject = String::Flatten(isolate, subject);
if (StringReplaceOneCharWithString(isolate, subject, search, replace, &found,
kRecursionLimit).ToHandle(&result)) {
return *result;
@ -141,7 +141,7 @@ RUNTIME_FUNCTION(Runtime_StringTrim) {
Handle<String> string = args.at<String>(0);
CONVERT_SMI_ARG_CHECKED(mode, 1);
String::TrimMode trim_mode = static_cast<String::TrimMode>(mode);
return *String::Trim(string, trim_mode);
return *String::Trim(isolate, string, trim_mode);
}
// ES6 #sec-string.prototype.includes
@ -257,7 +257,7 @@ RUNTIME_FUNCTION(Runtime_StringCharCodeAt) {
// Flatten the string. If someone wants to get a char at an index
// in a cons string, it is likely that more indices will be
// accessed.
subject = String::Flatten(subject);
subject = String::Flatten(isolate, subject);
if (i >= static_cast<uint32_t>(subject->length())) {
return isolate->heap()->nan_value();
@ -600,7 +600,7 @@ RUNTIME_FUNCTION(Runtime_StringToArray) {
CONVERT_ARG_HANDLE_CHECKED(String, s, 0);
CONVERT_NUMBER_CHECKED(uint32_t, limit, Uint32, args[1]);
s = String::Flatten(s);
s = String::Flatten(isolate, s);
const int length = static_cast<int>(Min<uint32_t>(s->length(), limit));
Handle<FixedArray> elements;
@ -644,7 +644,7 @@ RUNTIME_FUNCTION(Runtime_StringLessThan) {
DCHECK_EQ(2, args.length());
CONVERT_ARG_HANDLE_CHECKED(String, x, 0);
CONVERT_ARG_HANDLE_CHECKED(String, y, 1);
ComparisonResult result = String::Compare(x, y);
ComparisonResult result = String::Compare(isolate, x, y);
DCHECK_NE(result, ComparisonResult::kUndefined);
return isolate->heap()->ToBoolean(
ComparisonResultToBool(Operation::kLessThan, result));
@ -655,7 +655,7 @@ RUNTIME_FUNCTION(Runtime_StringLessThanOrEqual) {
DCHECK_EQ(2, args.length());
CONVERT_ARG_HANDLE_CHECKED(String, x, 0);
CONVERT_ARG_HANDLE_CHECKED(String, y, 1);
ComparisonResult result = String::Compare(x, y);
ComparisonResult result = String::Compare(isolate, x, y);
DCHECK_NE(result, ComparisonResult::kUndefined);
return isolate->heap()->ToBoolean(
ComparisonResultToBool(Operation::kLessThanOrEqual, result));
@ -666,7 +666,7 @@ RUNTIME_FUNCTION(Runtime_StringGreaterThan) {
DCHECK_EQ(2, args.length());
CONVERT_ARG_HANDLE_CHECKED(String, x, 0);
CONVERT_ARG_HANDLE_CHECKED(String, y, 1);
ComparisonResult result = String::Compare(x, y);
ComparisonResult result = String::Compare(isolate, x, y);
DCHECK_NE(result, ComparisonResult::kUndefined);
return isolate->heap()->ToBoolean(
ComparisonResultToBool(Operation::kGreaterThan, result));
@ -677,7 +677,7 @@ RUNTIME_FUNCTION(Runtime_StringGreaterThanOrEqual) {
DCHECK_EQ(2, args.length());
CONVERT_ARG_HANDLE_CHECKED(String, x, 0);
CONVERT_ARG_HANDLE_CHECKED(String, y, 1);
ComparisonResult result = String::Compare(x, y);
ComparisonResult result = String::Compare(isolate, x, y);
DCHECK_NE(result, ComparisonResult::kUndefined);
return isolate->heap()->ToBoolean(
ComparisonResultToBool(Operation::kGreaterThanOrEqual, result));
@ -688,7 +688,7 @@ RUNTIME_FUNCTION(Runtime_StringEqual) {
DCHECK_EQ(2, args.length());
CONVERT_ARG_HANDLE_CHECKED(String, x, 0);
CONVERT_ARG_HANDLE_CHECKED(String, y, 1);
return isolate->heap()->ToBoolean(String::Equals(x, y));
return isolate->heap()->ToBoolean(String::Equals(isolate, x, y));
}
RUNTIME_FUNCTION(Runtime_StringNotEqual) {
@ -696,14 +696,14 @@ RUNTIME_FUNCTION(Runtime_StringNotEqual) {
DCHECK_EQ(2, args.length());
CONVERT_ARG_HANDLE_CHECKED(String, x, 0);
CONVERT_ARG_HANDLE_CHECKED(String, y, 1);
return isolate->heap()->ToBoolean(!String::Equals(x, y));
return isolate->heap()->ToBoolean(!String::Equals(isolate, x, y));
}
RUNTIME_FUNCTION(Runtime_FlattenString) {
HandleScope scope(isolate);
DCHECK_EQ(1, args.length());
CONVERT_ARG_HANDLE_CHECKED(String, str, 0);
return *String::Flatten(str);
return *String::Flatten(isolate, str);
}
RUNTIME_FUNCTION(Runtime_StringCharFromCode) {

View File

@ -175,7 +175,7 @@ bool IntoOneAndTwoByte(Handle<String> uri, bool is_uri,
MaybeHandle<String> Uri::Decode(Isolate* isolate, Handle<String> uri,
bool is_uri) {
uri = String::Flatten(uri);
uri = String::Flatten(isolate, uri);
std::vector<uint8_t> one_byte_buffer;
std::vector<uc16> two_byte_buffer;
@ -273,7 +273,7 @@ void EncodePair(uc16 cc1, uc16 cc2, std::vector<uint8_t>* buffer) {
MaybeHandle<String> Uri::Encode(Isolate* isolate, Handle<String> uri,
bool is_uri) {
uri = String::Flatten(uri);
uri = String::Flatten(isolate, uri);
int uri_length = uri->length();
std::vector<uint8_t> buffer;
buffer.reserve(uri_length);
@ -492,7 +492,7 @@ static MaybeHandle<String> EscapePrivate(Isolate* isolate,
MaybeHandle<String> Uri::Escape(Isolate* isolate, Handle<String> string) {
Handle<String> result;
string = String::Flatten(string);
string = String::Flatten(isolate, string);
return string->IsOneByteRepresentationUnderneath()
? EscapePrivate<uint8_t>(isolate, string)
: EscapePrivate<uc16>(isolate, string);
@ -500,7 +500,7 @@ MaybeHandle<String> Uri::Escape(Isolate* isolate, Handle<String> string) {
MaybeHandle<String> Uri::Unescape(Isolate* isolate, Handle<String> string) {
Handle<String> result;
string = String::Flatten(string);
string = String::Flatten(isolate, string);
return string->IsOneByteRepresentationUnderneath()
? UnescapePrivate<uint8_t>(isolate, string)
: UnescapePrivate<uc16>(isolate, string);

View File

@ -431,7 +431,7 @@ void ValueSerializer::WriteBigInt(BigInt* bigint) {
}
void ValueSerializer::WriteString(Handle<String> string) {
string = String::Flatten(string);
string = String::Flatten(isolate_, string);
DisallowHeapAllocation no_gc;
String::FlatContent flat = string->GetFlatContent();
DCHECK(flat.IsFlat());

View File

@ -2034,7 +2034,7 @@ void InstanceBuilder::ProcessExports(Handle<WasmInstanceObject> instance) {
.ToHandleChecked();
Handle<JSObject> export_to;
if (is_asm_js && exp.kind == kExternalFunction &&
String::Equals(name, single_function_name)) {
String::Equals(isolate_, name, single_function_name)) {
export_to = instance;
} else {
export_to = exports_object;

View File

@ -8269,12 +8269,12 @@ static int StrNCmp16(uint16_t* a, uint16_t* b, int n) {
}
}
int GetUtf8Length(Local<String> str) {
int GetUtf8Length(v8::Isolate* isolate, Local<String> str) {
int len = str->Utf8Length();
if (len < 0) {
i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate);
i::Handle<i::String> istr(v8::Utils::OpenHandle(*str));
i::String::Flatten(istr);
i::String::Flatten(i_isolate, istr);
len = str->Utf8Length();
}
return len;
@ -8440,7 +8440,7 @@ THREADED_TEST(StringWrite) {
CHECK_EQ(0, charlen);
memset(utf8buf, 0x1, sizeof(utf8buf));
len = GetUtf8Length(left_tree);
len = GetUtf8Length(context->GetIsolate(), left_tree);
int utf8_expected =
(0x80 + (0x800 - 0x80) * 2 + (0xD800 - 0x800) * 3) / kStride;
CHECK_EQ(utf8_expected, len);
@ -8454,7 +8454,7 @@ THREADED_TEST(StringWrite) {
CHECK_EQ(1, utf8buf[utf8_expected]);
memset(utf8buf, 0x1, sizeof(utf8buf));
len = GetUtf8Length(right_tree);
len = GetUtf8Length(context->GetIsolate(), right_tree);
CHECK_EQ(utf8_expected, len);
len = right_tree->WriteUtf8(utf8buf, utf8_expected, &charlen);
CHECK_EQ(utf8_expected, len);
@ -8619,7 +8619,7 @@ static void Utf16Helper(
Local<v8::String>::Cast(a->Get(context.local(), i).ToLocalChecked());
Local<v8::Number> expected_len = Local<v8::Number>::Cast(
alens->Get(context.local(), i).ToLocalChecked());
int length = GetUtf8Length(string);
int length = GetUtf8Length(context->GetIsolate(), string);
CHECK_EQ(static_cast<int>(expected_len->Value()), length);
}
}
@ -20231,7 +20231,8 @@ THREADED_TEST(TwoByteStringInOneByteCons) {
int length = string->length();
CHECK(string->IsOneByteRepresentation());
i::Handle<i::String> flat_string = i::String::Flatten(string);
i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(context->GetIsolate());
i::Handle<i::String> flat_string = i::String::Flatten(i_isolate, string);
CHECK(string->IsOneByteRepresentation());
CHECK(flat_string->IsOneByteRepresentation());

View File

@ -402,7 +402,7 @@ TEST(ToString) {
Handle<String> expected = handle(String::cast(test->get(1)), isolate);
Handle<Object> result = ft.Call(obj).ToHandleChecked();
CHECK(result->IsString());
CHECK(String::Equals(Handle<String>::cast(result), expected));
CHECK(String::Equals(isolate, Handle<String>::cast(result), expected));
}
}

View File

@ -149,7 +149,7 @@ TEST(GetOptions) {
CHECK(result->IsString());
Handle<String> expected_str =
isolate->factory()->NewStringFromAsciiChecked("42");
CHECK(String::Equals(expected_str, Handle<String>::cast(result)));
CHECK(String::Equals(isolate, expected_str, Handle<String>::cast(result)));
result = Object::GetOption(isolate, options, key, Object::OptionType::Boolean,
empty_fixed_array, undefined, service)
@ -173,7 +173,7 @@ TEST(GetOptions) {
values, undefined, service)
.ToHandleChecked();
CHECK(result->IsString());
CHECK(String::Equals(expected_str, Handle<String>::cast(result)));
CHECK(String::Equals(isolate, expected_str, Handle<String>::cast(result)));
// Test boolean values
CHECK(Object::SetProperty(&it, isolate->factory()->ToBoolean(false),

View File

@ -1235,7 +1235,7 @@ void TestParserSyncWithFlags(i::Handle<i::String> source,
if (test_preparser && !ignore_error_msg) {
i::Handle<i::String> preparser_message =
pending_error_handler.FormatErrorMessageForTest(CcTest::i_isolate());
if (!i::String::Equals(message_string, preparser_message)) {
if (!i::String::Equals(isolate, message_string, preparser_message)) {
FATAL(
"Expected parser and preparser to produce the same error on:\n"
"\t%s\n"

View File

@ -457,14 +457,16 @@ TEST(ParserRegression) {
static void ExpectError(const char* input, const char* expected,
bool unicode = false) {
Isolate* isolate = CcTest::i_isolate();
v8::HandleScope scope(CcTest::isolate());
Zone zone(CcTest::i_isolate()->allocator(), ZONE_NAME);
FlatStringReader reader(CcTest::i_isolate(), CStrVector(input));
Zone zone(isolate->allocator(), ZONE_NAME);
FlatStringReader reader(isolate, CStrVector(input));
RegExpCompileData result;
JSRegExp::Flags flags = JSRegExp::kNone;
if (unicode) flags |= JSRegExp::kUnicode;
CHECK(!v8::internal::RegExpParser::ParseRegExp(CcTest::i_isolate(), &zone,
&reader, flags, &result));
CHECK(!v8::internal::RegExpParser::ParseRegExp(isolate, &zone, &reader, flags,
&result));
CHECK_NULL(result.tree);
CHECK(!result.error.is_null());
std::unique_ptr<char[]> str = result.error->ToCString(ALLOW_NULLS);

View File

@ -395,7 +395,8 @@ void VerifyConsString(Handle<String> root, ConsStringGenerationData* data) {
static Handle<String> ConstructRandomString(ConsStringGenerationData* data,
unsigned max_recursion) {
Factory* factory = CcTest::i_isolate()->factory();
Isolate* isolate = CcTest::i_isolate();
Factory* factory = isolate->factory();
// Compute termination characteristics.
bool terminate = false;
bool flat = data->rng_.next(data->empty_leaf_threshold_);
@ -447,7 +448,7 @@ static Handle<String> ConstructRandomString(ConsStringGenerationData* data,
// Special work needed for flat string.
if (flat) {
data->stats_.empty_leaves_++;
String::Flatten(root);
String::Flatten(isolate, root);
CHECK(root->IsConsString() && root->IsFlat());
}
return root;
@ -562,10 +563,11 @@ static void TraverseFirst(Handle<String> s1, Handle<String> s2, int chars) {
TEST(Traverse) {
printf("TestTraverse\n");
CcTest::InitializeVM();
Isolate* isolate = CcTest::i_isolate();
v8::HandleScope scope(CcTest::isolate());
ConsStringGenerationData data(false);
Handle<String> flat = ConstructBalanced(&data);
String::Flatten(flat);
String::Flatten(isolate, flat);
Handle<String> left_asymmetric = ConstructLeft(&data, DEEP_DEPTH);
Handle<String> right_asymmetric = ConstructRight(&data, DEEP_DEPTH);
Handle<String> symmetric = ConstructBalanced(&data);
@ -585,19 +587,19 @@ TEST(Traverse) {
printf("6\n");
TraverseFirst(left_asymmetric, right_deep_asymmetric, 65536);
printf("7\n");
String::Flatten(left_asymmetric);
String::Flatten(isolate, left_asymmetric);
printf("10\n");
Traverse(flat, left_asymmetric);
printf("11\n");
String::Flatten(right_asymmetric);
String::Flatten(isolate, right_asymmetric);
printf("12\n");
Traverse(flat, right_asymmetric);
printf("14\n");
String::Flatten(symmetric);
String::Flatten(isolate, symmetric);
printf("15\n");
Traverse(flat, symmetric);
printf("16\n");
String::Flatten(left_deep_asymmetric);
String::Flatten(isolate, left_deep_asymmetric);
printf("18\n");
}
@ -633,7 +635,7 @@ TEST(ConsStringWithEmptyFirstFlatten) {
// Make sure Flatten doesn't alloc a new string.
DisallowHeapAllocation no_alloc;
i::Handle<i::String> flat = i::String::Flatten(cons);
i::Handle<i::String> flat = i::String::Flatten(isolate, cons);
CHECK(flat->IsFlat());
CHECK_EQ(initial_length, flat->length());
}
@ -694,7 +696,7 @@ void TestStringCharacterStream(BuildString build, int test_cases) {
ConsStringStats flat_string_stats;
AccumulateStats(flat_string, &flat_string_stats);
// Flatten string.
String::Flatten(flat_string);
String::Flatten(isolate, flat_string);
// Build unflattened version of cons string to test.
Handle<String> cons_string = build(i, &data);
ConsStringStats cons_string_stats;
@ -716,10 +718,10 @@ void TestStringCharacterStream(BuildString build, int test_cases) {
static const int kCharacterStreamNonRandomCases = 8;
static Handle<String> BuildEdgeCaseConsString(
int test_case, ConsStringGenerationData* data) {
Factory* factory = CcTest::i_isolate()->factory();
static Handle<String> BuildEdgeCaseConsString(int test_case,
ConsStringGenerationData* data) {
Isolate* isolate = CcTest::i_isolate();
Factory* factory = isolate->factory();
data->Reset();
switch (test_case) {
case 0:
@ -749,7 +751,7 @@ static Handle<String> BuildEdgeCaseConsString(
Handle<String> string =
factory->NewConsString(data->block(0), data->block(1))
.ToHandleChecked();
String::Flatten(string);
String::Flatten(isolate, string);
return string;
}
case 7:
@ -764,7 +766,7 @@ static Handle<String> BuildEdgeCaseConsString(
Handle<String> left =
factory->NewConsString(data->block(0), data->block(1))
.ToHandleChecked();
String::Flatten(left);
String::Flatten(isolate, left);
return factory->NewConsString(left, data->block(2)).ToHandleChecked();
}
case 8:
@ -781,11 +783,11 @@ static Handle<String> BuildEdgeCaseConsString(
Handle<String> left =
factory->NewConsString(data->block(0), data->block(1))
.ToHandleChecked();
String::Flatten(left);
String::Flatten(isolate, left);
Handle<String> right =
factory->NewConsString(data->block(2), data->block(2))
.ToHandleChecked();
String::Flatten(right);
String::Flatten(isolate, right);
return factory->NewConsString(left, right).ToHandleChecked();
}
}
@ -885,7 +887,8 @@ static const int kDeepOneByteDepth = 100000;
TEST(DeepOneByte) {
CcTest::InitializeVM();
Factory* factory = CcTest::i_isolate()->factory();
Isolate* isolate = CcTest::i_isolate();
Factory* factory = isolate->factory();
v8::HandleScope scope(CcTest::isolate());
char* foo = NewArray<char>(kDeepOneByteDepth);
@ -901,7 +904,7 @@ TEST(DeepOneByte) {
}
Handle<String> flat_string =
factory->NewConsString(string, foo_string).ToHandleChecked();
String::Flatten(flat_string);
String::Flatten(isolate, flat_string);
for (int i = 0; i < 500; i++) {
TraverseFirst(flat_string, string, kDeepOneByteDepth);
@ -1525,7 +1528,7 @@ TEST(FormatMessage) {
arg0, arg1, arg2).ToHandleChecked();
Handle<String> expected = isolate->factory()->NewStringFromAsciiChecked(
"'arg0' returned for property 'arg1' of object 'arg2' is not a function");
CHECK(String::Equals(result, expected));
CHECK(String::Equals(isolate, result, expected));
}
TEST(Regress609831) {