[offthread] Add an OffThreadIsolate
The Factory/OffThreadFactory allows us to cleanly separate object construction behaviour between main-thread and off-thread in a syntactically consistent way (so that methods templated on the factory type can be made to work on both). However, there are cases where we also have to access the Isolate, for handle creation or exception throwing. So far we have been pushing more and more "customization points" into the factories to allow these factory-templated methods to dispatch on this isolate behaviour via these factory methods. Unfortunately, this is an increasing layering violation between Factory and Isolate, particularly around exception handling. Now, we introduce an OffThreadIsolate, analogous to Isolate in the same way as OffThreadFactory is analogous to Factory. All methods which were templated on Factory are now templated on Isolate, and methods which used to take an Isolate, and which were recently changed to take a templated Factory, are changed/reverted to take a templated Isolate. OffThreadFactory gets an isolate() method to match Factory's. Notably, FactoryHandle is changed to "HandleFor", where the template argument can be either of the Isolate type or the Factory type (allowing us to dispatch on both depending on what is available). Bug: chromium:1011762 Change-Id: Id144176f7da534dd76f3d535ab2ade008b6845e3 Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2030909 Commit-Queue: Leszek Swirski <leszeks@chromium.org> Reviewed-by: Toon Verwaest <verwaest@chromium.org> Reviewed-by: Ulan Degenbaev <ulan@chromium.org> Cr-Commit-Position: refs/heads/master@{#66101}
This commit is contained in:
parent
deb3fd8a74
commit
7a20b6b9d3
1
BUILD.gn
1
BUILD.gn
@ -2235,6 +2235,7 @@ v8_source_set("v8_base_without_compiler") {
|
||||
"src/execution/messages.h",
|
||||
"src/execution/microtask-queue.cc",
|
||||
"src/execution/microtask-queue.h",
|
||||
"src/execution/off-thread-isolate.h",
|
||||
"src/execution/protectors-inl.h",
|
||||
"src/execution/protectors.cc",
|
||||
"src/execution/protectors.h",
|
||||
|
@ -28,6 +28,7 @@
|
||||
#include "src/ast/ast-value-factory.h"
|
||||
|
||||
#include "src/common/globals.h"
|
||||
#include "src/execution/off-thread-isolate.h"
|
||||
#include "src/heap/factory-inl.h"
|
||||
#include "src/heap/off-thread-factory-inl.h"
|
||||
#include "src/objects/objects-inl.h"
|
||||
@ -57,24 +58,24 @@ class OneByteStringStream {
|
||||
|
||||
} // namespace
|
||||
|
||||
void AstRawString::Internalize(Factory* factory) {
|
||||
void AstRawString::Internalize(Isolate* isolate) {
|
||||
DCHECK(!has_string_);
|
||||
if (literal_bytes_.length() == 0) {
|
||||
set_string(factory->empty_string());
|
||||
set_string(isolate->factory()->empty_string());
|
||||
} else if (is_one_byte()) {
|
||||
OneByteStringKey key(hash_field_, literal_bytes_);
|
||||
set_string(factory->InternalizeStringWithKey(&key));
|
||||
set_string(isolate->factory()->InternalizeStringWithKey(&key));
|
||||
} else {
|
||||
TwoByteStringKey key(hash_field_,
|
||||
Vector<const uint16_t>::cast(literal_bytes_));
|
||||
set_string(factory->InternalizeStringWithKey(&key));
|
||||
set_string(isolate->factory()->InternalizeStringWithKey(&key));
|
||||
}
|
||||
}
|
||||
|
||||
void AstRawString::Internalize(OffThreadFactory* factory) {
|
||||
void AstRawString::Internalize(OffThreadIsolate* isolate) {
|
||||
DCHECK(!has_string_);
|
||||
if (literal_bytes_.length() == 0) {
|
||||
set_string(factory->empty_string());
|
||||
set_string(isolate->factory()->empty_string());
|
||||
return;
|
||||
}
|
||||
|
||||
@ -84,10 +85,10 @@ void AstRawString::Internalize(OffThreadFactory* factory) {
|
||||
// during merging.
|
||||
OffThreadHandle<SeqString> string;
|
||||
if (is_one_byte()) {
|
||||
string = factory->NewOneByteInternalizedString(
|
||||
string = isolate->factory()->NewOneByteInternalizedString(
|
||||
Vector<const uint8_t>::cast(literal_bytes_), hash_field());
|
||||
} else {
|
||||
string = factory->NewTwoByteInternalizedString(
|
||||
string = isolate->factory()->NewTwoByteInternalizedString(
|
||||
Vector<const uc16>::cast(literal_bytes_), hash_field());
|
||||
}
|
||||
set_string(string);
|
||||
@ -159,37 +160,36 @@ bool AstRawString::Compare(void* a, void* b) {
|
||||
}
|
||||
}
|
||||
|
||||
template <typename Factory>
|
||||
FactoryHandle<Factory, String> AstConsString::Allocate(Factory* factory) const {
|
||||
template <typename Isolate>
|
||||
HandleFor<Isolate, String> AstConsString::Allocate(Isolate* isolate) const {
|
||||
if (IsEmpty()) {
|
||||
return factory->empty_string();
|
||||
return isolate->factory()->empty_string();
|
||||
}
|
||||
// AstRawStrings are internalized before AstConsStrings are allocated, so
|
||||
// AstRawString::string() will just work.
|
||||
FactoryHandle<Factory, String> tmp(segment_.string->string().get<Factory>());
|
||||
HandleFor<Isolate, String> tmp(segment_.string->string().get<Isolate>());
|
||||
for (AstConsString::Segment* current = segment_.next; current != nullptr;
|
||||
current = current->next) {
|
||||
tmp = factory
|
||||
->NewConsString(current->string->string().get<Factory>(), tmp,
|
||||
tmp = isolate->factory()
|
||||
->NewConsString(current->string->string().get<Isolate>(), tmp,
|
||||
AllocationType::kOld)
|
||||
.ToHandleChecked();
|
||||
}
|
||||
return tmp;
|
||||
}
|
||||
template EXPORT_TEMPLATE_DEFINE(V8_EXPORT_PRIVATE)
|
||||
Handle<String> AstConsString::Allocate<Factory>(Factory* factory) const;
|
||||
Handle<String> AstConsString::Allocate<Isolate>(Isolate* isolate) const;
|
||||
template EXPORT_TEMPLATE_DEFINE(V8_EXPORT_PRIVATE)
|
||||
OffThreadHandle<String> AstConsString::Allocate<OffThreadFactory>(
|
||||
OffThreadFactory* factory) const;
|
||||
OffThreadHandle<String> AstConsString::Allocate<OffThreadIsolate>(
|
||||
OffThreadIsolate* isolate) const;
|
||||
|
||||
template <typename Factory>
|
||||
FactoryHandle<Factory, String> AstConsString::AllocateFlat(
|
||||
Factory* factory) const {
|
||||
template <typename Isolate>
|
||||
HandleFor<Isolate, String> AstConsString::AllocateFlat(Isolate* isolate) const {
|
||||
if (IsEmpty()) {
|
||||
return factory->empty_string();
|
||||
return isolate->factory()->empty_string();
|
||||
}
|
||||
if (!segment_.next) {
|
||||
return segment_.string->string().get<Factory>();
|
||||
return segment_.string->string().get<Isolate>();
|
||||
}
|
||||
|
||||
int result_length = 0;
|
||||
@ -201,8 +201,9 @@ FactoryHandle<Factory, String> AstConsString::AllocateFlat(
|
||||
}
|
||||
|
||||
if (is_one_byte) {
|
||||
FactoryHandle<Factory, SeqOneByteString> result =
|
||||
factory->NewRawOneByteString(result_length, AllocationType::kOld)
|
||||
HandleFor<Isolate, SeqOneByteString> result =
|
||||
isolate->factory()
|
||||
->NewRawOneByteString(result_length, AllocationType::kOld)
|
||||
.ToHandleChecked();
|
||||
DisallowHeapAllocation no_gc;
|
||||
uint8_t* dest = result->GetChars(no_gc) + result_length;
|
||||
@ -216,8 +217,9 @@ FactoryHandle<Factory, String> AstConsString::AllocateFlat(
|
||||
return result;
|
||||
}
|
||||
|
||||
FactoryHandle<Factory, SeqTwoByteString> result =
|
||||
factory->NewRawTwoByteString(result_length, AllocationType::kOld)
|
||||
HandleFor<Isolate, SeqTwoByteString> result =
|
||||
isolate->factory()
|
||||
->NewRawTwoByteString(result_length, AllocationType::kOld)
|
||||
.ToHandleChecked();
|
||||
DisallowHeapAllocation no_gc;
|
||||
uint16_t* dest = result->GetChars(no_gc) + result_length;
|
||||
@ -237,10 +239,10 @@ FactoryHandle<Factory, String> AstConsString::AllocateFlat(
|
||||
return result;
|
||||
}
|
||||
template EXPORT_TEMPLATE_DEFINE(V8_EXPORT_PRIVATE)
|
||||
Handle<String> AstConsString::AllocateFlat<Factory>(Factory* factory) const;
|
||||
Handle<String> AstConsString::AllocateFlat<Isolate>(Isolate* isolate) const;
|
||||
template EXPORT_TEMPLATE_DEFINE(V8_EXPORT_PRIVATE)
|
||||
OffThreadHandle<String> AstConsString::AllocateFlat<OffThreadFactory>(
|
||||
OffThreadFactory* factory) const;
|
||||
OffThreadHandle<String> AstConsString::AllocateFlat<OffThreadIsolate>(
|
||||
OffThreadIsolate* isolate) const;
|
||||
|
||||
std::forward_list<const AstRawString*> AstConsString::ToRawStrings() const {
|
||||
std::forward_list<const AstRawString*> result;
|
||||
@ -338,23 +340,23 @@ AstConsString* AstValueFactory::NewConsString(const AstRawString* str1,
|
||||
return NewConsString()->AddString(zone_, str1)->AddString(zone_, str2);
|
||||
}
|
||||
|
||||
template <typename Factory>
|
||||
void AstValueFactory::Internalize(Factory* factory) {
|
||||
template <typename Isolate>
|
||||
void AstValueFactory::Internalize(Isolate* isolate) {
|
||||
// Strings need to be internalized before values, because values refer to
|
||||
// strings.
|
||||
for (AstRawString* current = strings_; current != nullptr;) {
|
||||
AstRawString* next = current->next();
|
||||
current->Internalize(factory);
|
||||
current->Internalize(isolate);
|
||||
current = next;
|
||||
}
|
||||
|
||||
ResetStrings();
|
||||
}
|
||||
template EXPORT_TEMPLATE_DEFINE(
|
||||
V8_EXPORT_PRIVATE) void AstValueFactory::Internalize<Factory>(Factory*
|
||||
factory);
|
||||
V8_EXPORT_PRIVATE) void AstValueFactory::Internalize<Isolate>(Isolate*
|
||||
isolate);
|
||||
template EXPORT_TEMPLATE_DEFINE(V8_EXPORT_PRIVATE) void AstValueFactory::
|
||||
Internalize<OffThreadFactory>(OffThreadFactory* factory);
|
||||
Internalize<OffThreadIsolate>(OffThreadIsolate* isolate);
|
||||
|
||||
AstRawString* AstValueFactory::GetString(uint32_t hash_field, bool is_one_byte,
|
||||
Vector<const byte> literal_bytes) {
|
||||
|
@ -32,9 +32,7 @@
|
||||
|
||||
#include "src/base/hashmap.h"
|
||||
#include "src/common/globals.h"
|
||||
#include "src/execution/isolate.h"
|
||||
#include "src/heap/factory.h"
|
||||
#include "src/heap/off-thread-factory.h"
|
||||
#include "src/numbers/conversions.h"
|
||||
|
||||
// Ast(Raw|Cons)String and AstValueFactory are for storing strings and
|
||||
@ -45,6 +43,9 @@
|
||||
namespace v8 {
|
||||
namespace internal {
|
||||
|
||||
class Isolate;
|
||||
class OffThreadIsolate;
|
||||
|
||||
class AstRawString final : public ZoneObject {
|
||||
public:
|
||||
bool IsEmpty() const { return literal_bytes_.length() == 0; }
|
||||
@ -57,8 +58,8 @@ class AstRawString final : public ZoneObject {
|
||||
V8_EXPORT_PRIVATE bool IsOneByteEqualTo(const char* data) const;
|
||||
uint16_t FirstCharacter() const;
|
||||
|
||||
void Internalize(Factory* factory);
|
||||
void Internalize(OffThreadFactory* factory);
|
||||
void Internalize(Isolate* isolate);
|
||||
void Internalize(OffThreadIsolate* isolate);
|
||||
|
||||
// Access the physical representation:
|
||||
bool is_one_byte() const { return is_one_byte_; }
|
||||
@ -143,13 +144,13 @@ class AstConsString final : public ZoneObject {
|
||||
return segment_.string == nullptr;
|
||||
}
|
||||
|
||||
template <typename Factory>
|
||||
template <typename Isolate>
|
||||
EXPORT_TEMPLATE_DECLARE(V8_EXPORT_PRIVATE)
|
||||
FactoryHandle<Factory, String> Allocate(Factory* factory) const;
|
||||
HandleFor<Isolate, String> Allocate(Isolate* isolate) const;
|
||||
|
||||
template <typename Factory>
|
||||
template <typename Isolate>
|
||||
EXPORT_TEMPLATE_DECLARE(V8_EXPORT_PRIVATE)
|
||||
FactoryHandle<Factory, String> AllocateFlat(Factory* factory) const;
|
||||
HandleFor<Isolate, String> AllocateFlat(Isolate* isolate) const;
|
||||
|
||||
std::forward_list<const AstRawString*> ToRawStrings() const;
|
||||
|
||||
@ -311,8 +312,8 @@ class AstValueFactory {
|
||||
V8_EXPORT_PRIVATE AstConsString* NewConsString(const AstRawString* str1,
|
||||
const AstRawString* str2);
|
||||
|
||||
template <typename Factory>
|
||||
void Internalize(Factory* factory);
|
||||
template <typename Isolate>
|
||||
void Internalize(Isolate* isolate);
|
||||
|
||||
#define F(name, str) \
|
||||
const AstRawString* name##_string() const { \
|
||||
@ -358,12 +359,12 @@ class AstValueFactory {
|
||||
};
|
||||
|
||||
extern template EXPORT_TEMPLATE_DECLARE(
|
||||
V8_EXPORT_PRIVATE) void AstValueFactory::Internalize<Factory>(Factory*
|
||||
factory);
|
||||
V8_EXPORT_PRIVATE) void AstValueFactory::Internalize<Isolate>(Isolate*
|
||||
isolate);
|
||||
|
||||
extern template EXPORT_TEMPLATE_DECLARE(
|
||||
V8_EXPORT_PRIVATE) void AstValueFactory::
|
||||
Internalize<OffThreadFactory>(OffThreadFactory* factory);
|
||||
Internalize<OffThreadIsolate>(OffThreadIsolate* isolate);
|
||||
|
||||
} // namespace internal
|
||||
} // namespace v8
|
||||
|
@ -10,6 +10,7 @@
|
||||
#include "src/ast/prettyprinter.h"
|
||||
#include "src/ast/scopes.h"
|
||||
#include "src/base/hashmap.h"
|
||||
#include "src/base/logging.h"
|
||||
#include "src/builtins/builtins-constructor.h"
|
||||
#include "src/builtins/builtins.h"
|
||||
#include "src/common/assert-scope.h"
|
||||
@ -520,7 +521,7 @@ void ObjectLiteral::BuildBoilerplateDescription(Isolate* isolate) {
|
||||
key_literal->AsArrayIndex(&element_index)
|
||||
? isolate->factory()->NewNumberFromUint(element_index)
|
||||
: Handle<Object>::cast(
|
||||
key_literal->AsRawPropertyName()->string().get<Factory>());
|
||||
key_literal->AsRawPropertyName()->string().get<Isolate>());
|
||||
|
||||
Handle<Object> value = GetBoilerplateValue(property->value(), isolate);
|
||||
|
||||
@ -768,12 +769,17 @@ Handle<TemplateObjectDescription> GetTemplateObject::GetOrBuildDescription(
|
||||
this->raw_strings()->length(), AllocationType::kOld);
|
||||
bool raw_and_cooked_match = true;
|
||||
for (int i = 0; i < raw_strings->length(); ++i) {
|
||||
if (this->cooked_strings()->at(i) == nullptr ||
|
||||
*this->raw_strings()->at(i)->string().get<Factory>() !=
|
||||
*this->cooked_strings()->at(i)->string().get<Factory>()) {
|
||||
if (this->raw_strings()->at(i) != this->cooked_strings()->at(i)) {
|
||||
// If the AstRawStrings don't match, then neither should the allocated
|
||||
// Strings, since the AstValueFactory should have deduplicated them
|
||||
// already.
|
||||
DCHECK_IMPLIES(this->cooked_strings()->at(i) != nullptr,
|
||||
*this->cooked_strings()->at(i)->string().get<Isolate>() !=
|
||||
*this->raw_strings()->at(i)->string().get<Isolate>());
|
||||
|
||||
raw_and_cooked_match = false;
|
||||
}
|
||||
raw_strings->set(i, *this->raw_strings()->at(i)->string().get<Factory>());
|
||||
raw_strings->set(i, *this->raw_strings()->at(i)->string().get<Isolate>());
|
||||
}
|
||||
Handle<FixedArray> cooked_strings = raw_strings;
|
||||
if (!raw_and_cooked_match) {
|
||||
@ -782,7 +788,7 @@ Handle<TemplateObjectDescription> GetTemplateObject::GetOrBuildDescription(
|
||||
for (int i = 0; i < cooked_strings->length(); ++i) {
|
||||
if (this->cooked_strings()->at(i) != nullptr) {
|
||||
cooked_strings->set(
|
||||
i, *this->cooked_strings()->at(i)->string().get<Factory>());
|
||||
i, *this->cooked_strings()->at(i)->string().get<Isolate>());
|
||||
} else {
|
||||
cooked_strings->set(i, ReadOnlyRoots(isolate).undefined_value());
|
||||
}
|
||||
@ -967,7 +973,7 @@ Handle<Object> Literal::BuildValue(Isolate* isolate) const {
|
||||
case kHeapNumber:
|
||||
return isolate->factory()->NewNumber<AllocationType::kOld>(number_);
|
||||
case kString:
|
||||
return string_->string().get<Factory>();
|
||||
return string_->string();
|
||||
case kSymbol:
|
||||
return isolate->factory()->home_object_symbol();
|
||||
case kBoolean:
|
||||
|
@ -1177,7 +1177,7 @@ class MaterializedLiteral : public Expression {
|
||||
// Node for capturing a regexp literal.
|
||||
class RegExpLiteral final : public MaterializedLiteral {
|
||||
public:
|
||||
Handle<String> pattern() const { return pattern_->string().get<Factory>(); }
|
||||
Handle<String> pattern() const { return pattern_->string(); }
|
||||
const AstRawString* raw_pattern() const { return pattern_; }
|
||||
int flags() const { return flags_; }
|
||||
|
||||
@ -1507,7 +1507,7 @@ class VariableProxy final : public Expression {
|
||||
public:
|
||||
bool IsValidReferenceExpression() const { return !is_new_target(); }
|
||||
|
||||
Handle<String> name() const { return raw_name()->string().get<Factory>(); }
|
||||
Handle<String> name() const { return raw_name()->string(); }
|
||||
const AstRawString* raw_name() const {
|
||||
return is_resolved() ? var_->raw_name() : raw_name_;
|
||||
}
|
||||
@ -2218,8 +2218,8 @@ class FunctionLiteral final : public Expression {
|
||||
|
||||
// Empty handle means that the function does not have a shared name (i.e.
|
||||
// the name will be set dynamically after creation of the function closure).
|
||||
MaybeHandle<String> GetName(Factory* factory) const {
|
||||
return raw_name_ ? raw_name_->AllocateFlat(factory) : MaybeHandle<String>();
|
||||
MaybeHandle<String> GetName(Isolate* isolate) const {
|
||||
return raw_name_ ? raw_name_->AllocateFlat(isolate) : MaybeHandle<String>();
|
||||
}
|
||||
bool has_shared_name() const { return raw_name_ != nullptr; }
|
||||
const AstConsString* raw_name() const { return raw_name_; }
|
||||
@ -2277,13 +2277,13 @@ class FunctionLiteral final : public Expression {
|
||||
// Returns either name or inferred name as a cstring.
|
||||
std::unique_ptr<char[]> GetDebugName() const;
|
||||
|
||||
Handle<String> GetInferredName(Factory* factory) const {
|
||||
Handle<String> GetInferredName(Isolate* isolate) const {
|
||||
if (!inferred_name_.is_null()) {
|
||||
DCHECK_NULL(raw_inferred_name_);
|
||||
return inferred_name_;
|
||||
}
|
||||
if (raw_inferred_name_ != nullptr) {
|
||||
return raw_inferred_name_->Allocate(factory);
|
||||
return raw_inferred_name_->Allocate(isolate);
|
||||
}
|
||||
UNREACHABLE();
|
||||
}
|
||||
@ -2568,7 +2568,7 @@ class ClassLiteral final : public Expression {
|
||||
|
||||
class NativeFunctionLiteral final : public Expression {
|
||||
public:
|
||||
Handle<String> name() const { return name_->string().get<Factory>(); }
|
||||
Handle<String> name() const { return name_->string(); }
|
||||
const AstRawString* raw_name() const { return name_; }
|
||||
v8::Extension* extension() const { return extension_; }
|
||||
|
||||
|
@ -89,7 +89,7 @@ Handle<PrimitiveHeapObject> ToStringOrUndefined(Isolate* isolate,
|
||||
return (s == nullptr)
|
||||
? Handle<PrimitiveHeapObject>::cast(
|
||||
isolate->factory()->undefined_value())
|
||||
: Handle<PrimitiveHeapObject>::cast(s->string().get<Factory>());
|
||||
: Handle<PrimitiveHeapObject>::cast(s->string().get<Isolate>());
|
||||
}
|
||||
} // namespace
|
||||
|
||||
@ -127,7 +127,7 @@ Handle<FixedArray> SourceTextModuleDescriptor::SerializeRegularExports(
|
||||
|
||||
Handle<FixedArray> export_names = isolate->factory()->NewFixedArray(count);
|
||||
data[index + SourceTextModuleInfo::kRegularExportLocalNameOffset] =
|
||||
it->second->local_name->string().get<Factory>();
|
||||
it->second->local_name->string();
|
||||
data[index + SourceTextModuleInfo::kRegularExportCellIndexOffset] =
|
||||
handle(Smi::FromInt(it->second->cell_index), isolate);
|
||||
data[index + SourceTextModuleInfo::kRegularExportExportNamesOffset] =
|
||||
@ -137,7 +137,7 @@ Handle<FixedArray> SourceTextModuleDescriptor::SerializeRegularExports(
|
||||
// Collect the export names.
|
||||
int i = 0;
|
||||
for (; it != next; ++it) {
|
||||
export_names->set(i++, *it->second->export_name->string().get<Factory>());
|
||||
export_names->set(i++, *it->second->export_name->string().get<Isolate>());
|
||||
}
|
||||
DCHECK_EQ(i, count);
|
||||
|
||||
|
@ -587,7 +587,7 @@ void CallPrinter::PrintLiteral(Handle<Object> value, bool quote) {
|
||||
|
||||
|
||||
void CallPrinter::PrintLiteral(const AstRawString* value, bool quote) {
|
||||
PrintLiteral(value->string().get<Factory>(), quote);
|
||||
PrintLiteral(value->string(), quote);
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
@ -835,7 +835,7 @@ Variable* Scope::LookupInScopeInfo(const AstRawString* name, Scope* cache) {
|
||||
DCHECK_NULL(cache->variables_.Lookup(name));
|
||||
DisallowHeapAllocation no_gc;
|
||||
|
||||
String name_handle = *name->string().get<Factory>();
|
||||
String name_handle = *name->string().get<Isolate>();
|
||||
// The Scope is backed up by ScopeInfo. This means it cannot operate in a
|
||||
// heap-independent mode, and all strings must be internalized immediately. So
|
||||
// it's ok to get the Handle<String> here.
|
||||
@ -2655,7 +2655,7 @@ Variable* ClassScope::LookupPrivateNameInScopeInfo(const AstRawString* name) {
|
||||
DCHECK_NULL(LookupLocalPrivateName(name));
|
||||
DisallowHeapAllocation no_gc;
|
||||
|
||||
String name_handle = *name->string().get<Factory>();
|
||||
String name_handle = *name->string().get<Isolate>();
|
||||
VariableMode mode;
|
||||
InitializationFlag init_flag;
|
||||
MaybeAssignedFlag maybe_assigned_flag;
|
||||
|
@ -8,6 +8,7 @@
|
||||
#include "src/ast/ast-value-factory.h"
|
||||
#include "src/base/threaded-list.h"
|
||||
#include "src/common/globals.h"
|
||||
#include "src/execution/isolate.h"
|
||||
#include "src/zone/zone.h"
|
||||
|
||||
namespace v8 {
|
||||
@ -57,7 +58,7 @@ class Variable final : public ZoneObject {
|
||||
// parameter initializers.
|
||||
void set_scope(Scope* scope) { scope_ = scope; }
|
||||
|
||||
Handle<String> name() const { return name_->string().get<Factory>(); }
|
||||
Handle<String> name() const { return name_->string(); }
|
||||
const AstRawString* raw_name() const { return name_; }
|
||||
VariableMode mode() const { return VariableModeField::decode(bit_field_); }
|
||||
void set_mode(VariableMode mode) {
|
||||
|
@ -564,7 +564,7 @@ MaybeHandle<SharedFunctionInfo> GenerateUnoptimizedCodeForToplevel(
|
||||
Isolate* isolate, Handle<Script> script, ParseInfo* parse_info,
|
||||
AccountingAllocator* allocator, IsCompiledScope* is_compiled_scope) {
|
||||
EnsureSharedFunctionInfosArrayOnScript(script, parse_info, isolate);
|
||||
parse_info->ast_value_factory()->Internalize(isolate->factory());
|
||||
parse_info->ast_value_factory()->Internalize(isolate);
|
||||
|
||||
if (!Compiler::Analyze(parse_info)) return MaybeHandle<SharedFunctionInfo>();
|
||||
DeclarationScope::AllocateScopeInfos(parse_info, isolate);
|
||||
@ -959,7 +959,7 @@ MaybeHandle<SharedFunctionInfo> FinalizeTopLevel(
|
||||
UnoptimizedCompilationJob* outer_function_job,
|
||||
UnoptimizedCompilationJobList* inner_function_jobs) {
|
||||
// Internalize ast values onto the heap.
|
||||
parse_info->ast_value_factory()->Internalize(isolate->factory());
|
||||
parse_info->ast_value_factory()->Internalize(isolate);
|
||||
|
||||
// Create shared function infos for top level and shared function infos array
|
||||
// for inner functions.
|
||||
@ -1357,7 +1357,7 @@ bool Compiler::Compile(Handle<SharedFunctionInfo> shared_info,
|
||||
}
|
||||
|
||||
// Internalize ast values onto the heap.
|
||||
parse_info.ast_value_factory()->Internalize(isolate->factory());
|
||||
parse_info.ast_value_factory()->Internalize(isolate);
|
||||
|
||||
// Finalize compilation of the unoptimized bytecode or asm-js data.
|
||||
if (!FinalizeUnoptimizedCode(&parse_info, isolate, shared_info,
|
||||
@ -1469,7 +1469,7 @@ bool Compiler::FinalizeBackgroundCompileTask(
|
||||
}
|
||||
|
||||
// Parsing has succeeded - finalize compilation.
|
||||
parse_info->ast_value_factory()->Internalize(isolate->factory());
|
||||
parse_info->ast_value_factory()->Internalize(isolate);
|
||||
if (!FinalizeUnoptimizedCode(parse_info, isolate, shared_info,
|
||||
task->outer_function_job(),
|
||||
task->inner_function_jobs())) {
|
||||
|
@ -261,7 +261,7 @@ void ScopeIterator::TryParseAndRetrieveScopes(ReparseStrategy strategy) {
|
||||
|
||||
if (parsing::ParseAny(info_, shared_info, isolate_) &&
|
||||
Rewriter::Rewrite(info_)) {
|
||||
info_->ast_value_factory()->Internalize(isolate_->factory());
|
||||
info_->ast_value_factory()->Internalize(isolate_);
|
||||
DeclarationScope* literal_scope = info_->literal()->scope();
|
||||
|
||||
ScopeChainRetriever scope_chain_retriever(literal_scope, function_,
|
||||
|
@ -761,7 +761,7 @@ bool ParseScript(Isolate* isolate, Handle<Script> script, ParseInfo* parse_info,
|
||||
success = parsing::ParseProgram(parse_info, script, isolate);
|
||||
if (success) {
|
||||
success = Compiler::Analyze(parse_info);
|
||||
parse_info->ast_value_factory()->Internalize(isolate->factory());
|
||||
parse_info->ast_value_factory()->Internalize(isolate);
|
||||
}
|
||||
}
|
||||
if (!success) {
|
||||
|
@ -204,7 +204,7 @@ class BuiltinUnwindInfo;
|
||||
|
||||
#define ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, dst, call) \
|
||||
do { \
|
||||
Isolate* __isolate__ = (isolate); \
|
||||
auto* __isolate__ = (isolate); \
|
||||
ASSIGN_RETURN_ON_EXCEPTION_VALUE(__isolate__, dst, call, \
|
||||
ReadOnlyRoots(__isolate__).exception()); \
|
||||
} while (false)
|
||||
@ -212,21 +212,21 @@ class BuiltinUnwindInfo;
|
||||
#define ASSIGN_RETURN_ON_EXCEPTION(isolate, dst, call, T) \
|
||||
ASSIGN_RETURN_ON_EXCEPTION_VALUE(isolate, dst, call, MaybeHandle<T>())
|
||||
|
||||
#define THROW_NEW_ERROR(isolate, call, T) \
|
||||
do { \
|
||||
Isolate* __isolate__ = (isolate); \
|
||||
return __isolate__->Throw<T>(__isolate__->factory()->call); \
|
||||
#define THROW_NEW_ERROR(isolate, call, T) \
|
||||
do { \
|
||||
auto* __isolate__ = (isolate); \
|
||||
return __isolate__->template Throw<T>(__isolate__->factory()->call); \
|
||||
} while (false)
|
||||
|
||||
#define THROW_NEW_ERROR_RETURN_FAILURE(isolate, call) \
|
||||
do { \
|
||||
Isolate* __isolate__ = (isolate); \
|
||||
auto* __isolate__ = (isolate); \
|
||||
return __isolate__->Throw(*__isolate__->factory()->call); \
|
||||
} while (false)
|
||||
|
||||
#define THROW_NEW_ERROR_RETURN_VALUE(isolate, call, value) \
|
||||
do { \
|
||||
Isolate* __isolate__ = (isolate); \
|
||||
auto* __isolate__ = (isolate); \
|
||||
__isolate__->Throw(*__isolate__->factory()->call); \
|
||||
return value; \
|
||||
} while (false)
|
||||
@ -446,6 +446,16 @@ using DebugObjectCache = std::vector<Handle<HeapObject>>;
|
||||
#define THREAD_LOCAL_TOP_ADDRESS(type, name) \
|
||||
type* name##_address() { return &thread_local_top()->name##_; }
|
||||
|
||||
class Isolate;
|
||||
|
||||
template <>
|
||||
struct HandleTraits<Isolate> {
|
||||
template <typename T>
|
||||
using HandleType = Handle<T>;
|
||||
template <typename T>
|
||||
using MaybeHandleType = v8::internal::MaybeHandle<T>;
|
||||
};
|
||||
|
||||
// HiddenFactory exists so Isolate can privately inherit from it without making
|
||||
// Factory's members available to Isolate directly.
|
||||
class V8_EXPORT_PRIVATE HiddenFactory : private Factory {};
|
||||
@ -774,6 +784,10 @@ class Isolate final : private HiddenFactory {
|
||||
|
||||
void ThrowAt(Handle<JSObject> exception, MessageLocation* location);
|
||||
|
||||
void FatalProcessOutOfHeapMemory(const char* location) {
|
||||
heap()->FatalProcessOutOfMemory(location);
|
||||
}
|
||||
|
||||
void set_console_delegate(debug::ConsoleDelegate* delegate) {
|
||||
console_delegate_ = delegate;
|
||||
}
|
||||
|
@ -1233,7 +1233,7 @@ Handle<String> RenderCallSite(Isolate* isolate, Handle<Object> object,
|
||||
if (ComputeLocation(isolate, location)) {
|
||||
ParseInfo info(isolate, *location->shared());
|
||||
if (parsing::ParseAny(&info, location->shared(), isolate)) {
|
||||
info.ast_value_factory()->Internalize(isolate->factory());
|
||||
info.ast_value_factory()->Internalize(isolate);
|
||||
CallPrinter printer(isolate, location->shared()->IsUserJavaScript());
|
||||
Handle<String> str = printer.Print(info.literal(), location->start_pos());
|
||||
*hint = printer.GetErrorHint();
|
||||
@ -1334,7 +1334,7 @@ Object ErrorUtils::ThrowLoadFromNullOrUndefined(Isolate* isolate,
|
||||
|
||||
ParseInfo info(isolate, *location.shared());
|
||||
if (parsing::ParseAny(&info, location.shared(), isolate)) {
|
||||
info.ast_value_factory()->Internalize(isolate->factory());
|
||||
info.ast_value_factory()->Internalize(isolate);
|
||||
CallPrinter printer(isolate, location.shared()->IsUserJavaScript());
|
||||
Handle<String> str = printer.Print(info.literal(), location.start_pos());
|
||||
|
||||
@ -1351,8 +1351,7 @@ Object ErrorUtils::ThrowLoadFromNullOrUndefined(Isolate* isolate,
|
||||
maybe_property_name = destructuring_prop->key()
|
||||
->AsLiteral()
|
||||
->AsRawPropertyName()
|
||||
->string()
|
||||
.get<Factory>();
|
||||
->string();
|
||||
// Change the message location to point at the property name.
|
||||
pos = destructuring_prop->key()->position();
|
||||
}
|
||||
|
67
src/execution/off-thread-isolate.h
Normal file
67
src/execution/off-thread-isolate.h
Normal file
@ -0,0 +1,67 @@
|
||||
// Copyright 2020 the V8 project authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#ifndef V8_EXECUTION_OFF_THREAD_ISOLATE_H_
|
||||
#define V8_EXECUTION_OFF_THREAD_ISOLATE_H_
|
||||
|
||||
#include "src/base/logging.h"
|
||||
#include "src/handles/handle-for.h"
|
||||
#include "src/heap/off-thread-factory.h"
|
||||
|
||||
namespace v8 {
|
||||
namespace internal {
|
||||
|
||||
class Isolate;
|
||||
|
||||
class OffThreadIsolate;
|
||||
|
||||
template <>
|
||||
struct HandleTraits<OffThreadIsolate> {
|
||||
template <typename T>
|
||||
using HandleType = OffThreadHandle<T>;
|
||||
template <typename T>
|
||||
using MaybeHandleType = OffThreadHandle<T>;
|
||||
};
|
||||
|
||||
// HiddenOffThreadFactory parallels Isolate's HiddenFactory
|
||||
class V8_EXPORT_PRIVATE HiddenOffThreadFactory : private OffThreadFactory {
|
||||
public:
|
||||
// Forward constructors.
|
||||
using OffThreadFactory::OffThreadFactory;
|
||||
};
|
||||
|
||||
// And Isolate-like class that can be passed in to templated methods that need
|
||||
// an isolate syntactically, but are usable off-thread.
|
||||
//
|
||||
// This class holds an OffThreadFactory, but is otherwise effectively a stub
|
||||
// implementation of an Isolate. In particular, it doesn't allow throwing
|
||||
// exceptions, and hard crashes if you try.
|
||||
class V8_EXPORT_PRIVATE OffThreadIsolate : private HiddenOffThreadFactory {
|
||||
public:
|
||||
explicit OffThreadIsolate(Isolate* isolate)
|
||||
: HiddenOffThreadFactory(isolate) {}
|
||||
|
||||
v8::internal::OffThreadFactory* factory() {
|
||||
// Upcast to the privately inherited base-class using c-style casts to avoid
|
||||
// undefined behavior (as static_cast cannot cast across private bases).
|
||||
// NOLINTNEXTLINE (google-readability-casting)
|
||||
return (
|
||||
v8::internal::OffThreadFactory*)this; // NOLINT(readability/casting)
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
OffThreadHandle<T> Throw(OffThreadHandle<Object> exception) {
|
||||
UNREACHABLE();
|
||||
}
|
||||
[[noreturn]] void FatalProcessOutOfHeapMemory(const char* location) {
|
||||
UNREACHABLE();
|
||||
}
|
||||
inline bool CanAllocateInReadOnlySpace() { return false; }
|
||||
inline bool EmptyStringRootIsInitialized() { return true; }
|
||||
};
|
||||
|
||||
} // namespace internal
|
||||
} // namespace v8
|
||||
|
||||
#endif // V8_EXECUTION_OFF_THREAD_ISOLATE_H_
|
@ -1,23 +0,0 @@
|
||||
// Copyright 2020 the V8 project authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#ifndef V8_HANDLES_FACTORY_HANDLES_H_
|
||||
#define V8_HANDLES_FACTORY_HANDLES_H_
|
||||
|
||||
namespace v8 {
|
||||
namespace internal {
|
||||
|
||||
template <typename Impl>
|
||||
struct FactoryTraits;
|
||||
|
||||
template <typename Impl, typename T>
|
||||
using FactoryHandle = typename FactoryTraits<Impl>::template HandleType<T>;
|
||||
template <typename Impl, typename T>
|
||||
using FactoryMaybeHandle =
|
||||
typename FactoryTraits<Impl>::template MaybeHandleType<T>;
|
||||
|
||||
} // namespace internal
|
||||
} // namespace v8
|
||||
|
||||
#endif // V8_HANDLES_FACTORY_HANDLES_H_
|
29
src/handles/handle-for.h
Normal file
29
src/handles/handle-for.h
Normal file
@ -0,0 +1,29 @@
|
||||
// Copyright 2020 the V8 project authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#ifndef V8_HANDLES_HANDLE_FOR_H_
|
||||
#define V8_HANDLES_HANDLE_FOR_H_
|
||||
|
||||
namespace v8 {
|
||||
namespace internal {
|
||||
|
||||
// HandleTraits is specialized for Isolate, Factory, OffThreadIsolate, and
|
||||
// OffThreadFactory.
|
||||
template <typename IsolateOrFactory>
|
||||
struct HandleTraits;
|
||||
|
||||
// HandleFor<X> will return an appropriate Handle type for X, whether X is an
|
||||
// Isolate, a Factory, an OffThreadIsolate, or an OffThreadFactory. This allows
|
||||
// us to use it for both Isolate and Factory based optimisations.
|
||||
template <typename IsolateOrFactory, typename T>
|
||||
using HandleFor =
|
||||
typename HandleTraits<IsolateOrFactory>::template HandleType<T>;
|
||||
template <typename IsolateOrFactory, typename T>
|
||||
using MaybeHandleFor =
|
||||
typename HandleTraits<IsolateOrFactory>::template MaybeHandleType<T>;
|
||||
|
||||
} // namespace internal
|
||||
} // namespace v8
|
||||
|
||||
#endif // V8_HANDLES_HANDLE_FOR_H_
|
@ -12,6 +12,8 @@
|
||||
namespace v8 {
|
||||
namespace internal {
|
||||
|
||||
class OffThreadIsolate;
|
||||
|
||||
HandleBase::HandleBase(Address object, Isolate* isolate)
|
||||
: location_(HandleScope::GetHandle(isolate, object)) {}
|
||||
|
||||
@ -38,28 +40,21 @@ V8_INLINE Handle<T> handle(T object, Isolate* isolate) {
|
||||
return Handle<T>(object, isolate);
|
||||
}
|
||||
|
||||
// Convenience overloads for cases where we want to either create a Handle or an
|
||||
// OffThreadHandle, depending on whether we have a Factory or an
|
||||
// OffThreadFactory.
|
||||
template <typename T>
|
||||
V8_INLINE Handle<T> handle(T object, Factory* factory) {
|
||||
return factory->MakeHandle<T>(object);
|
||||
}
|
||||
template <typename T>
|
||||
V8_INLINE OffThreadHandle<T> handle(T object, OffThreadFactory* factory) {
|
||||
// Convienently, we don't actually need the factory to create this handle.
|
||||
V8_INLINE OffThreadHandle<T> handle(T object, OffThreadIsolate* isolate) {
|
||||
// Convienently, we don't actually need the isolate to create this handle.
|
||||
return OffThreadHandle<T>(object);
|
||||
}
|
||||
|
||||
// Similar convenience overloads for when we already have a Handle, but want
|
||||
// Convenience overloads for when we already have a Handle, but want
|
||||
// either a Handle or an OffThreadHandle.
|
||||
template <typename T>
|
||||
V8_INLINE Handle<T> handle(Handle<T> handle, Factory* factory) {
|
||||
V8_INLINE Handle<T> handle(Handle<T> handle, Isolate* isolate) {
|
||||
return handle;
|
||||
}
|
||||
template <typename T>
|
||||
V8_INLINE OffThreadHandle<T> handle(Handle<T> handle,
|
||||
OffThreadFactory* factory) {
|
||||
OffThreadIsolate* factory) {
|
||||
return OffThreadHandle<T>(*handle);
|
||||
}
|
||||
|
||||
|
@ -12,7 +12,7 @@
|
||||
#include "src/base/macros.h"
|
||||
#include "src/common/checks.h"
|
||||
#include "src/common/globals.h"
|
||||
#include "src/handles/factory-handles.h"
|
||||
#include "src/handles/handle-for.h"
|
||||
#include "src/zone/zone.h"
|
||||
|
||||
namespace v8 {
|
||||
@ -248,15 +248,19 @@ class HandleOrOffThreadHandle {
|
||||
}
|
||||
|
||||
// To minimize the impact of these handles on main-thread callers, we allow
|
||||
// them to implicitly convert to Handles.
|
||||
// them to implicitly convert to Handles and MaybeHandles.
|
||||
template <typename U>
|
||||
operator Handle<U>() {
|
||||
return get<class Factory>();
|
||||
operator Handle<U>() { // NOLINT
|
||||
return get<class Isolate>();
|
||||
}
|
||||
template <typename U>
|
||||
operator MaybeHandle<U>() { // NOLINT
|
||||
return get<class Isolate>();
|
||||
}
|
||||
|
||||
template <typename FactoryType>
|
||||
inline FactoryHandle<FactoryType, T> get() {
|
||||
return get_for(Tag<FactoryType>());
|
||||
template <typename IsolateType>
|
||||
inline HandleFor<IsolateType, T> get() {
|
||||
return get_for(Tag<IsolateType>());
|
||||
}
|
||||
|
||||
inline bool is_null() const { return value_ == 0; }
|
||||
@ -268,14 +272,14 @@ class HandleOrOffThreadHandle {
|
||||
private:
|
||||
// Tagged overloads because we can't specialize the above getter
|
||||
// without also specializing the class.
|
||||
template <typename FactoryType>
|
||||
template <typename IsolateType>
|
||||
struct Tag {};
|
||||
|
||||
V8_INLINE Handle<T> get_for(Tag<class Factory>) {
|
||||
V8_INLINE Handle<T> get_for(Tag<class Isolate>) {
|
||||
DCHECK_NE(which_, kOffThreadHandle);
|
||||
return Handle<T>(reinterpret_cast<Address*>(value_));
|
||||
}
|
||||
V8_INLINE OffThreadHandle<T> get_for(Tag<class OffThreadFactory>) {
|
||||
V8_INLINE OffThreadHandle<T> get_for(Tag<class OffThreadIsolate>) {
|
||||
DCHECK_NE(which_, kHandle);
|
||||
return OffThreadHandle<T>(T::unchecked_cast(Object(value_)));
|
||||
}
|
||||
|
@ -5,6 +5,7 @@
|
||||
#include "src/heap/factory-base.h"
|
||||
|
||||
#include "src/ast/ast.h"
|
||||
#include "src/execution/off-thread-isolate.h"
|
||||
#include "src/handles/handles-inl.h"
|
||||
#include "src/heap/factory.h"
|
||||
#include "src/heap/off-thread-factory.h"
|
||||
@ -15,10 +16,10 @@ namespace v8 {
|
||||
namespace internal {
|
||||
|
||||
template <typename Impl>
|
||||
FactoryHandle<Impl, SeqOneByteString>
|
||||
HandleFor<Impl, SeqOneByteString>
|
||||
FactoryBase<Impl>::NewOneByteInternalizedString(
|
||||
const Vector<const uint8_t>& str, uint32_t hash_field) {
|
||||
FactoryHandle<Impl, SeqOneByteString> result =
|
||||
HandleFor<Impl, SeqOneByteString> result =
|
||||
AllocateRawOneByteInternalizedString(str.length(), hash_field);
|
||||
DisallowHeapAllocation no_gc;
|
||||
MemCopy(result->GetChars(no_gc), str.begin(), str.length());
|
||||
@ -26,10 +27,10 @@ FactoryBase<Impl>::NewOneByteInternalizedString(
|
||||
}
|
||||
|
||||
template <typename Impl>
|
||||
FactoryHandle<Impl, SeqTwoByteString>
|
||||
HandleFor<Impl, SeqTwoByteString>
|
||||
FactoryBase<Impl>::NewTwoByteInternalizedString(const Vector<const uc16>& str,
|
||||
uint32_t hash_field) {
|
||||
FactoryHandle<Impl, SeqTwoByteString> result =
|
||||
HandleFor<Impl, SeqTwoByteString> result =
|
||||
AllocateRawTwoByteInternalizedString(str.length(), hash_field);
|
||||
DisallowHeapAllocation no_gc;
|
||||
MemCopy(result->GetChars(no_gc), str.begin(), str.length() * kUC16Size);
|
||||
@ -37,11 +38,10 @@ FactoryBase<Impl>::NewTwoByteInternalizedString(const Vector<const uc16>& str,
|
||||
}
|
||||
|
||||
template <typename Impl>
|
||||
FactoryMaybeHandle<Impl, SeqOneByteString>
|
||||
FactoryBase<Impl>::NewRawOneByteString(int length, AllocationType allocation) {
|
||||
MaybeHandleFor<Impl, SeqOneByteString> FactoryBase<Impl>::NewRawOneByteString(
|
||||
int length, AllocationType allocation) {
|
||||
if (length > String::kMaxLength || length < 0) {
|
||||
return impl()->template Throw<SeqOneByteString>(
|
||||
impl()->NewInvalidStringLengthError());
|
||||
THROW_NEW_ERROR(isolate(), NewInvalidStringLengthError(), SeqOneByteString);
|
||||
}
|
||||
DCHECK_GT(length, 0); // Use Factory::empty_string() instead.
|
||||
int size = SeqOneByteString::SizeFor(length);
|
||||
@ -49,8 +49,8 @@ FactoryBase<Impl>::NewRawOneByteString(int length, AllocationType allocation) {
|
||||
|
||||
HeapObject result = AllocateRawWithImmortalMap(
|
||||
size, allocation, read_only_roots().one_byte_string_map());
|
||||
FactoryHandle<Impl, SeqOneByteString> string =
|
||||
handle(SeqOneByteString::cast(result), impl());
|
||||
HandleFor<Impl, SeqOneByteString> string =
|
||||
handle(SeqOneByteString::cast(result), isolate());
|
||||
string->set_length(length);
|
||||
string->set_hash_field(String::kEmptyHashField);
|
||||
DCHECK_EQ(size, string->Size());
|
||||
@ -58,11 +58,10 @@ FactoryBase<Impl>::NewRawOneByteString(int length, AllocationType allocation) {
|
||||
}
|
||||
|
||||
template <typename Impl>
|
||||
FactoryMaybeHandle<Impl, SeqTwoByteString>
|
||||
FactoryBase<Impl>::NewRawTwoByteString(int length, AllocationType allocation) {
|
||||
MaybeHandleFor<Impl, SeqTwoByteString> FactoryBase<Impl>::NewRawTwoByteString(
|
||||
int length, AllocationType allocation) {
|
||||
if (length > String::kMaxLength || length < 0) {
|
||||
return impl()->template Throw<SeqTwoByteString>(
|
||||
impl()->NewInvalidStringLengthError());
|
||||
THROW_NEW_ERROR(isolate(), NewInvalidStringLengthError(), SeqTwoByteString);
|
||||
}
|
||||
DCHECK_GT(length, 0); // Use Factory::empty_string() instead.
|
||||
int size = SeqTwoByteString::SizeFor(length);
|
||||
@ -70,8 +69,8 @@ FactoryBase<Impl>::NewRawTwoByteString(int length, AllocationType allocation) {
|
||||
|
||||
HeapObject result = AllocateRawWithImmortalMap(
|
||||
size, allocation, read_only_roots().string_map());
|
||||
FactoryHandle<Impl, SeqTwoByteString> string =
|
||||
handle(SeqTwoByteString::cast(result), impl());
|
||||
HandleFor<Impl, SeqTwoByteString> string =
|
||||
handle(SeqTwoByteString::cast(result), isolate());
|
||||
string->set_length(length);
|
||||
string->set_hash_field(String::kEmptyHashField);
|
||||
DCHECK_EQ(size, string->Size());
|
||||
@ -79,14 +78,14 @@ FactoryBase<Impl>::NewRawTwoByteString(int length, AllocationType allocation) {
|
||||
}
|
||||
|
||||
template <typename Impl>
|
||||
FactoryMaybeHandle<Impl, String> FactoryBase<Impl>::NewConsString(
|
||||
FactoryHandle<Impl, String> left, FactoryHandle<Impl, String> right,
|
||||
MaybeHandleFor<Impl, String> FactoryBase<Impl>::NewConsString(
|
||||
HandleFor<Impl, String> left, HandleFor<Impl, String> right,
|
||||
AllocationType allocation) {
|
||||
if (left->IsThinString()) {
|
||||
left = handle(ThinString::cast(*left).actual(), impl());
|
||||
left = handle(ThinString::cast(*left).actual(), isolate());
|
||||
}
|
||||
if (right->IsThinString()) {
|
||||
right = handle(ThinString::cast(*right).actual(), impl());
|
||||
right = handle(ThinString::cast(*right).actual(), isolate());
|
||||
}
|
||||
int left_length = left->length();
|
||||
if (left_length == 0) return right;
|
||||
@ -104,8 +103,7 @@ FactoryMaybeHandle<Impl, String> FactoryBase<Impl>::NewConsString(
|
||||
// Make sure that an out of memory exception is thrown if the length
|
||||
// of the new cons string is too large.
|
||||
if (length > String::kMaxLength || length < 0) {
|
||||
return impl()->template Throw<String>(
|
||||
impl()->NewInvalidStringLengthError());
|
||||
THROW_NEW_ERROR(isolate(), NewInvalidStringLengthError(), String);
|
||||
}
|
||||
|
||||
bool left_is_one_byte = left->IsOneByteRepresentation();
|
||||
@ -121,7 +119,7 @@ FactoryMaybeHandle<Impl, String> FactoryBase<Impl>::NewConsString(
|
||||
|
||||
STATIC_ASSERT(ConsString::kMinLength <= String::kMaxLength);
|
||||
if (is_one_byte) {
|
||||
FactoryHandle<Impl, SeqOneByteString> result =
|
||||
HandleFor<Impl, SeqOneByteString> result =
|
||||
NewRawOneByteString(length, allocation).ToHandleChecked();
|
||||
DisallowHeapAllocation no_gc;
|
||||
uint8_t* dest = result->GetChars(no_gc);
|
||||
@ -134,7 +132,7 @@ FactoryMaybeHandle<Impl, String> FactoryBase<Impl>::NewConsString(
|
||||
return result;
|
||||
}
|
||||
|
||||
FactoryHandle<Impl, SeqTwoByteString> result =
|
||||
HandleFor<Impl, SeqTwoByteString> result =
|
||||
NewRawTwoByteString(length, allocation).ToHandleChecked();
|
||||
|
||||
DisallowHeapAllocation pointer_stays_valid;
|
||||
@ -148,22 +146,22 @@ FactoryMaybeHandle<Impl, String> FactoryBase<Impl>::NewConsString(
|
||||
}
|
||||
|
||||
template <typename Impl>
|
||||
FactoryHandle<Impl, String> FactoryBase<Impl>::NewConsString(
|
||||
FactoryHandle<Impl, String> left, FactoryHandle<Impl, String> right,
|
||||
int length, bool one_byte, AllocationType allocation) {
|
||||
HandleFor<Impl, String> FactoryBase<Impl>::NewConsString(
|
||||
HandleFor<Impl, String> left, HandleFor<Impl, String> right, int length,
|
||||
bool one_byte, AllocationType allocation) {
|
||||
DCHECK(!left->IsThinString());
|
||||
DCHECK(!right->IsThinString());
|
||||
DCHECK_GE(length, ConsString::kMinLength);
|
||||
DCHECK_LE(length, String::kMaxLength);
|
||||
|
||||
FactoryHandle<Impl, ConsString> result = handle(
|
||||
HandleFor<Impl, ConsString> result = handle(
|
||||
ConsString::cast(
|
||||
one_byte
|
||||
? NewWithImmortalMap(read_only_roots().cons_one_byte_string_map(),
|
||||
allocation)
|
||||
: NewWithImmortalMap(read_only_roots().cons_string_map(),
|
||||
allocation)),
|
||||
impl());
|
||||
isolate());
|
||||
|
||||
DisallowHeapAllocation no_gc;
|
||||
WriteBarrierMode mode = result->GetWriteBarrierMode(no_gc);
|
||||
@ -176,7 +174,7 @@ FactoryHandle<Impl, String> FactoryBase<Impl>::NewConsString(
|
||||
}
|
||||
|
||||
template <typename Impl>
|
||||
FactoryHandle<Impl, SeqOneByteString>
|
||||
HandleFor<Impl, SeqOneByteString>
|
||||
FactoryBase<Impl>::AllocateRawOneByteInternalizedString(int length,
|
||||
uint32_t hash_field) {
|
||||
CHECK_GE(String::kMaxLength, length);
|
||||
@ -190,8 +188,8 @@ FactoryBase<Impl>::AllocateRawOneByteInternalizedString(int length,
|
||||
impl()->CanAllocateInReadOnlySpace() ? AllocationType::kReadOnly
|
||||
: AllocationType::kOld,
|
||||
map);
|
||||
FactoryHandle<Impl, SeqOneByteString> answer =
|
||||
handle(SeqOneByteString::cast(result), impl());
|
||||
HandleFor<Impl, SeqOneByteString> answer =
|
||||
handle(SeqOneByteString::cast(result), isolate());
|
||||
answer->set_length(length);
|
||||
answer->set_hash_field(hash_field);
|
||||
DCHECK_EQ(size, answer->Size());
|
||||
@ -199,7 +197,7 @@ FactoryBase<Impl>::AllocateRawOneByteInternalizedString(int length,
|
||||
}
|
||||
|
||||
template <typename Impl>
|
||||
FactoryHandle<Impl, SeqTwoByteString>
|
||||
HandleFor<Impl, SeqTwoByteString>
|
||||
FactoryBase<Impl>::AllocateRawTwoByteInternalizedString(int length,
|
||||
uint32_t hash_field) {
|
||||
CHECK_GE(String::kMaxLength, length);
|
||||
@ -209,8 +207,8 @@ FactoryBase<Impl>::AllocateRawTwoByteInternalizedString(int length,
|
||||
int size = SeqTwoByteString::SizeFor(length);
|
||||
HeapObject result =
|
||||
AllocateRawWithImmortalMap(size, AllocationType::kOld, map);
|
||||
FactoryHandle<Impl, SeqTwoByteString> answer =
|
||||
handle(SeqTwoByteString::cast(result), impl());
|
||||
HandleFor<Impl, SeqTwoByteString> answer =
|
||||
handle(SeqTwoByteString::cast(result), isolate());
|
||||
answer->set_length(length);
|
||||
answer->set_hash_field(hash_field);
|
||||
DCHECK_EQ(size, result.Size());
|
||||
|
@ -6,7 +6,7 @@
|
||||
#define V8_HEAP_FACTORY_BASE_H_
|
||||
|
||||
#include "src/common/globals.h"
|
||||
#include "src/handles/factory-handles.h"
|
||||
#include "src/handles/handle-for.h"
|
||||
#include "src/roots/roots.h"
|
||||
|
||||
namespace v8 {
|
||||
@ -19,34 +19,33 @@ class SeqTwoByteString;
|
||||
template <typename Impl>
|
||||
class V8_EXPORT_PRIVATE FactoryBase {
|
||||
public:
|
||||
FactoryHandle<Impl, SeqOneByteString> NewOneByteInternalizedString(
|
||||
HandleFor<Impl, SeqOneByteString> NewOneByteInternalizedString(
|
||||
const Vector<const uint8_t>& str, uint32_t hash_field);
|
||||
FactoryHandle<Impl, SeqTwoByteString> NewTwoByteInternalizedString(
|
||||
HandleFor<Impl, SeqTwoByteString> NewTwoByteInternalizedString(
|
||||
const Vector<const uc16>& str, uint32_t hash_field);
|
||||
|
||||
FactoryHandle<Impl, SeqOneByteString> AllocateRawOneByteInternalizedString(
|
||||
HandleFor<Impl, SeqOneByteString> AllocateRawOneByteInternalizedString(
|
||||
int length, uint32_t hash_field);
|
||||
FactoryHandle<Impl, SeqTwoByteString> AllocateRawTwoByteInternalizedString(
|
||||
HandleFor<Impl, SeqTwoByteString> AllocateRawTwoByteInternalizedString(
|
||||
int length, uint32_t hash_field);
|
||||
|
||||
// Allocates and partially initializes an one-byte or two-byte String. The
|
||||
// characters of the string are uninitialized. Currently used in regexp code
|
||||
// only, where they are pretenured.
|
||||
V8_WARN_UNUSED_RESULT FactoryMaybeHandle<Impl, SeqOneByteString>
|
||||
V8_WARN_UNUSED_RESULT MaybeHandleFor<Impl, SeqOneByteString>
|
||||
NewRawOneByteString(int length,
|
||||
AllocationType allocation = AllocationType::kYoung);
|
||||
V8_WARN_UNUSED_RESULT FactoryMaybeHandle<Impl, SeqTwoByteString>
|
||||
V8_WARN_UNUSED_RESULT MaybeHandleFor<Impl, SeqTwoByteString>
|
||||
NewRawTwoByteString(int length,
|
||||
AllocationType allocation = AllocationType::kYoung);
|
||||
// Create a new cons string object which consists of a pair of strings.
|
||||
V8_WARN_UNUSED_RESULT FactoryMaybeHandle<Impl, String> NewConsString(
|
||||
FactoryHandle<Impl, String> left, FactoryHandle<Impl, String> right,
|
||||
V8_WARN_UNUSED_RESULT MaybeHandleFor<Impl, String> NewConsString(
|
||||
HandleFor<Impl, String> left, HandleFor<Impl, String> right,
|
||||
AllocationType allocation = AllocationType::kYoung);
|
||||
|
||||
V8_WARN_UNUSED_RESULT FactoryHandle<Impl, String> NewConsString(
|
||||
FactoryHandle<Impl, String> left, FactoryHandle<Impl, String> right,
|
||||
int length, bool one_byte,
|
||||
AllocationType allocation = AllocationType::kYoung);
|
||||
V8_WARN_UNUSED_RESULT HandleFor<Impl, String> NewConsString(
|
||||
HandleFor<Impl, String> left, HandleFor<Impl, String> right, int length,
|
||||
bool one_byte, AllocationType allocation = AllocationType::kYoung);
|
||||
|
||||
protected:
|
||||
HeapObject AllocateRawWithImmortalMap(
|
||||
@ -56,6 +55,7 @@ class V8_EXPORT_PRIVATE FactoryBase {
|
||||
|
||||
private:
|
||||
Impl* impl() { return static_cast<Impl*>(this); }
|
||||
auto isolate() { return impl()->isolate(); }
|
||||
ReadOnlyRoots read_only_roots() { return impl()->read_only_roots(); }
|
||||
|
||||
HeapObject AllocateRaw(int size, AllocationType allocation,
|
||||
|
@ -101,11 +101,6 @@ Handle<Object> Factory::NewURIError() {
|
||||
MessageTemplate::kURIMalformed);
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
inline MaybeHandle<T> Factory::Throw(Handle<Object> exception) {
|
||||
return isolate()->Throw<T>(exception);
|
||||
}
|
||||
|
||||
ReadOnlyRoots Factory::read_only_roots() { return ReadOnlyRoots(isolate()); }
|
||||
|
||||
} // namespace internal
|
||||
|
@ -221,10 +221,6 @@ Handle<Code> Factory::CodeBuilder::Build() {
|
||||
return BuildInternal(true).ToHandleChecked();
|
||||
}
|
||||
|
||||
void Factory::FatalProcessOutOfHeapMemory(const char* location) {
|
||||
isolate()->heap()->FatalProcessOutOfMemory(location);
|
||||
}
|
||||
|
||||
HeapObject Factory::AllocateRaw(int size, AllocationType allocation,
|
||||
AllocationAlignment alignment) {
|
||||
return isolate()->heap()->AllocateRawWith<Heap::kRetryOrFail>(
|
||||
@ -323,8 +319,8 @@ Handle<PrototypeInfo> Factory::NewPrototypeInfo() {
|
||||
|
||||
Handle<EnumCache> Factory::NewEnumCache(Handle<FixedArray> keys,
|
||||
Handle<FixedArray> indices) {
|
||||
Handle<EnumCache> result = Handle<EnumCache>::cast(
|
||||
NewStruct(ENUM_CACHE_TYPE, AllocationType::kOld));
|
||||
Handle<EnumCache> result =
|
||||
Handle<EnumCache>::cast(NewStruct(ENUM_CACHE_TYPE, AllocationType::kOld));
|
||||
result->set_keys(*keys);
|
||||
result->set_indices(*indices);
|
||||
return result;
|
||||
@ -1594,8 +1590,9 @@ Handle<Cell> Factory::NewCell(Handle<Object> value) {
|
||||
}
|
||||
|
||||
Handle<FeedbackCell> Factory::NewNoClosuresCell(Handle<HeapObject> value) {
|
||||
HeapObject result = AllocateRawWithImmortalMap(FeedbackCell::kAlignedSize,
|
||||
AllocationType::kOld, *no_closures_cell_map());
|
||||
HeapObject result =
|
||||
AllocateRawWithImmortalMap(FeedbackCell::kAlignedSize,
|
||||
AllocationType::kOld, *no_closures_cell_map());
|
||||
Handle<FeedbackCell> cell(FeedbackCell::cast(result), isolate());
|
||||
cell->set_value(*value);
|
||||
cell->set_interrupt_budget(FeedbackCell::GetInitialInterruptBudget());
|
||||
@ -1604,8 +1601,9 @@ Handle<FeedbackCell> Factory::NewNoClosuresCell(Handle<HeapObject> value) {
|
||||
}
|
||||
|
||||
Handle<FeedbackCell> Factory::NewOneClosureCell(Handle<HeapObject> value) {
|
||||
HeapObject result = AllocateRawWithImmortalMap(FeedbackCell::kAlignedSize,
|
||||
AllocationType::kOld, *one_closure_cell_map());
|
||||
HeapObject result =
|
||||
AllocateRawWithImmortalMap(FeedbackCell::kAlignedSize,
|
||||
AllocationType::kOld, *one_closure_cell_map());
|
||||
Handle<FeedbackCell> cell(FeedbackCell::cast(result), isolate());
|
||||
cell->set_value(*value);
|
||||
cell->set_interrupt_budget(FeedbackCell::GetInitialInterruptBudget());
|
||||
@ -1615,7 +1613,8 @@ Handle<FeedbackCell> Factory::NewOneClosureCell(Handle<HeapObject> value) {
|
||||
|
||||
Handle<FeedbackCell> Factory::NewManyClosuresCell(Handle<HeapObject> value) {
|
||||
HeapObject result = AllocateRawWithImmortalMap(FeedbackCell::kAlignedSize,
|
||||
AllocationType::kOld, *many_closures_cell_map());
|
||||
AllocationType::kOld,
|
||||
*many_closures_cell_map());
|
||||
Handle<FeedbackCell> cell(FeedbackCell::cast(result), isolate());
|
||||
cell->set_value(*value);
|
||||
cell->set_interrupt_budget(FeedbackCell::GetInitialInterruptBudget());
|
||||
@ -3214,7 +3213,7 @@ Handle<SharedFunctionInfo> Factory::NewSharedFunctionInfoForLiteral(
|
||||
FunctionLiteral* literal, Handle<Script> script, bool is_toplevel) {
|
||||
FunctionKind kind = literal->kind();
|
||||
Handle<SharedFunctionInfo> shared = NewSharedFunctionInfoForBuiltin(
|
||||
literal->GetName(this), Builtins::kCompileLazy, kind);
|
||||
literal->GetName(isolate()), Builtins::kCompileLazy, kind);
|
||||
SharedFunctionInfo::InitFromFunctionLiteral(isolate(), shared, literal,
|
||||
is_toplevel);
|
||||
shared->SetScript(ReadOnlyRoots(isolate()), *script,
|
||||
|
@ -109,7 +109,7 @@ enum FunctionMode {
|
||||
class Factory;
|
||||
|
||||
template <>
|
||||
struct FactoryTraits<Factory> {
|
||||
struct HandleTraits<Factory> {
|
||||
template <typename T>
|
||||
using HandleType = Handle<T>;
|
||||
template <typename T>
|
||||
@ -120,10 +120,7 @@ struct FactoryTraits<Factory> {
|
||||
class V8_EXPORT_PRIVATE Factory : public FactoryBase<Factory> {
|
||||
public:
|
||||
inline ReadOnlyRoots read_only_roots();
|
||||
template <typename T>
|
||||
Handle<T> MakeHandle(T obj) {
|
||||
return handle(obj, isolate());
|
||||
}
|
||||
|
||||
Handle<Oddball> NewOddball(Handle<Map> map, const char* to_string,
|
||||
Handle<Object> to_number, const char* type_of,
|
||||
byte kind);
|
||||
@ -1003,12 +1000,6 @@ class V8_EXPORT_PRIVATE Factory : public FactoryBase<Factory> {
|
||||
// Customization points for FactoryBase
|
||||
HeapObject AllocateRaw(int size, AllocationType allocation,
|
||||
AllocationAlignment alignment = kWordAligned);
|
||||
template <typename T>
|
||||
inline MaybeHandle<T> Throw(Handle<Object> exception);
|
||||
[[noreturn]] void FatalProcessOutOfHeapMemory(const char* location);
|
||||
bool CanAllocateInReadOnlySpace();
|
||||
bool EmptyStringRootIsInitialized();
|
||||
// ------
|
||||
|
||||
Isolate* isolate() {
|
||||
// Downcast to the privately inherited sub-class using c-style casts to
|
||||
@ -1017,6 +1008,12 @@ class V8_EXPORT_PRIVATE Factory : public FactoryBase<Factory> {
|
||||
// NOLINTNEXTLINE (google-readability-casting)
|
||||
return (Isolate*)this; // NOLINT(readability/casting)
|
||||
}
|
||||
bool CanAllocateInReadOnlySpace();
|
||||
bool EmptyStringRootIsInitialized();
|
||||
|
||||
Handle<String> MakeOrFindTwoCharacterString(uint16_t c1, uint16_t c2);
|
||||
|
||||
// ------
|
||||
|
||||
HeapObject AllocateRawWithAllocationSite(
|
||||
Handle<Map> map, AllocationType allocation,
|
||||
@ -1065,8 +1062,6 @@ class V8_EXPORT_PRIVATE Factory : public FactoryBase<Factory> {
|
||||
MaybeHandle<String> NewStringFromTwoByte(const uc16* string, int length,
|
||||
AllocationType allocation);
|
||||
|
||||
Handle<String> MakeOrFindTwoCharacterString(uint16_t c1, uint16_t c2);
|
||||
|
||||
// Attempt to find the number in a small cache. If we finds it, return
|
||||
// the string representation of the number. Otherwise return undefined.
|
||||
Handle<Object> NumberToStringCacheGet(Object number, int hash);
|
||||
|
@ -212,10 +212,5 @@ HeapObject OffThreadFactory::AllocateRaw(int size, AllocationType allocation,
|
||||
return result.ToObjectChecked();
|
||||
}
|
||||
|
||||
void OffThreadFactory::FatalProcessOutOfHeapMemory(const char* location) {
|
||||
// TODO(leszeks): Do something reasonable.
|
||||
UNREACHABLE();
|
||||
}
|
||||
|
||||
} // namespace internal
|
||||
} // namespace v8
|
||||
|
@ -23,11 +23,12 @@ namespace internal {
|
||||
class AstValueFactory;
|
||||
class AstRawString;
|
||||
class AstConsString;
|
||||
class OffThreadIsolate;
|
||||
|
||||
class OffThreadFactory;
|
||||
|
||||
template <>
|
||||
struct FactoryTraits<OffThreadFactory> {
|
||||
struct HandleTraits<OffThreadFactory> {
|
||||
template <typename T>
|
||||
using HandleType = OffThreadHandle<T>;
|
||||
template <typename T>
|
||||
@ -70,18 +71,21 @@ class V8_EXPORT_PRIVATE OffThreadFactory
|
||||
// Customization points for FactoryBase.
|
||||
HeapObject AllocateRaw(int size, AllocationType allocation,
|
||||
AllocationAlignment alignment = kWordAligned);
|
||||
template <typename T>
|
||||
OffThreadHandle<T> Throw(OffThreadHandle<Object> exception) {
|
||||
// TODO(leszeks): Figure out what to do here.
|
||||
return OffThreadHandle<T>();
|
||||
|
||||
OffThreadIsolate* isolate() {
|
||||
// Downcast to the privately inherited sub-class using c-style casts to
|
||||
// avoid undefined behavior (as static_cast cannot cast across private
|
||||
// bases).
|
||||
// NOLINTNEXTLINE (google-readability-casting)
|
||||
return (OffThreadIsolate*)this; // NOLINT(readability/casting)
|
||||
}
|
||||
[[noreturn]] void FatalProcessOutOfHeapMemory(const char* location);
|
||||
inline bool CanAllocateInReadOnlySpace() { return false; }
|
||||
inline bool EmptyStringRootIsInitialized() { return true; }
|
||||
// ------
|
||||
|
||||
OffThreadHandle<String> MakeOrFindTwoCharacterString(uint16_t c1,
|
||||
uint16_t c2);
|
||||
// ------
|
||||
|
||||
ReadOnlyRoots roots_;
|
||||
OffThreadSpace space_;
|
||||
|
@ -772,7 +772,7 @@ class BytecodeGenerator::TopLevelDeclarationsBuilder final : public ZoneObject {
|
||||
int start = array_index;
|
||||
#endif
|
||||
if (decl->IsVariableDeclaration()) {
|
||||
data->set(array_index++, *var->raw_name()->string().get<Factory>());
|
||||
data->set(array_index++, *var->raw_name()->string().get<Isolate>());
|
||||
DCHECK_EQ(start + kGlobalVariableDeclarationSize, array_index);
|
||||
} else {
|
||||
FunctionLiteral* f = static_cast<FunctionDeclaration*>(decl)->fun();
|
||||
|
@ -376,7 +376,7 @@ Handle<Object> ConstantArrayBuilder::Entry::ToHandle(Isolate* isolate) const {
|
||||
// TODO(leszeks): There's probably a better value we could use here.
|
||||
return isolate->factory()->the_hole_value();
|
||||
case Tag::kRawString:
|
||||
return raw_string_->string().get<Factory>();
|
||||
return raw_string_->string();
|
||||
case Tag::kHeapNumber:
|
||||
return isolate->factory()->NewNumber<AllocationType::kOld>(heap_number_);
|
||||
case Tag::kBigInt:
|
||||
|
@ -175,7 +175,7 @@ void InterpreterCompilationJob::CheckAndPrintBytecodeMismatch(
|
||||
Isolate* isolate, Handle<Script> script, Handle<BytecodeArray> bytecode) {
|
||||
int first_mismatch = generator()->CheckBytecodeMatches(bytecode);
|
||||
if (first_mismatch >= 0) {
|
||||
parse_info()->ast_value_factory()->Internalize(isolate->factory());
|
||||
parse_info()->ast_value_factory()->Internalize(isolate);
|
||||
DeclarationScope::AllocateScopeInfos(parse_info(), isolate);
|
||||
|
||||
Handle<BytecodeArray> new_bytecode =
|
||||
@ -184,8 +184,7 @@ void InterpreterCompilationJob::CheckAndPrintBytecodeMismatch(
|
||||
std::cerr << "Bytecode mismatch";
|
||||
#ifdef OBJECT_PRINT
|
||||
std::cerr << " found for function: ";
|
||||
Handle<String> name =
|
||||
parse_info()->function_name()->string().get<Factory>();
|
||||
Handle<String> name = parse_info()->function_name()->string();
|
||||
if (name->length() == 0) {
|
||||
std::cerr << "anonymous";
|
||||
} else {
|
||||
|
@ -516,8 +516,7 @@ Handle<ClassBoilerplate> ClassBoilerplate::BuildClassBoilerplate(
|
||||
desc.AddIndexedProperty(isolate, index, value_kind, value_index);
|
||||
|
||||
} else {
|
||||
Handle<String> name =
|
||||
key_literal->AsRawPropertyName()->string().get<Factory>();
|
||||
Handle<String> name = key_literal->AsRawPropertyName()->string();
|
||||
DCHECK(name->IsInternalizedString());
|
||||
desc.AddNamedProperty(isolate, name, value_kind, value_index);
|
||||
}
|
||||
|
@ -5385,11 +5385,11 @@ void SharedFunctionInfo::InitFromFunctionLiteral(
|
||||
scope_data->Serialize(shared_info->GetIsolate());
|
||||
|
||||
data = isolate->factory()->NewUncompiledDataWithPreparseData(
|
||||
lit->GetInferredName(isolate->factory()), lit->start_position(),
|
||||
lit->GetInferredName(isolate), lit->start_position(),
|
||||
lit->end_position(), preparse_data);
|
||||
} else {
|
||||
data = isolate->factory()->NewUncompiledDataWithoutPreparseData(
|
||||
lit->GetInferredName(isolate->factory()), lit->start_position(),
|
||||
lit->GetInferredName(isolate), lit->start_position(),
|
||||
lit->end_position());
|
||||
}
|
||||
|
||||
|
@ -1058,7 +1058,7 @@ Handle<SourceTextModuleInfo> SourceTextModuleInfo::New(
|
||||
isolate->factory()->NewFixedArray(size);
|
||||
for (const auto& elem : descr->module_requests()) {
|
||||
module_requests->set(elem.second.index,
|
||||
*elem.first->string().get<Factory>());
|
||||
*elem.first->string().get<Isolate>());
|
||||
module_request_positions->set(elem.second.index,
|
||||
Smi::FromInt(elem.second.position));
|
||||
}
|
||||
|
@ -637,7 +637,7 @@ FunctionLiteral* Parser::DoParseProgram(Isolate* isolate, ParseInfo* info) {
|
||||
// conflicting var declarations with outer scope-info-backed scopes.
|
||||
if (info->is_eval()) {
|
||||
DCHECK(parsing_on_main_thread_);
|
||||
info->ast_value_factory()->Internalize(isolate->factory());
|
||||
info->ast_value_factory()->Internalize(isolate);
|
||||
}
|
||||
CheckConflictingVarDeclarations(scope);
|
||||
|
||||
@ -809,7 +809,7 @@ FunctionLiteral* Parser::ParseFunction(Isolate* isolate, ParseInfo* info,
|
||||
if (V8_UNLIKELY(FLAG_log_function_events) && result != nullptr) {
|
||||
double ms = timer.Elapsed().InMillisecondsF();
|
||||
// We need to make sure that the debug-name is available.
|
||||
ast_value_factory()->Internalize(isolate->factory());
|
||||
ast_value_factory()->Internalize(isolate);
|
||||
DeclarationScope* function_scope = result->scope();
|
||||
std::unique_ptr<char[]> function_name = result->GetDebugName();
|
||||
LOG(isolate,
|
||||
|
@ -83,7 +83,7 @@ bool ParseFunction(ParseInfo* info, Handle<SharedFunctionInfo> shared_info,
|
||||
result = parser.ParseFunction(isolate, info, shared_info);
|
||||
info->set_literal(result);
|
||||
if (result) {
|
||||
info->ast_value_factory()->Internalize(isolate->factory());
|
||||
info->ast_value_factory()->Internalize(isolate);
|
||||
if (info->is_eval()) {
|
||||
info->set_allow_eval_cache(parser.allow_eval_cache());
|
||||
}
|
||||
|
@ -16,7 +16,7 @@ namespace internal {
|
||||
|
||||
Handle<String> PendingCompilationErrorHandler::MessageDetails::ArgumentString(
|
||||
Isolate* isolate) const {
|
||||
if (arg_ != nullptr) return arg_->string().get<Factory>();
|
||||
if (arg_ != nullptr) return arg_->string();
|
||||
if (char_arg_ != nullptr) {
|
||||
return isolate->factory()
|
||||
->NewStringFromUtf8(CStrVector(char_arg_))
|
||||
@ -83,7 +83,7 @@ void PendingCompilationErrorHandler::ReportErrors(
|
||||
} else {
|
||||
DCHECK(has_pending_error());
|
||||
// Internalize ast values for throwing the pending error.
|
||||
ast_value_factory->Internalize(isolate->factory());
|
||||
ast_value_factory->Internalize(isolate);
|
||||
ThrowPendingError(isolate, script);
|
||||
}
|
||||
}
|
||||
|
@ -170,7 +170,7 @@ TEST(InterpreterLoadLiteral) {
|
||||
|
||||
builder.LoadLiteral(-2.1e19).Return();
|
||||
|
||||
ast_factory.Internalize(isolate->factory());
|
||||
ast_factory.Internalize(isolate);
|
||||
Handle<BytecodeArray> bytecode_array = builder.ToBytecodeArray(isolate);
|
||||
|
||||
InterpreterTester tester(isolate, bytecode_array);
|
||||
@ -189,14 +189,14 @@ TEST(InterpreterLoadLiteral) {
|
||||
const AstRawString* raw_string = ast_factory.GetOneByteString("String");
|
||||
builder.LoadLiteral(raw_string).Return();
|
||||
|
||||
ast_factory.Internalize(isolate->factory());
|
||||
ast_factory.Internalize(isolate);
|
||||
Handle<BytecodeArray> bytecode_array = builder.ToBytecodeArray(isolate);
|
||||
|
||||
InterpreterTester tester(isolate, bytecode_array);
|
||||
auto callable = tester.GetCallable<>();
|
||||
Handle<Object> return_val = callable().ToHandleChecked();
|
||||
CHECK(i::String::cast(*return_val)
|
||||
.Equals(*raw_string->string().get<Factory>()));
|
||||
.Equals(*raw_string->string().get<Isolate>()));
|
||||
}
|
||||
}
|
||||
|
||||
@ -535,7 +535,7 @@ TEST(InterpreterStringAdd) {
|
||||
builder.LoadLiteral(test_cases[i].lhs).StoreAccumulatorInRegister(reg);
|
||||
LoadLiteralForTest(&builder, test_cases[i].rhs);
|
||||
builder.BinaryOperation(Token::Value::ADD, reg, GetIndex(slot)).Return();
|
||||
ast_factory.Internalize(isolate->factory());
|
||||
ast_factory.Internalize(isolate);
|
||||
Handle<BytecodeArray> bytecode_array = builder.ToBytecodeArray(isolate);
|
||||
|
||||
InterpreterTester tester(isolate, bytecode_array, metadata);
|
||||
@ -603,7 +603,7 @@ TEST(InterpreterParameter8) {
|
||||
.BinaryOperation(Token::Value::ADD, builder.Parameter(5), GetIndex(slot5))
|
||||
.BinaryOperation(Token::Value::ADD, builder.Parameter(6), GetIndex(slot6))
|
||||
.Return();
|
||||
ast_factory.Internalize(isolate->factory());
|
||||
ast_factory.Internalize(isolate);
|
||||
Handle<BytecodeArray> bytecode_array = builder.ToBytecodeArray(isolate);
|
||||
|
||||
InterpreterTester tester(isolate, bytecode_array, metadata);
|
||||
@ -743,7 +743,7 @@ TEST(InterpreterBinaryOpTypeFeedback) {
|
||||
LoadLiteralForTest(&builder, test_case.arg2);
|
||||
builder.BinaryOperation(test_case.op, reg, GetIndex(slot0)).Return();
|
||||
|
||||
ast_factory.Internalize(isolate->factory());
|
||||
ast_factory.Internalize(isolate);
|
||||
Handle<BytecodeArray> bytecode_array = builder.ToBytecodeArray(isolate);
|
||||
|
||||
InterpreterTester tester(isolate, bytecode_array, metadata);
|
||||
@ -849,7 +849,7 @@ TEST(InterpreterBinaryOpSmiTypeFeedback) {
|
||||
.BinaryOperation(test_case.op, reg, GetIndex(slot0))
|
||||
.Return();
|
||||
|
||||
ast_factory.Internalize(isolate->factory());
|
||||
ast_factory.Internalize(isolate);
|
||||
Handle<BytecodeArray> bytecode_array = builder.ToBytecodeArray(isolate);
|
||||
|
||||
InterpreterTester tester(isolate, bytecode_array, metadata);
|
||||
@ -1146,7 +1146,7 @@ TEST(InterpreterLoadNamedProperty) {
|
||||
BytecodeArrayBuilder builder(zone, 1, 0, &feedback_spec);
|
||||
|
||||
builder.LoadNamedProperty(builder.Receiver(), name, GetIndex(slot)).Return();
|
||||
ast_factory.Internalize(isolate->factory());
|
||||
ast_factory.Internalize(isolate);
|
||||
Handle<BytecodeArray> bytecode_array = builder.ToBytecodeArray(isolate);
|
||||
|
||||
InterpreterTester tester(isolate, bytecode_array, metadata);
|
||||
@ -1200,7 +1200,7 @@ TEST(InterpreterLoadKeyedProperty) {
|
||||
builder.LoadLiteral(key)
|
||||
.LoadKeyedProperty(builder.Receiver(), GetIndex(slot))
|
||||
.Return();
|
||||
ast_factory.Internalize(isolate->factory());
|
||||
ast_factory.Internalize(isolate);
|
||||
Handle<BytecodeArray> bytecode_array = builder.ToBytecodeArray(isolate);
|
||||
|
||||
InterpreterTester tester(isolate, bytecode_array, metadata);
|
||||
@ -1243,7 +1243,7 @@ TEST(InterpreterStoreNamedProperty) {
|
||||
.StoreNamedProperty(builder.Receiver(), name, GetIndex(slot),
|
||||
LanguageMode::kStrict)
|
||||
.Return();
|
||||
ast_factory.Internalize(isolate->factory());
|
||||
ast_factory.Internalize(isolate);
|
||||
Handle<BytecodeArray> bytecode_array = builder.ToBytecodeArray(isolate);
|
||||
|
||||
InterpreterTester tester(isolate, bytecode_array, metadata);
|
||||
@ -1308,7 +1308,7 @@ TEST(InterpreterStoreKeyedProperty) {
|
||||
.StoreKeyedProperty(builder.Receiver(), Register(0), GetIndex(slot),
|
||||
i::LanguageMode::kSloppy)
|
||||
.Return();
|
||||
ast_factory.Internalize(isolate->factory());
|
||||
ast_factory.Internalize(isolate);
|
||||
Handle<BytecodeArray> bytecode_array = builder.ToBytecodeArray(isolate);
|
||||
|
||||
InterpreterTester tester(isolate, bytecode_array, metadata);
|
||||
@ -1368,7 +1368,7 @@ TEST(InterpreterCall) {
|
||||
builder.CallProperty(reg, args, call_slot_index);
|
||||
|
||||
builder.Return();
|
||||
ast_factory.Internalize(isolate->factory());
|
||||
ast_factory.Internalize(isolate);
|
||||
Handle<BytecodeArray> bytecode_array = builder.ToBytecodeArray(isolate);
|
||||
|
||||
InterpreterTester tester(isolate, bytecode_array, metadata);
|
||||
@ -1390,7 +1390,7 @@ TEST(InterpreterCall) {
|
||||
.MoveRegister(builder.Receiver(), args[0]);
|
||||
builder.CallProperty(reg, args, call_slot_index);
|
||||
builder.Return();
|
||||
ast_factory.Internalize(isolate->factory());
|
||||
ast_factory.Internalize(isolate);
|
||||
Handle<BytecodeArray> bytecode_array = builder.ToBytecodeArray(isolate);
|
||||
|
||||
InterpreterTester tester(isolate, bytecode_array, metadata);
|
||||
@ -1424,7 +1424,7 @@ TEST(InterpreterCall) {
|
||||
|
||||
builder.Return();
|
||||
|
||||
ast_factory.Internalize(isolate->factory());
|
||||
ast_factory.Internalize(isolate);
|
||||
Handle<BytecodeArray> bytecode_array = builder.ToBytecodeArray(isolate);
|
||||
|
||||
InterpreterTester tester(isolate, bytecode_array, metadata);
|
||||
@ -1473,7 +1473,7 @@ TEST(InterpreterCall) {
|
||||
|
||||
builder.Return();
|
||||
|
||||
ast_factory.Internalize(isolate->factory());
|
||||
ast_factory.Internalize(isolate);
|
||||
Handle<BytecodeArray> bytecode_array = builder.ToBytecodeArray(isolate);
|
||||
|
||||
InterpreterTester tester(isolate, bytecode_array, metadata);
|
||||
@ -1691,7 +1691,7 @@ TEST(InterpreterJumpConstantWith16BitOperand) {
|
||||
builder.LoadAccumulatorWithRegister(reg);
|
||||
builder.Return();
|
||||
|
||||
ast_factory.Internalize(isolate->factory());
|
||||
ast_factory.Internalize(isolate);
|
||||
Handle<BytecodeArray> bytecode_array = builder.ToBytecodeArray(isolate);
|
||||
BytecodeArrayIterator iterator(bytecode_array);
|
||||
|
||||
@ -1735,7 +1735,7 @@ TEST(InterpreterJumpWith32BitOperand) {
|
||||
builder.Bind(&done);
|
||||
builder.Return();
|
||||
|
||||
ast_factory.Internalize(isolate->factory());
|
||||
ast_factory.Internalize(isolate);
|
||||
Handle<BytecodeArray> bytecode_array = builder.ToBytecodeArray(isolate);
|
||||
|
||||
BytecodeArrayIterator iterator(bytecode_array);
|
||||
@ -1873,7 +1873,7 @@ TEST(InterpreterHeapNumberComparisons) {
|
||||
.CompareOperation(comparison, r0, GetIndex(slot))
|
||||
.Return();
|
||||
|
||||
ast_factory.Internalize(isolate->factory());
|
||||
ast_factory.Internalize(isolate);
|
||||
Handle<BytecodeArray> bytecode_array = builder.ToBytecodeArray(isolate);
|
||||
InterpreterTester tester(isolate, bytecode_array, metadata);
|
||||
auto callable = tester.GetCallable<>();
|
||||
@ -1920,7 +1920,7 @@ TEST(InterpreterBigIntComparisons) {
|
||||
.CompareOperation(comparison, r0, GetIndex(slot))
|
||||
.Return();
|
||||
|
||||
ast_factory.Internalize(isolate->factory());
|
||||
ast_factory.Internalize(isolate);
|
||||
Handle<BytecodeArray> bytecode_array = builder.ToBytecodeArray(isolate);
|
||||
InterpreterTester tester(isolate, bytecode_array, metadata);
|
||||
auto callable = tester.GetCallable<>();
|
||||
@ -1968,7 +1968,7 @@ TEST(InterpreterStringComparisons) {
|
||||
.CompareOperation(comparison, r0, GetIndex(slot))
|
||||
.Return();
|
||||
|
||||
ast_factory.Internalize(isolate->factory());
|
||||
ast_factory.Internalize(isolate);
|
||||
Handle<BytecodeArray> bytecode_array = builder.ToBytecodeArray(isolate);
|
||||
InterpreterTester tester(isolate, bytecode_array, metadata);
|
||||
auto callable = tester.GetCallable<>();
|
||||
@ -2080,7 +2080,7 @@ TEST(InterpreterMixedComparisons) {
|
||||
builder.CompareOperation(comparison, lhs_reg, GetIndex(slot))
|
||||
.Return();
|
||||
|
||||
ast_factory.Internalize(isolate->factory());
|
||||
ast_factory.Internalize(isolate);
|
||||
Handle<BytecodeArray> bytecode_array =
|
||||
builder.ToBytecodeArray(isolate);
|
||||
InterpreterTester tester(isolate, bytecode_array, metadata);
|
||||
@ -2295,7 +2295,7 @@ TEST(InterpreterTestIn) {
|
||||
.CompareOperation(Token::Value::IN, r0, GetIndex(slot))
|
||||
.Return();
|
||||
|
||||
ast_factory.Internalize(isolate->factory());
|
||||
ast_factory.Internalize(isolate);
|
||||
Handle<BytecodeArray> bytecode_array = builder.ToBytecodeArray(isolate);
|
||||
InterpreterTester tester(isolate, bytecode_array, metadata);
|
||||
auto callable = tester.GetCallable<>();
|
||||
@ -2353,7 +2353,7 @@ TEST(InterpreterUnaryNotNonBoolean) {
|
||||
Register r0(0);
|
||||
LoadLiteralForTest(&builder, object_type_tuples[i].first);
|
||||
builder.LogicalNot(ToBooleanMode::kConvertToBoolean).Return();
|
||||
ast_factory.Internalize(isolate->factory());
|
||||
ast_factory.Internalize(isolate);
|
||||
Handle<BytecodeArray> bytecode_array = builder.ToBytecodeArray(isolate);
|
||||
InterpreterTester tester(isolate, bytecode_array);
|
||||
auto callable = tester.GetCallable<>();
|
||||
|
@ -907,7 +907,7 @@ void TestScanRegExp(const char* re_source, const char* expected) {
|
||||
HashSeed(CcTest::i_isolate()));
|
||||
const i::AstRawString* current_symbol =
|
||||
scanner.CurrentSymbol(&ast_value_factory);
|
||||
ast_value_factory.Internalize(CcTest::i_isolate()->factory());
|
||||
ast_value_factory.Internalize(CcTest::i_isolate());
|
||||
i::Handle<i::String> val = current_symbol->string();
|
||||
i::DisallowHeapAllocation no_alloc;
|
||||
i::String::FlatContent content = val->GetFlatContent(no_alloc);
|
||||
@ -1061,7 +1061,7 @@ TEST(ScopeUsesArgumentsSuperThis) {
|
||||
info.set_allow_lazy_parsing(false);
|
||||
CHECK(i::parsing::ParseProgram(&info, script, isolate));
|
||||
CHECK(i::Rewriter::Rewrite(&info));
|
||||
info.ast_value_factory()->Internalize(isolate->factory());
|
||||
info.ast_value_factory()->Internalize(isolate);
|
||||
CHECK(i::DeclarationScope::Analyze(&info));
|
||||
i::DeclarationScope::AllocateScopeInfos(&info, isolate);
|
||||
CHECK_NOT_NULL(info.literal());
|
||||
@ -3312,7 +3312,7 @@ TEST(SerializationOfMaybeAssignmentFlag) {
|
||||
i::AstValueFactory avf(&zone, isolate->ast_string_constants(),
|
||||
HashSeed(isolate));
|
||||
const i::AstRawString* name = avf.GetOneByteString("result");
|
||||
avf.Internalize(isolate->factory());
|
||||
avf.Internalize(isolate);
|
||||
i::Handle<i::String> str = name->string();
|
||||
CHECK(str->IsInternalizedString());
|
||||
i::DeclarationScope* script_scope =
|
||||
@ -3362,7 +3362,7 @@ TEST(IfArgumentsArrayAccessedThenParametersMaybeAssigned) {
|
||||
i::AstValueFactory avf(&zone, isolate->ast_string_constants(),
|
||||
HashSeed(isolate));
|
||||
const i::AstRawString* name_x = avf.GetOneByteString("x");
|
||||
avf.Internalize(isolate->factory());
|
||||
avf.Internalize(isolate);
|
||||
|
||||
i::DeclarationScope* script_scope =
|
||||
new (&zone) i::DeclarationScope(&zone, &avf);
|
||||
|
@ -8,6 +8,7 @@
|
||||
#include <memory>
|
||||
|
||||
#include "src/ast/ast-value-factory.h"
|
||||
#include "src/execution/off-thread-isolate.h"
|
||||
#include "src/handles/handles-inl.h"
|
||||
#include "src/handles/handles.h"
|
||||
#include "src/heap/off-thread-factory.h"
|
||||
@ -18,12 +19,17 @@
|
||||
namespace v8 {
|
||||
namespace internal {
|
||||
|
||||
class OffThreadIsolate;
|
||||
|
||||
class OffThreadFactoryTest : public TestWithIsolateAndZone {
|
||||
public:
|
||||
OffThreadFactoryTest()
|
||||
: TestWithIsolateAndZone(), off_thread_factory_(isolate()) {}
|
||||
: TestWithIsolateAndZone(), off_thread_isolate_(isolate()) {}
|
||||
|
||||
OffThreadFactory* off_thread_factory() { return &off_thread_factory_; }
|
||||
OffThreadIsolate* off_thread_isolate() { return &off_thread_isolate_; }
|
||||
OffThreadFactory* off_thread_factory() {
|
||||
return off_thread_isolate()->factory();
|
||||
}
|
||||
|
||||
// We only internalize strings which are referred to in other slots, so create
|
||||
// a wrapper pointing at the off_thread_string.
|
||||
@ -34,7 +40,7 @@ class OffThreadFactoryTest : public TestWithIsolateAndZone {
|
||||
}
|
||||
|
||||
private:
|
||||
OffThreadFactory off_thread_factory_;
|
||||
OffThreadIsolate off_thread_isolate_;
|
||||
};
|
||||
|
||||
TEST_F(OffThreadFactoryTest, HandleOrOffThreadHandle_IsNullWhenConstructed) {
|
||||
@ -47,9 +53,9 @@ TEST_F(OffThreadFactoryTest, HandleOrOffThreadHandle_IsNullWhenConstructed) {
|
||||
|
||||
// Default constructed HandleOrOffThreadHandles should work as both null
|
||||
// handles and null off-thread handles.
|
||||
EXPECT_TRUE(HandleOrOffThreadHandle<HeapObject>().get<Factory>().is_null());
|
||||
EXPECT_TRUE(HandleOrOffThreadHandle<HeapObject>().get<Isolate>().is_null());
|
||||
EXPECT_TRUE(
|
||||
HandleOrOffThreadHandle<HeapObject>().get<OffThreadFactory>().is_null());
|
||||
HandleOrOffThreadHandle<HeapObject>().get<OffThreadIsolate>().is_null());
|
||||
}
|
||||
|
||||
TEST_F(OffThreadFactoryTest, OneByteInternalizedString_IsAddedToStringTable) {
|
||||
@ -124,10 +130,10 @@ TEST_F(OffThreadFactoryTest, AstRawString_IsInternalized) {
|
||||
|
||||
const AstRawString* raw_string = ast_value_factory.GetOneByteString("foo");
|
||||
|
||||
ast_value_factory.Internalize(off_thread_factory());
|
||||
ast_value_factory.Internalize(off_thread_isolate());
|
||||
|
||||
OffThreadHandle<FixedArray> off_thread_wrapper =
|
||||
WrapString(raw_string->string().get<OffThreadFactory>());
|
||||
WrapString(raw_string->string().get<OffThreadIsolate>());
|
||||
|
||||
off_thread_factory()->FinishOffThread();
|
||||
|
||||
@ -150,10 +156,10 @@ TEST_F(OffThreadFactoryTest, AstConsString_CreatesConsString) {
|
||||
const AstConsString* foobar_string =
|
||||
ast_value_factory.NewConsString(foo_string, bar_string);
|
||||
|
||||
ast_value_factory.Internalize(off_thread_factory());
|
||||
ast_value_factory.Internalize(off_thread_isolate());
|
||||
|
||||
OffThreadHandle<FixedArray> off_thread_wrapper =
|
||||
WrapString(foobar_string->Allocate(off_thread_factory()));
|
||||
WrapString(foobar_string->Allocate(off_thread_isolate()));
|
||||
|
||||
off_thread_factory()->FinishOffThread();
|
||||
|
||||
|
@ -447,7 +447,7 @@ TEST_F(BytecodeArrayBuilderTest, AllBytecodesGenerated) {
|
||||
|
||||
// Generate BytecodeArray.
|
||||
scope.SetScriptScopeInfo(factory->NewScopeInfo(1));
|
||||
ast_factory.Internalize(isolate()->factory());
|
||||
ast_factory.Internalize(isolate());
|
||||
Handle<BytecodeArray> the_array = builder.ToBytecodeArray(isolate());
|
||||
CHECK_EQ(the_array->frame_size(),
|
||||
builder.total_register_count() * kSystemPointerSize);
|
||||
@ -560,7 +560,7 @@ TEST_F(BytecodeArrayBuilderTest, Constants) {
|
||||
.LoadLiteral(nan)
|
||||
.Return();
|
||||
|
||||
ast_factory.Internalize(isolate()->factory());
|
||||
ast_factory.Internalize(isolate());
|
||||
Handle<BytecodeArray> array = builder.ToBytecodeArray(isolate());
|
||||
// Should only have one entry for each identical constant.
|
||||
EXPECT_EQ(4, array->constant_pool().length());
|
||||
|
@ -73,7 +73,7 @@ TEST_F(BytecodeArrayIteratorTest, IteratesBytecodeArray) {
|
||||
.Return();
|
||||
|
||||
// Test iterator sees the expected output from the builder.
|
||||
ast_factory.Internalize(isolate()->factory());
|
||||
ast_factory.Internalize(isolate());
|
||||
BytecodeArrayIterator iterator(builder.ToBytecodeArray(isolate()));
|
||||
const int kPrefixByteSize = 1;
|
||||
int offset = 0;
|
||||
|
@ -66,7 +66,7 @@ TEST_F(BytecodeArrayRandomIteratorTest, InvalidBeforeStart) {
|
||||
.Debugger()
|
||||
.Return();
|
||||
|
||||
ast_factory.Internalize(isolate()->factory());
|
||||
ast_factory.Internalize(isolate());
|
||||
Handle<BytecodeArray> bytecodeArray = builder.ToBytecodeArray(isolate());
|
||||
BytecodeArrayRandomIterator iterator(bytecodeArray, zone());
|
||||
|
||||
@ -120,7 +120,7 @@ TEST_F(BytecodeArrayRandomIteratorTest, InvalidAfterEnd) {
|
||||
.Debugger()
|
||||
.Return();
|
||||
|
||||
ast_factory.Internalize(isolate()->factory());
|
||||
ast_factory.Internalize(isolate());
|
||||
Handle<BytecodeArray> bytecodeArray = builder.ToBytecodeArray(isolate());
|
||||
BytecodeArrayRandomIterator iterator(bytecodeArray, zone());
|
||||
|
||||
@ -174,7 +174,7 @@ TEST_F(BytecodeArrayRandomIteratorTest, AccessesFirst) {
|
||||
.Debugger()
|
||||
.Return();
|
||||
|
||||
ast_factory.Internalize(isolate()->factory());
|
||||
ast_factory.Internalize(isolate());
|
||||
Handle<BytecodeArray> bytecodeArray = builder.ToBytecodeArray(isolate());
|
||||
BytecodeArrayRandomIterator iterator(bytecodeArray, zone());
|
||||
|
||||
@ -233,7 +233,7 @@ TEST_F(BytecodeArrayRandomIteratorTest, AccessesLast) {
|
||||
.Debugger()
|
||||
.Return();
|
||||
|
||||
ast_factory.Internalize(isolate()->factory());
|
||||
ast_factory.Internalize(isolate());
|
||||
Handle<BytecodeArray> bytecodeArray = builder.ToBytecodeArray(isolate());
|
||||
BytecodeArrayRandomIterator iterator(bytecodeArray, zone());
|
||||
|
||||
@ -294,7 +294,7 @@ TEST_F(BytecodeArrayRandomIteratorTest, RandomAccessValid) {
|
||||
.Return();
|
||||
|
||||
// Test iterator sees the expected output from the builder.
|
||||
ast_factory.Internalize(isolate()->factory());
|
||||
ast_factory.Internalize(isolate());
|
||||
BytecodeArrayRandomIterator iterator(builder.ToBytecodeArray(isolate()),
|
||||
zone());
|
||||
const int kPrefixByteSize = 1;
|
||||
@ -480,7 +480,7 @@ TEST_F(BytecodeArrayRandomIteratorTest, IteratesBytecodeArray) {
|
||||
.Return();
|
||||
|
||||
// Test iterator sees the expected output from the builder.
|
||||
ast_factory.Internalize(isolate()->factory());
|
||||
ast_factory.Internalize(isolate());
|
||||
BytecodeArrayRandomIterator iterator(builder.ToBytecodeArray(isolate()),
|
||||
zone());
|
||||
const int kPrefixByteSize = 1;
|
||||
@ -761,7 +761,7 @@ TEST_F(BytecodeArrayRandomIteratorTest, IteratesBytecodeArrayBackwards) {
|
||||
.Return();
|
||||
|
||||
// Test iterator sees the expected output from the builder.
|
||||
ast_factory.Internalize(isolate()->factory());
|
||||
ast_factory.Internalize(isolate());
|
||||
Handle<BytecodeArray> bytecodeArray = builder.ToBytecodeArray(isolate());
|
||||
BytecodeArrayRandomIterator iterator(bytecodeArray, zone());
|
||||
const int kPrefixByteSize = 1;
|
||||
|
@ -40,7 +40,7 @@ TEST_F(ConstantArrayBuilderTest, AllocateAllEntries) {
|
||||
builder.Insert(i + 0.5);
|
||||
}
|
||||
CHECK_EQ(builder.size(), k16BitCapacity);
|
||||
ast_factory.Internalize(isolate()->factory());
|
||||
ast_factory.Internalize(isolate());
|
||||
for (size_t i = 0; i < k16BitCapacity; i++) {
|
||||
CHECK_EQ(
|
||||
Handle<HeapNumber>::cast(builder.At(i, isolate()).ToHandleChecked())
|
||||
@ -90,7 +90,7 @@ TEST_F(ConstantArrayBuilderTest, ToLargeFixedArrayWithReservations) {
|
||||
for (int i = 0; i < kNumberOfElements; i++) {
|
||||
builder.CommitReservedEntry(builder.CreateReservedEntry(), Smi::FromInt(i));
|
||||
}
|
||||
ast_factory.Internalize(isolate()->factory());
|
||||
ast_factory.Internalize(isolate());
|
||||
Handle<FixedArray> constant_array = builder.ToFixedArray(isolate());
|
||||
ASSERT_EQ(kNumberOfElements, constant_array->length());
|
||||
for (int i = 0; i < kNumberOfElements; i++) {
|
||||
@ -149,7 +149,7 @@ TEST_F(ConstantArrayBuilderTest, AllocateEntriesWithIdx8Reservations) {
|
||||
builder.DiscardReservedEntry(OperandSize::kByte);
|
||||
}
|
||||
|
||||
ast_factory.Internalize(isolate()->factory());
|
||||
ast_factory.Internalize(isolate());
|
||||
Handle<FixedArray> constant_array = builder.ToFixedArray(isolate());
|
||||
CHECK_EQ(constant_array->length(),
|
||||
static_cast<int>(2 * k8BitCapacity + reserved));
|
||||
@ -203,7 +203,7 @@ TEST_F(ConstantArrayBuilderTest, AllocateEntriesWithWideReservations) {
|
||||
CHECK_EQ(builder.size(), i + 1);
|
||||
}
|
||||
|
||||
ast_factory.Internalize(isolate()->factory());
|
||||
ast_factory.Internalize(isolate());
|
||||
Handle<FixedArray> constant_array = builder.ToFixedArray(isolate());
|
||||
CHECK_EQ(constant_array->length(),
|
||||
static_cast<int>(k8BitCapacity + reserved));
|
||||
@ -234,7 +234,7 @@ TEST_F(ConstantArrayBuilderTest, GapFilledWhenLowReservationCommitted) {
|
||||
Smi::FromInt(static_cast<int>(i)));
|
||||
CHECK_EQ(builder.size(), 2 * k8BitCapacity);
|
||||
}
|
||||
ast_factory.Internalize(isolate()->factory());
|
||||
ast_factory.Internalize(isolate());
|
||||
Handle<FixedArray> constant_array = builder.ToFixedArray(isolate());
|
||||
CHECK_EQ(constant_array->length(), static_cast<int>(2 * k8BitCapacity));
|
||||
for (size_t i = 0; i < k8BitCapacity; i++) {
|
||||
@ -300,7 +300,7 @@ TEST_F(ConstantArrayBuilderTest, HolesWithUnusedReservations) {
|
||||
builder.DiscardReservedEntry(OperandSize::kByte);
|
||||
}
|
||||
|
||||
ast_factory.Internalize(isolate()->factory());
|
||||
ast_factory.Internalize(isolate());
|
||||
Handle<FixedArray> constant_array = builder.ToFixedArray(isolate());
|
||||
CHECK_EQ(constant_array->length(), k8BitCapacity + 1);
|
||||
for (int i = kNumberOfHoles; i < k8BitCapacity; i++) {
|
||||
@ -343,7 +343,7 @@ TEST_F(ConstantArrayBuilderTest, ReservationsAtAllScales) {
|
||||
builder.DiscardReservedEntry(OperandSize::kQuad);
|
||||
}
|
||||
|
||||
ast_factory.Internalize(isolate()->factory());
|
||||
ast_factory.Internalize(isolate());
|
||||
Handle<FixedArray> constant_array = builder.ToFixedArray(isolate());
|
||||
CHECK_EQ(constant_array->length(), 65537);
|
||||
int count = 1;
|
||||
|
Loading…
Reference in New Issue
Block a user