[off-thread] Get rid of OffThreadHandle

Remove OffThreadHandle, HandleOrOffThreadHandle, and HandleFor, and
make the OffThreadIsolate allocate "real" Handles. Rather than using
the main-thread Isolate's handle scopes, these off-thread Handles are
backed by a Zone, which is tied to the lifetime of the nearest
OffThreadHandleScope. Eventually, we'll likely want to merge the
implementation of OffThreadHandleScope and HandleScope, but currently
the latter is too tightly coupled to the main thread to do so.

Bug: chromium:1011762
Change-Id: I2a6361931fe3f90a7bef4cc28ee42155fa8d062f
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2071865
Reviewed-by: Ross McIlroy <rmcilroy@chromium.org>
Reviewed-by: Ulan Degenbaev <ulan@chromium.org>
Reviewed-by: Toon Verwaest <verwaest@chromium.org>
Commit-Queue: Leszek Swirski <leszeks@chromium.org>
Cr-Commit-Position: refs/heads/master@{#66516}
This commit is contained in:
Leszek Swirski 2020-02-28 13:24:46 +01:00 committed by Commit Bot
parent ecc1508bc3
commit 84279bfcca
65 changed files with 861 additions and 1148 deletions

View File

@ -83,7 +83,7 @@ void AstRawString::Internalize(OffThreadIsolate* isolate) {
// construction and don't have access to the main thread string table yet, so
// we just unconditionally create strings and will internalize them properly
// during merging.
OffThreadHandle<SeqString> string;
Handle<SeqString> string;
if (is_one_byte()) {
string = isolate->factory()->NewOneByteInternalizedString(
Vector<const uint8_t>::cast(literal_bytes_), hash_field());
@ -162,8 +162,8 @@ bool AstRawString::Compare(void* a, void* b) {
}
}
template <typename Isolate>
HandleFor<Isolate, String> AstConsString::Allocate(Isolate* isolate) const {
template <typename LocalIsolate>
Handle<String> AstConsString::Allocate(LocalIsolate* isolate) const {
DCHECK(string_.is_null());
if (IsEmpty()) {
@ -171,7 +171,7 @@ HandleFor<Isolate, String> AstConsString::Allocate(Isolate* isolate) const {
}
// AstRawStrings are internalized before AstConsStrings are allocated, so
// AstRawString::string() will just work.
HandleFor<Isolate, String> tmp = segment_.string->string();
Handle<String> tmp = segment_.string->string();
for (AstConsString::Segment* current = segment_.next; current != nullptr;
current = current->next) {
tmp = isolate->factory()
@ -184,11 +184,11 @@ HandleFor<Isolate, String> AstConsString::Allocate(Isolate* isolate) const {
template EXPORT_TEMPLATE_DEFINE(V8_EXPORT_PRIVATE)
Handle<String> AstConsString::Allocate<Isolate>(Isolate* isolate) const;
template EXPORT_TEMPLATE_DEFINE(V8_EXPORT_PRIVATE)
OffThreadHandle<String> AstConsString::Allocate<OffThreadIsolate>(
Handle<String> AstConsString::Allocate<OffThreadIsolate>(
OffThreadIsolate* isolate) const;
template <typename Isolate>
HandleFor<Isolate, String> AstConsString::AllocateFlat(Isolate* isolate) const {
template <typename LocalIsolate>
Handle<String> AstConsString::AllocateFlat(LocalIsolate* isolate) const {
if (IsEmpty()) {
return isolate->factory()->empty_string();
}
@ -205,7 +205,7 @@ HandleFor<Isolate, String> AstConsString::AllocateFlat(Isolate* isolate) const {
}
if (is_one_byte) {
HandleFor<Isolate, SeqOneByteString> result =
Handle<SeqOneByteString> result =
isolate->factory()
->NewRawOneByteString(result_length, AllocationType::kOld)
.ToHandleChecked();
@ -221,7 +221,7 @@ HandleFor<Isolate, String> AstConsString::AllocateFlat(Isolate* isolate) const {
return result;
}
HandleFor<Isolate, SeqTwoByteString> result =
Handle<SeqTwoByteString> result =
isolate->factory()
->NewRawTwoByteString(result_length, AllocationType::kOld)
.ToHandleChecked();
@ -245,7 +245,7 @@ HandleFor<Isolate, String> AstConsString::AllocateFlat(Isolate* isolate) const {
template EXPORT_TEMPLATE_DEFINE(V8_EXPORT_PRIVATE)
Handle<String> AstConsString::AllocateFlat<Isolate>(Isolate* isolate) const;
template EXPORT_TEMPLATE_DEFINE(V8_EXPORT_PRIVATE)
OffThreadHandle<String> AstConsString::AllocateFlat<OffThreadIsolate>(
Handle<String> AstConsString::AllocateFlat<OffThreadIsolate>(
OffThreadIsolate* isolate) const;
std::forward_list<const AstRawString*> AstConsString::ToRawStrings() const {
@ -344,8 +344,8 @@ AstConsString* AstValueFactory::NewConsString(const AstRawString* str1,
return NewConsString()->AddString(zone_, str1)->AddString(zone_, str2);
}
template <typename Isolate>
void AstValueFactory::Internalize(Isolate* isolate) {
template <typename LocalIsolate>
void AstValueFactory::Internalize(LocalIsolate* isolate) {
// Strings need to be internalized before values, because values refer to
// strings.
for (AstRawString* current = strings_; current != nullptr;) {

View File

@ -71,7 +71,7 @@ class AstRawString final : public ZoneObject {
uint32_t Hash() const { return hash_field_ >> Name::kHashShift; }
// This function can be called after internalizing.
V8_INLINE HandleOrOffThreadHandle<String> string() const {
V8_INLINE Handle<String> string() const {
DCHECK(has_string_);
return string_;
}
@ -98,7 +98,7 @@ class AstRawString final : public ZoneObject {
return &next_;
}
void set_string(HandleOrOffThreadHandle<String> string) {
void set_string(Handle<String> string) {
DCHECK(!string.is_null());
DCHECK(!has_string_);
string_ = string;
@ -109,7 +109,7 @@ class AstRawString final : public ZoneObject {
union {
AstRawString* next_;
HandleOrOffThreadHandle<String> string_;
Handle<String> string_;
};
Vector<const byte> literal_bytes_; // Memory owned by Zone.
@ -144,17 +144,17 @@ class AstConsString final : public ZoneObject {
return segment_.string == nullptr;
}
template <typename Isolate>
HandleFor<Isolate, String> GetString(Isolate* isolate) {
template <typename LocalIsolate>
Handle<String> GetString(LocalIsolate* isolate) {
if (string_.is_null()) {
string_ = Allocate(isolate);
}
return string_;
}
template <typename Isolate>
template <typename LocalIsolate>
EXPORT_TEMPLATE_DECLARE(V8_EXPORT_PRIVATE)
HandleFor<Isolate, String> AllocateFlat(Isolate* isolate) const;
Handle<String> AllocateFlat(LocalIsolate* isolate) const;
std::forward_list<const AstRawString*> ToRawStrings() const;
@ -163,11 +163,11 @@ class AstConsString final : public ZoneObject {
AstConsString() : string_(), segment_({nullptr, nullptr}) {}
template <typename Isolate>
template <typename LocalIsolate>
EXPORT_TEMPLATE_DECLARE(V8_EXPORT_PRIVATE)
HandleFor<Isolate, String> Allocate(Isolate* isolate) const;
Handle<String> Allocate(LocalIsolate* isolate) const;
HandleOrOffThreadHandle<String> string_;
Handle<String> string_;
// A linked list of AstRawStrings of the contents of this AstConsString.
// This list has several properties:
@ -317,8 +317,8 @@ class AstValueFactory {
V8_EXPORT_PRIVATE AstConsString* NewConsString(const AstRawString* str1,
const AstRawString* str2);
template <typename Isolate>
void Internalize(Isolate* isolate);
template <typename LocalIsolate>
void Internalize(LocalIsolate* isolate);
#define F(name, str) \
const AstRawString* name##_string() const { \

View File

@ -60,7 +60,6 @@ void AstNode::Print(Isolate* isolate) {
AstPrinter::PrintOut(isolate, this);
}
#endif // DEBUG
#define RETURN_NODE(Node) \
@ -235,11 +234,7 @@ int FunctionLiteral::start_position() const {
return scope()->start_position();
}
int FunctionLiteral::end_position() const {
return scope()->end_position();
}
int FunctionLiteral::end_position() const { return scope()->end_position(); }
LanguageMode FunctionLiteral::language_mode() const {
return scope()->language_mode();
@ -341,7 +336,6 @@ bool ObjectLiteral::Property::IsCompileTimeValue() const {
(kind_ == MATERIALIZED_LITERAL && value_->IsCompileTimeValue());
}
void ObjectLiteral::Property::set_emit_store(bool emit_store) {
emit_store_ = emit_store;
}
@ -475,8 +469,8 @@ int ObjectLiteral::InitDepthAndFlags() {
return depth_acc;
}
template <typename Isolate>
void ObjectLiteral::BuildBoilerplateDescription(Isolate* isolate) {
template <typename LocalIsolate>
void ObjectLiteral::BuildBoilerplateDescription(LocalIsolate* isolate) {
if (!boilerplate_description_.is_null()) return;
int index_keys = 0;
@ -493,7 +487,7 @@ void ObjectLiteral::BuildBoilerplateDescription(Isolate* isolate) {
if (!key->IsPropertyName()) index_keys++;
}
HandleFor<Isolate, ObjectBoilerplateDescription> boilerplate_description =
Handle<ObjectBoilerplateDescription> boilerplate_description =
isolate->factory()->NewObjectBoilerplateDescription(
boilerplate_properties_, properties()->length(), index_keys,
has_seen_proto);
@ -519,16 +513,14 @@ void ObjectLiteral::BuildBoilerplateDescription(Isolate* isolate) {
// runtime. The enumeration order is maintained.
Literal* key_literal = property->key()->AsLiteral();
uint32_t element_index = 0;
HandleFor<Isolate, Object> key =
Handle<Object> key =
key_literal->AsArrayIndex(&element_index)
? isolate->factory()
->template NewNumberFromUint<AllocationType::kOld>(
element_index)
: HandleFor<Isolate, Object>::cast(
key_literal->AsRawPropertyName()->string().get<Isolate>());
: Handle<Object>::cast(key_literal->AsRawPropertyName()->string());
HandleFor<Isolate, Object> value =
GetBoilerplateValue(property->value(), isolate);
Handle<Object> value = GetBoilerplateValue(property->value(), isolate);
// Add name, value pair to the fixed array.
boilerplate_description->set_key_value(position++, *key, *value);
@ -632,8 +624,8 @@ int ArrayLiteral::InitDepthAndFlags() {
return depth_acc;
}
template <typename Isolate>
void ArrayLiteral::BuildBoilerplateDescription(Isolate* isolate) {
template <typename LocalIsolate>
void ArrayLiteral::BuildBoilerplateDescription(LocalIsolate* isolate) {
if (!boilerplate_description_.is_null()) return;
int constants_length =
@ -641,7 +633,7 @@ void ArrayLiteral::BuildBoilerplateDescription(Isolate* isolate) {
ElementsKind kind = boilerplate_descriptor_kind();
bool use_doubles = IsDoubleElementsKind(kind);
HandleFor<Isolate, FixedArrayBase> elements;
Handle<FixedArrayBase> elements;
if (use_doubles) {
elements = isolate->factory()->NewFixedDoubleArray(constants_length,
AllocationType::kOld);
@ -677,7 +669,7 @@ void ArrayLiteral::BuildBoilerplateDescription(Isolate* isolate) {
}
// New handle scope here, needs to be after BuildContants().
HandleScopeFor<Isolate> scope(isolate);
typename LocalIsolate::HandleScopeType scope(isolate);
Object boilerplate_value = *GetBoilerplateValue(element, isolate);
// We shouldn't allocate after creating the boilerplate value.
@ -731,9 +723,9 @@ bool MaterializedLiteral::IsSimple() const {
return false;
}
template <typename Isolate>
HandleFor<Isolate, Object> MaterializedLiteral::GetBoilerplateValue(
Expression* expression, Isolate* isolate) {
template <typename LocalIsolate>
Handle<Object> MaterializedLiteral::GetBoilerplateValue(Expression* expression,
LocalIsolate* isolate) {
if (expression->IsLiteral()) {
return expression->AsLiteral()->BuildValue(isolate);
}
@ -755,7 +747,7 @@ template EXPORT_TEMPLATE_DEFINE(V8_EXPORT_PRIVATE)
Handle<Object> MaterializedLiteral::GetBoilerplateValue(
Expression* expression, Isolate* isolate);
template EXPORT_TEMPLATE_DEFINE(V8_EXPORT_PRIVATE)
OffThreadHandle<Object> MaterializedLiteral::GetBoilerplateValue(
Handle<Object> MaterializedLiteral::GetBoilerplateValue(
Expression* expression, OffThreadIsolate* isolate);
int MaterializedLiteral::InitDepthAndFlags() {
@ -776,8 +768,8 @@ bool MaterializedLiteral::NeedsInitialAllocationSite() {
return false;
}
template <typename Isolate>
void MaterializedLiteral::BuildConstants(Isolate* isolate) {
template <typename LocalIsolate>
void MaterializedLiteral::BuildConstants(LocalIsolate* isolate) {
if (IsArrayLiteral()) {
AsArrayLiteral()->BuildBoilerplateDescription(isolate);
return;
@ -794,12 +786,11 @@ template EXPORT_TEMPLATE_DEFINE(
V8_BASE_EXPORT) void MaterializedLiteral::BuildConstants(OffThreadIsolate*
isolate);
template <typename Isolate>
HandleFor<Isolate, TemplateObjectDescription>
GetTemplateObject::GetOrBuildDescription(Isolate* isolate) {
HandleFor<Isolate, FixedArray> raw_strings =
isolate->factory()->NewFixedArray(this->raw_strings()->length(),
AllocationType::kOld);
template <typename LocalIsolate>
Handle<TemplateObjectDescription> GetTemplateObject::GetOrBuildDescription(
LocalIsolate* isolate) {
Handle<FixedArray> raw_strings = isolate->factory()->NewFixedArray(
this->raw_strings()->length(), AllocationType::kOld);
bool raw_and_cooked_match = true;
for (int i = 0; i < raw_strings->length(); ++i) {
if (this->raw_strings()->at(i) != this->cooked_strings()->at(i)) {
@ -807,21 +798,20 @@ GetTemplateObject::GetOrBuildDescription(Isolate* isolate) {
// 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>());
*this->cooked_strings()->at(i)->string() !=
*this->raw_strings()->at(i)->string());
raw_and_cooked_match = false;
}
raw_strings->set(i, *this->raw_strings()->at(i)->string().get<Isolate>());
raw_strings->set(i, *this->raw_strings()->at(i)->string());
}
HandleFor<Isolate, FixedArray> cooked_strings = raw_strings;
Handle<FixedArray> cooked_strings = raw_strings;
if (!raw_and_cooked_match) {
cooked_strings = isolate->factory()->NewFixedArray(
this->cooked_strings()->length(), AllocationType::kOld);
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<Isolate>());
cooked_strings->set(i, *this->cooked_strings()->at(i)->string());
} else {
cooked_strings->set(i, ReadOnlyRoots(isolate).undefined_value());
}
@ -834,8 +824,8 @@ template EXPORT_TEMPLATE_DEFINE(V8_BASE_EXPORT)
Handle<TemplateObjectDescription> GetTemplateObject::GetOrBuildDescription(
Isolate* isolate);
template EXPORT_TEMPLATE_DEFINE(V8_BASE_EXPORT)
OffThreadHandle<TemplateObjectDescription> GetTemplateObject::
GetOrBuildDescription(OffThreadIsolate* isolate);
Handle<TemplateObjectDescription> GetTemplateObject::GetOrBuildDescription(
OffThreadIsolate* isolate);
static bool IsCommutativeOperationWithSmiLiteral(Token::Value op) {
// Add is not commutative due to potential for string addition.
@ -884,20 +874,16 @@ bool CompareOperation::IsLiteralCompareTypeof(Expression** expr,
MatchLiteralCompareTypeof(right_, op(), left_, expr, literal);
}
static bool IsVoidOfLiteral(Expression* expr) {
UnaryOperation* maybe_unary = expr->AsUnaryOperation();
return maybe_unary != nullptr && maybe_unary->op() == Token::VOID &&
maybe_unary->expression()->IsLiteral();
}
// Check for the pattern: void <literal> equals <expression> or
// undefined equals <expression>
static bool MatchLiteralCompareUndefined(Expression* left,
Token::Value op,
Expression* right,
Expression** expr) {
static bool MatchLiteralCompareUndefined(Expression* left, Token::Value op,
Expression* right, Expression** expr) {
if (IsVoidOfLiteral(left) && Token::IsEqualityOp(op)) {
*expr = right;
return true;
@ -915,10 +901,8 @@ bool CompareOperation::IsLiteralCompareUndefined(Expression** expr) {
}
// Check for the pattern: null equals <expression>
static bool MatchLiteralCompareNull(Expression* left,
Token::Value op,
Expression* right,
Expression** expr) {
static bool MatchLiteralCompareNull(Expression* left, Token::Value op,
Expression* right, Expression** expr) {
if (left->IsNullLiteral() && Token::IsEqualityOp(op)) {
*expr = right;
return true;
@ -1005,8 +989,8 @@ bool Literal::AsArrayIndex(uint32_t* value) const {
return ToUint32(value) && *value != kMaxUInt32;
}
template <typename Isolate>
HandleFor<Isolate, Object> Literal::BuildValue(Isolate* isolate) const {
template <typename LocalIsolate>
Handle<Object> Literal::BuildValue(LocalIsolate* isolate) const {
switch (type()) {
case kSmi:
return handle(Smi::FromInt(smi_), isolate);
@ -1035,8 +1019,7 @@ HandleFor<Isolate, Object> Literal::BuildValue(Isolate* isolate) const {
template EXPORT_TEMPLATE_DEFINE(V8_EXPORT_PRIVATE)
Handle<Object> Literal::BuildValue(Isolate* isolate) const;
template EXPORT_TEMPLATE_DEFINE(V8_EXPORT_PRIVATE)
OffThreadHandle<Object> Literal::BuildValue(
OffThreadIsolate* isolate) const;
Handle<Object> Literal::BuildValue(OffThreadIsolate* isolate) const;
bool Literal::ToBooleanIsTrue() const {
switch (type()) {
@ -1076,7 +1059,6 @@ uint32_t Literal::Hash() {
: ComputeLongHash(double_to_uint64(AsNumber()));
}
// static
bool Literal::Match(void* a, void* b) {
Literal* x = static_cast<Literal*>(a);

View File

@ -967,8 +967,8 @@ class Literal final : public Expression {
// Returns an appropriate Object representing this Literal, allocating
// a heap object if needed.
template <typename Isolate>
HandleFor<Isolate, Object> BuildValue(Isolate* isolate) const;
template <typename LocalIsolate>
Handle<Object> BuildValue(LocalIsolate* isolate) const;
// Support for using Literal as a HashMap key. NOTE: Currently, this works
// only for string and number literals!
@ -1044,23 +1044,23 @@ class MaterializedLiteral : public Expression {
bool NeedsInitialAllocationSite();
// Populate the constant properties/elements fixed array.
template <typename Isolate>
void BuildConstants(Isolate* isolate);
template <typename LocalIsolate>
void BuildConstants(LocalIsolate* isolate);
// If the expression is a literal, return the literal value;
// if the expression is a materialized literal and is_simple
// then return an Array or Object Boilerplate Description
// Otherwise, return undefined literal as the placeholder
// in the object literal boilerplate.
template <typename Isolate>
HandleFor<Isolate, Object> GetBoilerplateValue(Expression* expression,
Isolate* isolate);
template <typename LocalIsolate>
Handle<Object> GetBoilerplateValue(Expression* expression,
LocalIsolate* isolate);
};
// Node for capturing a regexp literal.
class RegExpLiteral final : public MaterializedLiteral {
public:
HandleOrOffThreadHandle<String> pattern() const { return pattern_->string(); }
Handle<String> pattern() const { return pattern_->string(); }
const AstRawString* raw_pattern() const { return pattern_; }
int flags() const { return flags_; }
@ -1218,9 +1218,8 @@ class ObjectLiteral final : public AggregateLiteral {
public:
using Property = ObjectLiteralProperty;
HandleOrOffThreadHandle<ObjectBoilerplateDescription>
boilerplate_description() const {
DCHECK(boilerplate_description_.is_initialized());
Handle<ObjectBoilerplateDescription> boilerplate_description() const {
DCHECK(!boilerplate_description_.is_null());
return boilerplate_description_;
}
int properties_count() const { return boilerplate_properties_; }
@ -1248,9 +1247,9 @@ class ObjectLiteral final : public AggregateLiteral {
int InitDepthAndFlags();
// Get the boilerplate description, populating it if necessary.
template <typename Isolate>
HandleFor<Isolate, ObjectBoilerplateDescription>
GetOrBuildBoilerplateDescription(Isolate* isolate) {
template <typename LocalIsolate>
Handle<ObjectBoilerplateDescription> GetOrBuildBoilerplateDescription(
LocalIsolate* isolate) {
if (boilerplate_description_.is_null()) {
BuildBoilerplateDescription(isolate);
}
@ -1258,8 +1257,8 @@ class ObjectLiteral final : public AggregateLiteral {
}
// Populate the boilerplate description.
template <typename Isolate>
void BuildBoilerplateDescription(Isolate* isolate);
template <typename LocalIsolate>
void BuildBoilerplateDescription(LocalIsolate* isolate);
// Mark all computed expressions that are bound to a key that
// is shadowed by a later occurrence of the same key. For the
@ -1320,8 +1319,7 @@ class ObjectLiteral final : public AggregateLiteral {
bit_field_ = HasNullPrototypeField::update(bit_field_, has_null_prototype);
}
uint32_t boilerplate_properties_;
HandleOrOffThreadHandle<ObjectBoilerplateDescription>
boilerplate_description_;
Handle<ObjectBoilerplateDescription> boilerplate_description_;
ZoneList<Property*> properties_;
using HasElementsField = AggregateLiteral::NextBitField<bool, 1>;
@ -1334,8 +1332,7 @@ class ObjectLiteral final : public AggregateLiteral {
// for minimizing the work when constructing it at runtime.
class ArrayLiteral final : public AggregateLiteral {
public:
HandleOrOffThreadHandle<ArrayBoilerplateDescription> boilerplate_description()
const {
Handle<ArrayBoilerplateDescription> boilerplate_description() const {
return boilerplate_description_;
}
@ -1347,18 +1344,18 @@ class ArrayLiteral final : public AggregateLiteral {
int InitDepthAndFlags();
// Get the boilerplate description, populating it if necessary.
template <typename Isolate>
HandleFor<Isolate, ArrayBoilerplateDescription>
GetOrBuildBoilerplateDescription(Isolate* isolate) {
template <typename LocalIsolate>
Handle<ArrayBoilerplateDescription> GetOrBuildBoilerplateDescription(
LocalIsolate* isolate) {
if (boilerplate_description_.is_null()) {
BuildBoilerplateDescription(isolate);
}
return boilerplate_description_.get<Isolate>();
return boilerplate_description_;
}
// Populate the boilerplate description.
template <typename Isolate>
void BuildBoilerplateDescription(Isolate* isolate);
template <typename LocalIsolate>
void BuildBoilerplateDescription(LocalIsolate* isolate);
// Determines whether the {CreateShallowArrayLiteral} builtin can be used.
bool IsFastCloningSupported() const;
@ -1380,7 +1377,7 @@ class ArrayLiteral final : public AggregateLiteral {
}
int first_spread_index_;
HandleOrOffThreadHandle<ArrayBoilerplateDescription> boilerplate_description_;
Handle<ArrayBoilerplateDescription> boilerplate_description_;
ZonePtrList<Expression> values_;
};
@ -2083,10 +2080,9 @@ 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).
template <typename Isolate>
MaybeHandleFor<Isolate, String> GetName(Isolate* isolate) const {
return raw_name_ ? raw_name_->AllocateFlat(isolate)
: MaybeHandleFor<Isolate, String>();
template <typename LocalIsolate>
MaybeHandle<String> GetName(LocalIsolate* 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_; }
@ -2154,7 +2150,7 @@ class FunctionLiteral final : public Expression {
}
UNREACHABLE();
}
OffThreadHandle<String> GetInferredName(OffThreadIsolate* isolate) const {
Handle<String> GetInferredName(OffThreadIsolate* isolate) const {
DCHECK(inferred_name_.is_null());
DCHECK_NOT_NULL(raw_inferred_name_);
return raw_inferred_name_->GetString(isolate);
@ -2534,9 +2530,9 @@ class GetTemplateObject final : public Expression {
return raw_strings_;
}
template <typename Isolate>
HandleFor<Isolate, TemplateObjectDescription> GetOrBuildDescription(
Isolate* isolate);
template <typename LocalIsolate>
Handle<TemplateObjectDescription> GetOrBuildDescription(
LocalIsolate* isolate);
private:
friend class AstNodeFactory;

View File

@ -85,17 +85,17 @@ void SourceTextModuleDescriptor::AddStarExport(
}
namespace {
template <typename Isolate>
HandleFor<Isolate, PrimitiveHeapObject> ToStringOrUndefined(
Isolate* isolate, const AstRawString* s) {
template <typename LocalIsolate>
Handle<PrimitiveHeapObject> ToStringOrUndefined(LocalIsolate* isolate,
const AstRawString* s) {
if (s == nullptr) return isolate->factory()->undefined_value();
return s->string();
}
} // namespace
template <typename Isolate>
HandleFor<Isolate, SourceTextModuleInfoEntry>
SourceTextModuleDescriptor::Entry::Serialize(Isolate* isolate) const {
template <typename LocalIsolate>
Handle<SourceTextModuleInfoEntry> SourceTextModuleDescriptor::Entry::Serialize(
LocalIsolate* isolate) const {
CHECK(Smi::IsValid(module_request)); // TODO(neis): Check earlier?
return SourceTextModuleInfoEntry::New(
isolate, ToStringOrUndefined(isolate, export_name),
@ -105,18 +105,17 @@ SourceTextModuleDescriptor::Entry::Serialize(Isolate* isolate) const {
}
template Handle<SourceTextModuleInfoEntry>
SourceTextModuleDescriptor::Entry::Serialize(Isolate* isolate) const;
template OffThreadHandle<SourceTextModuleInfoEntry>
template Handle<SourceTextModuleInfoEntry>
SourceTextModuleDescriptor::Entry::Serialize(OffThreadIsolate* isolate) const;
template <typename Isolate>
HandleFor<Isolate, FixedArray>
SourceTextModuleDescriptor::SerializeRegularExports(Isolate* isolate,
Zone* zone) const {
template <typename LocalIsolate>
Handle<FixedArray> SourceTextModuleDescriptor::SerializeRegularExports(
LocalIsolate* isolate, Zone* zone) const {
// We serialize regular exports in a way that lets us later iterate over their
// local names and for each local name immediately access all its export
// names. (Regular exports have neither import name nor module request.)
ZoneVector<HandleFor<Isolate, Object>> data(
ZoneVector<Handle<Object>> data(
SourceTextModuleInfo::kRegularExportLength * regular_exports_.size(),
zone);
int index = 0;
@ -132,8 +131,7 @@ SourceTextModuleDescriptor::SerializeRegularExports(Isolate* isolate,
++count;
} while (next != regular_exports_.end() && next->first == it->first);
HandleFor<Isolate, FixedArray> export_names =
isolate->factory()->NewFixedArray(count);
Handle<FixedArray> export_names = isolate->factory()->NewFixedArray(count);
data[index + SourceTextModuleInfo::kRegularExportLocalNameOffset] =
it->second->local_name->string();
data[index + SourceTextModuleInfo::kRegularExportCellIndexOffset] =
@ -145,7 +143,7 @@ SourceTextModuleDescriptor::SerializeRegularExports(Isolate* isolate,
// Collect the export names.
int i = 0;
for (; it != next; ++it) {
export_names->set(i++, *it->second->export_name->string().get<Isolate>());
export_names->set(i++, *it->second->export_name->string());
}
DCHECK_EQ(i, count);
@ -157,8 +155,7 @@ SourceTextModuleDescriptor::SerializeRegularExports(Isolate* isolate,
// We cannot create the FixedArray earlier because we only now know the
// precise size.
HandleFor<Isolate, FixedArray> result =
isolate->factory()->NewFixedArray(index);
Handle<FixedArray> result = isolate->factory()->NewFixedArray(index);
for (int i = 0; i < index; ++i) {
result->set(i, *data[i]);
}
@ -166,9 +163,8 @@ SourceTextModuleDescriptor::SerializeRegularExports(Isolate* isolate,
}
template Handle<FixedArray> SourceTextModuleDescriptor::SerializeRegularExports(
Isolate* isolate, Zone* zone) const;
template OffThreadHandle<FixedArray>
SourceTextModuleDescriptor::SerializeRegularExports(OffThreadIsolate* isolate,
Zone* zone) const;
template Handle<FixedArray> SourceTextModuleDescriptor::SerializeRegularExports(
OffThreadIsolate* isolate, Zone* zone) const;
void SourceTextModuleDescriptor::MakeIndirectExportsExplicit(Zone* zone) {
for (auto it = regular_exports_.begin(); it != regular_exports_.end();) {

View File

@ -5,7 +5,6 @@
#ifndef V8_AST_MODULES_H_
#define V8_AST_MODULES_H_
#include "src/handles/handle-for.h"
#include "src/parsing/scanner.h" // Only for Scanner::Location.
#include "src/zone/zone-containers.h"
@ -108,9 +107,8 @@ class SourceTextModuleDescriptor : public ZoneObject {
module_request(-1),
cell_index(0) {}
template <typename Isolate>
HandleFor<Isolate, SourceTextModuleInfoEntry> Serialize(
Isolate* isolate) const;
template <typename LocalIsolate>
Handle<SourceTextModuleInfoEntry> Serialize(LocalIsolate* isolate) const;
};
enum CellIndexKind { kInvalid, kExport, kImport };
@ -187,9 +185,9 @@ class SourceTextModuleDescriptor : public ZoneObject {
namespace_imports_.push_back(entry);
}
template <typename Isolate>
HandleFor<Isolate, FixedArray> SerializeRegularExports(Isolate* isolate,
Zone* zone) const;
template <typename LocalIsolate>
Handle<FixedArray> SerializeRegularExports(LocalIsolate* isolate,
Zone* zone) const;
private:
ModuleRequestMap module_requests_;

View File

@ -836,8 +836,8 @@ Variable* Scope::LookupInScopeInfo(const AstRawString* name, Scope* cache) {
DCHECK_NULL(cache->variables_.Lookup(name));
DisallowHeapAllocation no_gc;
String name_handle = *name->string().get_handle();
ScopeInfo scope_info = *scope_info_.get_handle();
String name_handle = *name->string();
ScopeInfo scope_info = *scope_info_;
// 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.
@ -1222,7 +1222,7 @@ void DeclarationScope::DeserializeReceiver(AstValueFactory* ast_value_factory) {
receiver_->AllocateTo(VariableLocation::LOOKUP, -1);
} else {
receiver_->AllocateTo(VariableLocation::CONTEXT,
scope_info_.get_handle()->ReceiverContextSlotIndex());
scope_info_->ReceiverContextSlotIndex());
}
}
@ -2451,11 +2451,11 @@ void Scope::AllocateVariablesRecursively() {
});
}
template <typename Isolate>
void Scope::AllocateScopeInfosRecursively(
Isolate* isolate, MaybeHandleFor<Isolate, ScopeInfo> outer_scope) {
template <typename LocalIsolate>
void Scope::AllocateScopeInfosRecursively(LocalIsolate* isolate,
MaybeHandle<ScopeInfo> outer_scope) {
DCHECK(scope_info_.is_null());
MaybeHandleFor<Isolate, ScopeInfo> next_outer_scope = outer_scope;
MaybeHandle<ScopeInfo> next_outer_scope = outer_scope;
if (NeedsScopeInfo()) {
scope_info_ = ScopeInfo::Create(isolate, zone(), this, outer_scope);
@ -2478,7 +2478,7 @@ template EXPORT_TEMPLATE_DEFINE(V8_EXPORT_PRIVATE) void Scope::
MaybeHandle<ScopeInfo> outer_scope);
template EXPORT_TEMPLATE_DEFINE(V8_EXPORT_PRIVATE) void Scope::
AllocateScopeInfosRecursively<OffThreadIsolate>(
OffThreadIsolate* isolate, OffThreadHandle<ScopeInfo> outer_scope);
OffThreadIsolate* isolate, MaybeHandle<ScopeInfo> outer_scope);
void DeclarationScope::RecalcPrivateNameContextChain() {
// The outermost scope in a class heritage expression is marked to skip the
@ -2522,14 +2522,15 @@ void DeclarationScope::RecordNeedsPrivateNameContextChainRecalc() {
}
// static
template <typename Isolate>
void DeclarationScope::AllocateScopeInfos(ParseInfo* info, Isolate* isolate) {
template <typename LocalIsolate>
void DeclarationScope::AllocateScopeInfos(ParseInfo* info,
LocalIsolate* isolate) {
DeclarationScope* scope = info->literal()->scope();
// No one else should have allocated a scope info for this scope yet.
DCHECK(scope->scope_info_.is_null());
MaybeHandleFor<Isolate, ScopeInfo> outer_scope;
MaybeHandle<ScopeInfo> outer_scope;
if (scope->outer_scope_ != nullptr) {
DCHECK((std::is_same<Isolate, v8::internal::Isolate>::value));
outer_scope = scope->outer_scope_->scope_info_;
@ -2671,14 +2672,14 @@ Variable* ClassScope::LookupPrivateNameInScopeInfo(const AstRawString* name) {
DCHECK_NULL(LookupLocalPrivateName(name));
DisallowHeapAllocation no_gc;
String name_handle = *name->string().get_handle();
String name_handle = *name->string();
VariableMode mode;
InitializationFlag init_flag;
MaybeAssignedFlag maybe_assigned_flag;
IsStaticFlag is_static_flag;
int index = ScopeInfo::ContextSlotIndex(
*scope_info_.get_handle(), name_handle, &mode, &init_flag,
&maybe_assigned_flag, &is_static_flag);
int index =
ScopeInfo::ContextSlotIndex(*scope_info_, name_handle, &mode, &init_flag,
&maybe_assigned_flag, &is_static_flag);
if (index < 0) {
return nullptr;
}

View File

@ -11,7 +11,6 @@
#include "src/base/hashmap.h"
#include "src/base/threaded-list.h"
#include "src/common/globals.h"
#include "src/handles/handle-for.h"
#include "src/objects/function-kind.h"
#include "src/objects/objects.h"
#include "src/utils/pointer-with-payload.h"
@ -521,7 +520,7 @@ class V8_EXPORT_PRIVATE Scope : public NON_EXPORTED_BASE(ZoneObject) {
bool HasThisReference() const;
// Analyze() must have been called once to create the ScopeInfo.
HandleOrOffThreadHandle<ScopeInfo> scope_info() const {
Handle<ScopeInfo> scope_info() const {
DCHECK(!scope_info_.is_null());
return scope_info_;
}
@ -671,9 +670,9 @@ class V8_EXPORT_PRIVATE Scope : public NON_EXPORTED_BASE(ZoneObject) {
V8_INLINE void AllocateNonParameterLocalsAndDeclaredGlobals();
void AllocateVariablesRecursively();
template <typename Isolate>
void AllocateScopeInfosRecursively(
Isolate* isolate, MaybeHandleFor<Isolate, ScopeInfo> outer_scope);
template <typename LocalIsolate>
void AllocateScopeInfosRecursively(LocalIsolate* isolate,
MaybeHandle<ScopeInfo> outer_scope);
void AllocateDebuggerScopeInfos(Isolate* isolate,
MaybeHandle<ScopeInfo> outer_scope);
@ -694,7 +693,6 @@ class V8_EXPORT_PRIVATE Scope : public NON_EXPORTED_BASE(ZoneObject) {
void SetDefaults();
void set_scope_info(Handle<ScopeInfo> scope_info);
void set_scope_info(OffThreadHandle<ScopeInfo> scope_info);
friend class DeclarationScope;
friend class ClassScope;
@ -723,7 +721,7 @@ class V8_EXPORT_PRIVATE Scope : public NON_EXPORTED_BASE(ZoneObject) {
base::ThreadedList<Declaration> decls_;
// Serialized scope info support.
HandleOrOffThreadHandle<ScopeInfo> scope_info_;
Handle<ScopeInfo> scope_info_;
// Debugging support.
#ifdef DEBUG
const AstRawString* scope_name_;
@ -1103,9 +1101,9 @@ class V8_EXPORT_PRIVATE DeclarationScope : public Scope {
// Allocate ScopeInfos for top scope and any inner scopes that need them.
// Does nothing if ScopeInfo is already allocated.
template <typename Isolate>
template <typename LocalIsolate>
V8_EXPORT_PRIVATE static void AllocateScopeInfos(ParseInfo* info,
Isolate* isolate);
LocalIsolate* isolate);
Handle<StringSet> CollectNonLocals(Isolate* isolate, ParseInfo* info,
Handle<StringSet> non_locals);

View File

@ -58,7 +58,7 @@ class Variable final : public ZoneObject {
// parameter initializers.
void set_scope(Scope* scope) { scope_ = scope; }
HandleOrOffThreadHandle<String> name() const { return name_->string(); }
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) {

View File

@ -164,8 +164,7 @@ CompilationJob::Status UnoptimizedCompilationJob::FinalizeJob(
void UnoptimizedCompilationJob::RecordCompilationStats(Isolate* isolate) const {
int code_size;
if (compilation_info()->has_bytecode_array()) {
code_size =
compilation_info()->bytecode_array<Isolate>()->SizeIncludingMetadata();
code_size = compilation_info()->bytecode_array()->SizeIncludingMetadata();
} else {
DCHECK(compilation_info()->has_asm_wasm_data());
code_size = compilation_info()->asm_wasm_data()->Size();
@ -185,8 +184,8 @@ void UnoptimizedCompilationJob::RecordFunctionCompilation(
Isolate* isolate) const {
Handle<AbstractCode> abstract_code;
if (compilation_info()->has_bytecode_array()) {
abstract_code = Handle<AbstractCode>::cast(
compilation_info()->bytecode_array<Isolate>());
abstract_code =
Handle<AbstractCode>::cast(compilation_info()->bytecode_array());
} else {
DCHECK(compilation_info()->has_asm_wasm_data());
abstract_code =
@ -421,8 +420,8 @@ void InstallUnoptimizedCode(UnoptimizedCompilationInfo* compilation_info,
shared_info->set_is_asm_wasm_broken(true);
}
InstallBytecodeArray(compilation_info->bytecode_array<Isolate>(),
shared_info, parse_info, isolate);
InstallBytecodeArray(compilation_info->bytecode_array(), shared_info,
parse_info, isolate);
Handle<FeedbackMetadata> feedback_metadata = FeedbackMetadata::New(
isolate, compilation_info->feedback_vector_spec());
@ -438,8 +437,8 @@ void InstallUnoptimizedCode(UnoptimizedCompilationInfo* compilation_info,
if (compilation_info->has_coverage_info() &&
!shared_info->HasCoverageInfo()) {
DCHECK(isolate->is_block_code_coverage());
isolate->debug()->InstallCoverageInfo(
shared_info, compilation_info->coverage_info<Isolate>());
isolate->debug()->InstallCoverageInfo(shared_info,
compilation_info->coverage_info());
}
}
@ -1283,9 +1282,8 @@ bool Compiler::CollectSourcePositions(Isolate* isolate,
// table set on it as well.
if (shared_info->HasDebugInfo() &&
shared_info->GetDebugInfo().HasInstrumentedBytecodeArray()) {
ByteArray source_position_table = job->compilation_info()
->bytecode_array<Isolate>()
->SourcePositionTable();
ByteArray source_position_table =
job->compilation_info()->bytecode_array()->SourcePositionTable();
shared_info->GetDebugBytecodeArray().set_source_position_table(
source_position_table);
}
@ -2261,25 +2259,24 @@ Compiler::GetSharedFunctionInfoForStreamedScript(
return maybe_result;
}
template <typename Isolate>
HandleFor<Isolate, SharedFunctionInfo> Compiler::GetSharedFunctionInfo(
FunctionLiteral* literal, HandleFor<Isolate, Script> script,
Isolate* isolate) {
template <typename LocalIsolate>
Handle<SharedFunctionInfo> Compiler::GetSharedFunctionInfo(
FunctionLiteral* literal, Handle<Script> script, LocalIsolate* isolate) {
// Precondition: code has been parsed and scopes have been analyzed.
MaybeHandleFor<Isolate, SharedFunctionInfo> maybe_existing;
MaybeHandle<SharedFunctionInfo> maybe_existing;
// Find any previously allocated shared function info for the given literal.
maybe_existing = script->FindSharedFunctionInfo(isolate, literal);
// If we found an existing shared function info, return it.
HandleFor<Isolate, SharedFunctionInfo> existing;
Handle<SharedFunctionInfo> existing;
if (maybe_existing.ToHandle(&existing)) {
// If the function has been uncompiled (bytecode flushed) it will have lost
// any preparsed data. If we produced preparsed data during this compile for
// this function, replace the uncompiled data with one that includes it.
if (literal->produced_preparse_data() != nullptr &&
existing->HasUncompiledDataWithoutPreparseData()) {
HandleFor<Isolate, UncompiledData> existing_uncompiled_data =
Handle<UncompiledData> existing_uncompiled_data =
handle(existing->uncompiled_data(), isolate);
DCHECK_EQ(literal->start_position(),
existing_uncompiled_data->start_position());
@ -2287,11 +2284,11 @@ HandleFor<Isolate, SharedFunctionInfo> Compiler::GetSharedFunctionInfo(
existing_uncompiled_data->end_position());
// Use existing uncompiled data's inferred name as it may be more
// accurate than the literal we preparsed.
HandleFor<Isolate, String> inferred_name =
Handle<String> inferred_name =
handle(existing_uncompiled_data->inferred_name(), isolate);
HandleFor<Isolate, PreparseData> preparse_data =
Handle<PreparseData> preparse_data =
literal->produced_preparse_data()->Serialize(isolate);
HandleFor<Isolate, UncompiledData> new_uncompiled_data =
Handle<UncompiledData> new_uncompiled_data =
isolate->factory()->NewUncompiledDataWithPreparseData(
inferred_name, existing_uncompiled_data->start_position(),
existing_uncompiled_data->end_position(), preparse_data);
@ -2301,7 +2298,7 @@ HandleFor<Isolate, SharedFunctionInfo> Compiler::GetSharedFunctionInfo(
}
// Allocate a shared function info object which will be compiled lazily.
HandleFor<Isolate, SharedFunctionInfo> result =
Handle<SharedFunctionInfo> result =
isolate->factory()->NewSharedFunctionInfoForLiteral(literal, script,
false);
return result;
@ -2309,9 +2306,8 @@ HandleFor<Isolate, SharedFunctionInfo> Compiler::GetSharedFunctionInfo(
template Handle<SharedFunctionInfo> Compiler::GetSharedFunctionInfo(
FunctionLiteral* literal, Handle<Script> script, Isolate* isolate);
template OffThreadHandle<SharedFunctionInfo> Compiler::GetSharedFunctionInfo(
FunctionLiteral* literal, OffThreadHandle<Script> script,
OffThreadIsolate* isolate);
template Handle<SharedFunctionInfo> Compiler::GetSharedFunctionInfo(
FunctionLiteral* literal, Handle<Script> script, OffThreadIsolate* isolate);
MaybeHandle<Code> Compiler::GetOptimizedCodeForOSR(Handle<JSFunction> function,
BailoutId osr_offset,

View File

@ -176,10 +176,9 @@ class V8_EXPORT_PRIVATE Compiler : public AllStatic {
// Create a shared function info object for the given function literal
// node (the code may be lazily compiled).
template <typename Isolate>
static HandleFor<Isolate, SharedFunctionInfo> GetSharedFunctionInfo(
FunctionLiteral* node, HandleFor<Isolate, Script> script,
Isolate* isolate);
template <typename LocalIsolate>
static Handle<SharedFunctionInfo> GetSharedFunctionInfo(
FunctionLiteral* node, Handle<Script> script, LocalIsolate* isolate);
// ===========================================================================
// The following family of methods provides support for OSR. Code generated

View File

@ -155,13 +155,13 @@ void SourcePositionTableBuilder::AddEntry(const PositionTableEntry& entry) {
#endif
}
template <typename Isolate>
HandleFor<Isolate, ByteArray> SourcePositionTableBuilder::ToSourcePositionTable(
Isolate* isolate) {
template <typename LocalIsolate>
Handle<ByteArray> SourcePositionTableBuilder::ToSourcePositionTable(
LocalIsolate* isolate) {
if (bytes_.empty()) return isolate->factory()->empty_byte_array();
DCHECK(!Omit());
HandleFor<Isolate, ByteArray> table = isolate->factory()->NewByteArray(
Handle<ByteArray> table = isolate->factory()->NewByteArray(
static_cast<int>(bytes_.size()), AllocationType::kOld);
MemCopy(table->GetDataStartAddress(), bytes_.data(), bytes_.size());
@ -182,8 +182,8 @@ template EXPORT_TEMPLATE_DEFINE(V8_EXPORT_PRIVATE)
Handle<ByteArray> SourcePositionTableBuilder::ToSourcePositionTable(
Isolate* isolate);
template EXPORT_TEMPLATE_DEFINE(V8_EXPORT_PRIVATE)
OffThreadHandle<ByteArray> SourcePositionTableBuilder::
ToSourcePositionTable(OffThreadIsolate* isolate);
Handle<ByteArray> SourcePositionTableBuilder::ToSourcePositionTable(
OffThreadIsolate* isolate);
OwnedVector<byte> SourcePositionTableBuilder::ToSourcePositionTableVector() {
if (bytes_.empty()) return OwnedVector<byte>();

View File

@ -54,9 +54,9 @@ class V8_EXPORT_PRIVATE SourcePositionTableBuilder {
void AddPosition(size_t code_offset, SourcePosition source_position,
bool is_statement);
template <typename Isolate>
template <typename LocalIsolate>
EXPORT_TEMPLATE_DECLARE(V8_EXPORT_PRIVATE)
HandleFor<Isolate, ByteArray> ToSourcePositionTable(Isolate* isolate);
Handle<ByteArray> ToSourcePositionTable(LocalIsolate* isolate);
OwnedVector<byte> ToSourcePositionTableVector();
inline bool Omit() const { return mode_ != RECORD_SOURCE_POSITIONS; }

View File

@ -75,22 +75,16 @@ class V8_EXPORT_PRIVATE UnoptimizedCompilationInfo final {
}
bool has_coverage_info() const { return !coverage_info_.is_null(); }
template <typename Isolate>
HandleFor<Isolate, CoverageInfo> coverage_info() const {
return coverage_info_.get<Isolate>();
}
void set_coverage_info(HandleOrOffThreadHandle<CoverageInfo> coverage_info) {
Handle<CoverageInfo> coverage_info() const { return coverage_info_; }
void set_coverage_info(Handle<CoverageInfo> coverage_info) {
coverage_info_ = coverage_info;
}
// Accessors for the output of compilation.
bool has_bytecode_array() const { return !bytecode_array_.is_null(); }
template <typename Isolate>
HandleFor<Isolate, BytecodeArray> bytecode_array() const {
return bytecode_array_.get<Isolate>();
}
void SetBytecodeArray(HandleOrOffThreadHandle<BytecodeArray> bytecode_array) {
Handle<BytecodeArray> bytecode_array() const { return bytecode_array_; }
void SetBytecodeArray(Handle<BytecodeArray> bytecode_array) {
bytecode_array_ = bytecode_array;
}
@ -130,10 +124,10 @@ class V8_EXPORT_PRIVATE UnoptimizedCompilationInfo final {
// Encapsulates coverage information gathered by the bytecode generator.
// Needs to be stored on the shared function info once compilation completes.
HandleOrOffThreadHandle<CoverageInfo> coverage_info_;
Handle<CoverageInfo> coverage_info_;
// Holds the bytecode array generated by the interpreter.
HandleOrOffThreadHandle<BytecodeArray> bytecode_array_;
Handle<BytecodeArray> bytecode_array_;
// Holds the asm_wasm data struct generated by the asmjs compiler.
Handle<AsmWasmData> asm_wasm_data_;

View File

@ -646,8 +646,6 @@ class NewSpace;
class NewLargeObjectSpace;
class NumberDictionary;
class Object;
template <typename T>
class OffThreadHandle;
class OldLargeObjectSpace;
template <HeapObjectReferenceType kRefType, typename StorageType>
class TaggedImpl;

View File

@ -769,7 +769,7 @@ bool ScopeIterator::VisitLocals(const Visitor& visitor, Mode mode) const {
for (Variable* var : *current_scope_->locals()) {
DCHECK(!var->is_this());
if (ScopeInfo::VariableIsSynthetic(*var->name().get_handle())) continue;
if (ScopeInfo::VariableIsSynthetic(*var->name())) continue;
int index = var->index();
Handle<Object> value;

View File

@ -663,7 +663,7 @@ bool HasChangedScope(FunctionLiteral* a, FunctionLiteral* b) {
if (!var->IsContextSlot()) continue;
auto it = vars.find(var->index());
if (it == vars.end()) return true;
if (*it->second != *var->name().get_handle()) return true;
if (*it->second != *var->name()) return true;
}
scope_a = scope_a->outer_scope();
scope_b = scope_b->outer_scope();

View File

@ -448,17 +448,6 @@ 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 = MaybeHandle<T>;
using HandleScopeType = HandleScope;
};
// 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 {};
@ -470,6 +459,8 @@ class V8_EXPORT_PRIVATE Isolate final : private HiddenFactory {
class EntryStackItem;
public:
using HandleScopeType = HandleScope;
// A thread has a PerIsolateThreadData instance for each isolate that it has
// entered. That instance is allocated when the isolate is initially entered
// and reused on subsequent entries.

View File

@ -11,11 +11,12 @@
namespace v8 {
namespace internal {
OffThreadIsolate::OffThreadIsolate(Isolate* isolate)
OffThreadIsolate::OffThreadIsolate(Isolate* isolate, Zone* zone)
: HiddenOffThreadFactory(isolate),
isolate_(isolate),
logger_(new OffThreadLogger()),
thread_id_(ThreadId::Current()) {}
thread_id_(ThreadId::Current()),
handle_zone_(zone) {}
OffThreadIsolate::~OffThreadIsolate() { delete logger_; }
int OffThreadIsolate::GetNextScriptId() { return isolate_->GetNextScriptId(); }

View File

@ -7,7 +7,7 @@
#include "src/base/logging.h"
#include "src/execution/thread-id.h"
#include "src/handles/handle-for.h"
#include "src/handles/handles.h"
#include "src/heap/off-thread-factory.h"
namespace v8 {
@ -17,15 +17,6 @@ class Isolate;
class OffThreadIsolate;
class OffThreadLogger;
template <>
struct HandleTraits<OffThreadIsolate> {
template <typename T>
using HandleType = OffThreadHandle<T>;
template <typename T>
using MaybeHandleType = OffThreadHandle<T>;
using HandleScopeType = OffThreadHandleScope;
};
// HiddenOffThreadFactory parallels Isolate's HiddenFactory
class V8_EXPORT_PRIVATE HiddenOffThreadFactory : private OffThreadFactory {
public:
@ -42,7 +33,9 @@ class V8_EXPORT_PRIVATE HiddenOffThreadFactory : private OffThreadFactory {
class V8_EXPORT_PRIVATE OffThreadIsolate final
: private HiddenOffThreadFactory {
public:
explicit OffThreadIsolate(Isolate* isolate);
using HandleScopeType = OffThreadHandleScope;
explicit OffThreadIsolate(Isolate* isolate, Zone* zone);
~OffThreadIsolate();
v8::internal::OffThreadFactory* factory() {
@ -53,14 +46,25 @@ class V8_EXPORT_PRIVATE OffThreadIsolate final
v8::internal::OffThreadFactory*)this; // NOLINT(readability/casting)
}
// This method finishes the use of the off-thread Isolate, and can be safely
// called off-thread.
void FinishOffThread() { factory()->FinishOffThread(); }
template <typename T>
OffThreadHandle<T> Throw(OffThreadHandle<Object> exception) {
Handle<T> Throw(Handle<Object> exception) {
UNREACHABLE();
}
[[noreturn]] void FatalProcessOutOfHeapMemory(const char* location) {
UNREACHABLE();
}
Address* NewHandle(Address object) {
Address* location =
static_cast<Address*>(handle_zone_->New(sizeof(Address)));
*location = object;
return location;
}
int GetNextScriptId();
#if V8_SFI_HAS_UNIQUE_ID
int GetNextUniqueSharedFunctionInfoId();
@ -80,6 +84,7 @@ class V8_EXPORT_PRIVATE OffThreadIsolate final
OffThreadLogger* logger_;
ThreadId thread_id_;
Zone* handle_zone_;
};
} // namespace internal

View File

@ -1,31 +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_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>;
template <typename IsolateOrFactory>
using HandleScopeFor = typename HandleTraits<IsolateOrFactory>::HandleScopeType;
} // namespace internal
} // namespace v8
#endif // V8_HANDLES_HANDLE_FOR_H_

View File

@ -6,17 +6,19 @@
#define V8_HANDLES_HANDLES_INL_H_
#include "src/execution/isolate.h"
#include "src/execution/off-thread-isolate.h"
#include "src/handles/handles.h"
#include "src/sanitizer/msan.h"
namespace v8 {
namespace internal {
class OffThreadIsolate;
HandleBase::HandleBase(Address object, Isolate* isolate)
: location_(HandleScope::GetHandle(isolate, object)) {}
HandleBase::HandleBase(Address object, OffThreadIsolate* isolate)
: location_(isolate->NewHandle(object)) {}
// Allocate a new handle for the object, do not canonicalize.
template <typename T>
@ -35,27 +37,29 @@ template <typename T>
Handle<T>::Handle(T object, Isolate* isolate)
: HandleBase(object.ptr(), isolate) {}
template <typename T>
Handle<T>::Handle(T object, OffThreadIsolate* isolate)
: HandleBase(object.ptr(), isolate) {}
template <typename T>
V8_INLINE Handle<T> handle(T object, Isolate* isolate) {
return Handle<T>(object, isolate);
}
template <typename T>
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);
V8_INLINE Handle<T> handle(T object, OffThreadIsolate* isolate) {
return Handle<T>(object, isolate);
}
// Convenience overloads for when we already have a Handle, but want
// either a Handle or an OffThreadHandle.
// either a Handle or an Handle.
template <typename T>
V8_INLINE Handle<T> handle(Handle<T> handle, Isolate* isolate) {
return handle;
}
template <typename T>
V8_INLINE OffThreadHandle<T> handle(Handle<T> handle,
OffThreadIsolate* isolate) {
return OffThreadHandle<T>(*handle);
V8_INLINE Handle<T> handle(Handle<T> handle, OffThreadIsolate* isolate) {
return Handle<T>(*handle);
}
template <typename T>

View File

@ -12,7 +12,6 @@
#include "src/base/macros.h"
#include "src/common/checks.h"
#include "src/common/globals.h"
#include "src/handles/handle-for.h"
#include "src/zone/zone.h"
namespace v8 {
@ -40,6 +39,7 @@ class HandleBase {
public:
V8_INLINE explicit HandleBase(Address* location) : location_(location) {}
V8_INLINE explicit HandleBase(Address object, Isolate* isolate);
V8_INLINE explicit HandleBase(Address object, OffThreadIsolate* isolate);
// Check if this handle refers to the exact same object as the other handle.
V8_INLINE bool is_identical_to(const HandleBase that) const {
@ -76,29 +76,6 @@ class HandleBase {
Address* location_;
};
template <typename T>
class Handle;
template <typename T>
class OffThreadHandle;
// {ObjectRef} is returned by {Handle::operator->}. It should never be stored
// anywhere or used in any other code; no one should ever have to spell out
// {ObjectRef} in code. Its only purpose is to be dereferenced immediately by
// "operator-> chaining". Returning the address of the field is valid because
// this objects lifetime only ends at the end of the full statement.
template <typename T>
class HandleObjectRef {
public:
T* operator->() { return &object_; }
private:
friend class Handle<T>;
friend class OffThreadHandle<T>;
explicit HandleObjectRef(T object) : object_(object) {}
T object_;
};
// ----------------------------------------------------------------------------
// A Handle provides a reference to an object that survives relocation by
// the garbage collector.
@ -113,6 +90,22 @@ class HandleObjectRef {
template <typename T>
class Handle final : public HandleBase {
public:
// {ObjectRef} is returned by {Handle::operator->}. It should never be stored
// anywhere or used in any other code; no one should ever have to spell out
// {ObjectRef} in code. Its only purpose is to be dereferenced immediately by
// "operator-> chaining". Returning the address of the field is valid because
// this objects lifetime only ends at the end of the full statement.
class ObjectRef {
public:
T* operator->() { return &object_; }
private:
friend class Handle<T>;
explicit ObjectRef(T object) : object_(object) {}
T object_;
};
V8_INLINE explicit Handle() : HandleBase(nullptr) {
// Skip static type check in order to allow Handle<XXX>::null() as default
// parameter values in non-inl header files without requiring full
@ -127,6 +120,7 @@ class Handle final : public HandleBase {
}
V8_INLINE Handle(T object, Isolate* isolate);
V8_INLINE Handle(T object, OffThreadIsolate* isolate);
// Allocate a new handle for the object, do not canonicalize.
V8_INLINE static Handle<T> New(T object, Isolate* isolate);
@ -138,9 +132,7 @@ class Handle final : public HandleBase {
// NOLINTNEXTLINE
V8_INLINE Handle(Handle<S> handle) : HandleBase(handle) {}
V8_INLINE HandleObjectRef<T> operator->() const {
return HandleObjectRef<T>{**this};
}
V8_INLINE ObjectRef operator->() const { return ObjectRef{**this}; }
V8_INLINE T operator*() const {
// unchecked_cast because we rather trust Handle<T> to contain a T than
@ -185,136 +177,6 @@ class Handle final : public HandleBase {
template <typename T>
inline std::ostream& operator<<(std::ostream& os, Handle<T> handle);
// ----------------------------------------------------------------------------
// A fake Handle that simply wraps an object reference. This is used for
// off-thread Objects, where we want a class that behaves like Handle for the
// purposes of operator->, casting, etc., but isn't a GC root and doesn't
// require access to the Isolate.
template <typename T>
class OffThreadHandle {
public:
OffThreadHandle() = default;
explicit OffThreadHandle(T obj, OffThreadIsolate* isolate = nullptr)
: address_(obj.ptr()) {}
// Constructor for handling automatic up casting. We rely on the compiler
// making sure that the cast to T is legitimate.
template <typename U>
// NOLINTNEXTLINE
OffThreadHandle<T>(OffThreadHandle<U> other)
: address_(static_cast<T>(*other).ptr()) {}
T operator*() const { return T::unchecked_cast(Object(address_)); }
V8_INLINE HandleObjectRef<T> operator->() const {
return HandleObjectRef<T>{**this};
}
template <typename U>
static OffThreadHandle<T> cast(OffThreadHandle<U> other) {
return OffThreadHandle<T>(T::cast(*other));
}
bool is_null() const {
// TODO(leszeks): This will only work for HeapObjects, figure out a way to
// make is_null work for Object and Smi too.
return (*this)->is_null();
}
bool ToHandle(OffThreadHandle<T>* out) {
if (is_null()) return false;
*out = *this;
return true;
}
OffThreadHandle<T> ToHandleChecked() {
DCHECK(!is_null());
return *this;
}
private:
Address address_ = 0;
};
// A helper class which wraps an normal or off-thread handle, and returns one
// or the other depending on the factory type.
template <typename T>
class HandleOrOffThreadHandle {
public:
HandleOrOffThreadHandle() = default;
template <typename U>
HandleOrOffThreadHandle(Handle<U> handle) // NOLINT
: value_(bit_cast<Address>(static_cast<Handle<T>>(handle).location())) {
#ifdef DEBUG
which_ = kHandle;
#endif
}
template <typename U>
HandleOrOffThreadHandle(OffThreadHandle<U> handle) // NOLINT
: value_(static_cast<OffThreadHandle<T>>(handle)->ptr()) {
#ifdef DEBUG
which_ = kOffThreadHandle;
#endif
}
// Explicit getters for the Handle and OffThreadHandle.
inline Handle<T> get_handle() const {
DCHECK_NE(which_, kOffThreadHandle);
return Handle<T>(reinterpret_cast<Address*>(value_));
}
inline OffThreadHandle<T> get_off_thread_handle() const {
DCHECK_NE(which_, kHandle);
return OffThreadHandle<T>(T::unchecked_cast(Object(value_)));
}
// Implicitly convert to Handle, MaybeHandle and OffThreadHandle, whenever
// the conversion can be implicit.
template <typename U>
operator Handle<U>() const { // NOLINT
return get_handle();
}
template <typename U>
operator MaybeHandle<U>() const { // NOLINT
return get_handle();
}
template <typename U>
operator OffThreadHandle<U>() const { // NOLINT
return get_off_thread_handle();
}
// Allow templated dispatch on which type of handle to get.
template <typename IsolateType>
inline HandleFor<IsolateType, T> get() const {
return get_for(Tag<IsolateType>());
}
inline bool is_null() const { return value_ == 0; }
#ifdef DEBUG
inline bool is_initialized() const { return which_ != kUninitialized; }
#endif
private:
// Tagged overloads because we can't specialize the above getter
// without also specializing the class.
template <typename IsolateType>
struct Tag {};
V8_INLINE Handle<T> get_for(Tag<class Isolate>) const { return get_handle(); }
V8_INLINE OffThreadHandle<T> get_for(Tag<class OffThreadIsolate>) const {
return get_off_thread_handle();
}
// Either handle.location() or off_thread_handle->ptr().
Address value_ = 0;
#ifdef DEBUG
enum { kUninitialized, kHandle, kOffThreadHandle } which_ = kUninitialized;
#endif
};
// ----------------------------------------------------------------------------
// A stack-allocated class that governs a number of local handles.
// After a handle scope has been created, all local handles will be
@ -503,6 +365,8 @@ struct HandleScopeData final {
class OffThreadHandleScope {
public:
// Off-thread Handles are allocated in the parse/compile zone, and not
// cleared out, so the scope doesn't have to do anything
explicit OffThreadHandleScope(OffThreadIsolate* isolate) {}
};

View File

@ -7,8 +7,8 @@
#include "src/heap/factory-base.h"
#include "src/handles/handle-for.h"
#include "src/numbers/conversions.h"
#include "src/objects/heap-number.h"
#include "src/objects/smi.h"
#include "src/roots/roots.h"
@ -16,13 +16,13 @@ namespace v8 {
namespace internal {
template <typename Impl>
HandleFor<Impl, Oddball> FactoryBase<Impl>::ToBoolean(bool value) {
Handle<Oddball> FactoryBase<Impl>::ToBoolean(bool value) {
return value ? impl()->true_value() : impl()->false_value();
}
template <typename Impl>
template <AllocationType allocation>
HandleFor<Impl, Object> FactoryBase<Impl>::NewNumber(double value) {
Handle<Object> FactoryBase<Impl>::NewNumber(double value) {
// Materialize as a SMI if possible.
int32_t int_value;
if (DoubleToSmiInteger(value, &int_value)) {
@ -33,7 +33,7 @@ HandleFor<Impl, Object> FactoryBase<Impl>::NewNumber(double value) {
template <typename Impl>
template <AllocationType allocation>
HandleFor<Impl, Object> FactoryBase<Impl>::NewNumberFromInt(int32_t value) {
Handle<Object> FactoryBase<Impl>::NewNumberFromInt(int32_t value) {
if (Smi::IsValid(value)) return handle(Smi::FromInt(value), isolate());
// Bypass NewNumber to avoid various redundant checks.
return NewHeapNumber<allocation>(FastI2D(value));
@ -41,7 +41,7 @@ HandleFor<Impl, Object> FactoryBase<Impl>::NewNumberFromInt(int32_t value) {
template <typename Impl>
template <AllocationType allocation>
HandleFor<Impl, Object> FactoryBase<Impl>::NewNumberFromUint(uint32_t value) {
Handle<Object> FactoryBase<Impl>::NewNumberFromUint(uint32_t value) {
int32_t int32v = static_cast<int32_t>(value);
if (int32v >= 0 && Smi::IsValid(int32v)) {
return handle(Smi::FromInt(int32v), isolate());
@ -51,7 +51,7 @@ HandleFor<Impl, Object> FactoryBase<Impl>::NewNumberFromUint(uint32_t value) {
template <typename Impl>
template <AllocationType allocation>
HandleFor<Impl, Object> FactoryBase<Impl>::NewNumberFromSize(size_t value) {
Handle<Object> FactoryBase<Impl>::NewNumberFromSize(size_t value) {
// We can't use Smi::IsValid() here because that operates on a signed
// intptr_t, and casting from size_t could create a bogus sign bit.
if (value <= static_cast<size_t>(Smi::kMaxValue)) {
@ -62,7 +62,7 @@ HandleFor<Impl, Object> FactoryBase<Impl>::NewNumberFromSize(size_t value) {
template <typename Impl>
template <AllocationType allocation>
HandleFor<Impl, Object> FactoryBase<Impl>::NewNumberFromInt64(int64_t value) {
Handle<Object> FactoryBase<Impl>::NewNumberFromInt64(int64_t value) {
if (value <= std::numeric_limits<int32_t>::max() &&
value >= std::numeric_limits<int32_t>::min() &&
Smi::IsValid(static_cast<int32_t>(value))) {
@ -73,24 +73,23 @@ HandleFor<Impl, Object> FactoryBase<Impl>::NewNumberFromInt64(int64_t value) {
template <typename Impl>
template <AllocationType allocation>
HandleFor<Impl, HeapNumber> FactoryBase<Impl>::NewHeapNumber(double value) {
HandleFor<Impl, HeapNumber> heap_number = NewHeapNumber<allocation>();
Handle<HeapNumber> FactoryBase<Impl>::NewHeapNumber(double value) {
Handle<HeapNumber> heap_number = NewHeapNumber<allocation>();
heap_number->set_value(value);
return heap_number;
}
template <typename Impl>
template <AllocationType allocation>
HandleFor<Impl, HeapNumber> FactoryBase<Impl>::NewHeapNumberFromBits(
uint64_t bits) {
HandleFor<Impl, HeapNumber> heap_number = NewHeapNumber<allocation>();
Handle<HeapNumber> FactoryBase<Impl>::NewHeapNumberFromBits(uint64_t bits) {
Handle<HeapNumber> heap_number = NewHeapNumber<allocation>();
heap_number->set_value_as_bits(bits);
return heap_number;
}
template <typename Impl>
template <AllocationType allocation>
HandleFor<Impl, HeapNumber> FactoryBase<Impl>::NewHeapNumberWithHoleNaN() {
Handle<HeapNumber> FactoryBase<Impl>::NewHeapNumberWithHoleNaN() {
return NewHeapNumberFromBits<allocation>(kHoleNanInt64);
}

View File

@ -26,7 +26,7 @@ namespace internal {
template <typename Impl>
template <AllocationType allocation>
HandleFor<Impl, HeapNumber> FactoryBase<Impl>::NewHeapNumber() {
Handle<HeapNumber> FactoryBase<Impl>::NewHeapNumber() {
STATIC_ASSERT(HeapNumber::kSize <= kMaxRegularHeapObjectSize);
Map map = read_only_roots().heap_number_map();
HeapObject result = AllocateRawWithImmortalMap(HeapNumber::kSize, allocation,
@ -41,23 +41,23 @@ FactoryBase<Factory>::NewHeapNumber<AllocationType::kOld>();
template V8_EXPORT_PRIVATE Handle<HeapNumber>
FactoryBase<Factory>::NewHeapNumber<AllocationType::kReadOnly>();
template V8_EXPORT_PRIVATE OffThreadHandle<HeapNumber>
template V8_EXPORT_PRIVATE Handle<HeapNumber>
FactoryBase<OffThreadFactory>::NewHeapNumber<AllocationType::kOld>();
template <typename Impl>
HandleFor<Impl, Struct> FactoryBase<Impl>::NewStruct(
InstanceType type, AllocationType allocation) {
Handle<Struct> FactoryBase<Impl>::NewStruct(InstanceType type,
AllocationType allocation) {
Map map = Map::GetStructMap(read_only_roots(), type);
int size = map.instance_size();
HeapObject result = AllocateRawWithImmortalMap(size, allocation, map);
HandleFor<Impl, Struct> str = handle(Struct::cast(result), isolate());
Handle<Struct> str = handle(Struct::cast(result), isolate());
str->InitializeBody(size);
return str;
}
template <typename Impl>
HandleFor<Impl, FixedArray> FactoryBase<Impl>::NewFixedArray(
int length, AllocationType allocation) {
Handle<FixedArray> FactoryBase<Impl>::NewFixedArray(int length,
AllocationType allocation) {
DCHECK_LE(0, length);
if (length == 0) return impl()->empty_fixed_array();
return NewFixedArrayWithFiller(read_only_roots().fixed_array_map(), length,
@ -66,7 +66,7 @@ HandleFor<Impl, FixedArray> FactoryBase<Impl>::NewFixedArray(
}
template <typename Impl>
HandleFor<Impl, FixedArray> FactoryBase<Impl>::NewFixedArrayWithMap(
Handle<FixedArray> FactoryBase<Impl>::NewFixedArrayWithMap(
Map map, int length, AllocationType allocation) {
// Zero-length case must be handled outside, where the knowledge about
// the map is.
@ -76,7 +76,7 @@ HandleFor<Impl, FixedArray> FactoryBase<Impl>::NewFixedArrayWithMap(
}
template <typename Impl>
HandleFor<Impl, FixedArray> FactoryBase<Impl>::NewFixedArrayWithHoles(
Handle<FixedArray> FactoryBase<Impl>::NewFixedArrayWithHoles(
int length, AllocationType allocation) {
DCHECK_LE(0, length);
if (length == 0) return impl()->empty_fixed_array();
@ -86,21 +86,20 @@ HandleFor<Impl, FixedArray> FactoryBase<Impl>::NewFixedArrayWithHoles(
}
template <typename Impl>
HandleFor<Impl, FixedArray> FactoryBase<Impl>::NewFixedArrayWithFiller(
Handle<FixedArray> FactoryBase<Impl>::NewFixedArrayWithFiller(
Map map, int length, Oddball filler, AllocationType allocation) {
HeapObject result = AllocateRawFixedArray(length, allocation);
DCHECK(ReadOnlyHeap::Contains(map));
DCHECK(ReadOnlyHeap::Contains(filler));
result.set_map_after_allocation(map, SKIP_WRITE_BARRIER);
HandleFor<Impl, FixedArray> array =
handle(FixedArray::cast(result), isolate());
Handle<FixedArray> array = handle(FixedArray::cast(result), isolate());
array->set_length(length);
MemsetTagged(array->data_start(), filler, length);
return array;
}
template <typename Impl>
HandleFor<Impl, FixedArrayBase> FactoryBase<Impl>::NewFixedDoubleArray(
Handle<FixedArrayBase> FactoryBase<Impl>::NewFixedDoubleArray(
int length, AllocationType allocation) {
if (length == 0) return impl()->empty_fixed_array();
if (length < 0 || length > FixedDoubleArray::kMaxLength) {
@ -110,14 +109,14 @@ HandleFor<Impl, FixedArrayBase> FactoryBase<Impl>::NewFixedDoubleArray(
Map map = read_only_roots().fixed_double_array_map();
HeapObject result =
AllocateRawWithImmortalMap(size, allocation, map, kDoubleAligned);
HandleFor<Impl, FixedDoubleArray> array =
Handle<FixedDoubleArray> array =
handle(FixedDoubleArray::cast(result), isolate());
array->set_length(length);
return array;
}
template <typename Impl>
HandleFor<Impl, WeakFixedArray> FactoryBase<Impl>::NewWeakFixedArrayWithMap(
Handle<WeakFixedArray> FactoryBase<Impl>::NewWeakFixedArrayWithMap(
Map map, int length, AllocationType allocation) {
// Zero-length case must be handled outside.
DCHECK_LT(0, length);
@ -127,7 +126,7 @@ HandleFor<Impl, WeakFixedArray> FactoryBase<Impl>::NewWeakFixedArrayWithMap(
AllocateRawArray(WeakFixedArray::SizeFor(length), allocation);
result.set_map_after_allocation(map, SKIP_WRITE_BARRIER);
HandleFor<Impl, WeakFixedArray> array =
Handle<WeakFixedArray> array =
handle(WeakFixedArray::cast(result), isolate());
array->set_length(length);
MemsetTagged(ObjectSlot(array->data_start()),
@ -137,7 +136,7 @@ HandleFor<Impl, WeakFixedArray> FactoryBase<Impl>::NewWeakFixedArrayWithMap(
}
template <typename Impl>
HandleFor<Impl, WeakFixedArray> FactoryBase<Impl>::NewWeakFixedArray(
Handle<WeakFixedArray> FactoryBase<Impl>::NewWeakFixedArray(
int length, AllocationType allocation) {
DCHECK_LE(0, length);
if (length == 0) return impl()->empty_weak_fixed_array();
@ -146,24 +145,24 @@ HandleFor<Impl, WeakFixedArray> FactoryBase<Impl>::NewWeakFixedArray(
}
template <typename Impl>
HandleFor<Impl, ByteArray> FactoryBase<Impl>::NewByteArray(
int length, AllocationType allocation) {
Handle<ByteArray> FactoryBase<Impl>::NewByteArray(int length,
AllocationType allocation) {
if (length < 0 || length > ByteArray::kMaxLength) {
isolate()->FatalProcessOutOfHeapMemory("invalid array length");
}
int size = ByteArray::SizeFor(length);
HeapObject result = AllocateRawWithImmortalMap(
size, allocation, read_only_roots().byte_array_map());
HandleFor<Impl, ByteArray> array(ByteArray::cast(result), isolate());
Handle<ByteArray> array(ByteArray::cast(result), isolate());
array->set_length(length);
array->clear_padding();
return array;
}
template <typename Impl>
HandleFor<Impl, BytecodeArray> FactoryBase<Impl>::NewBytecodeArray(
Handle<BytecodeArray> FactoryBase<Impl>::NewBytecodeArray(
int length, const byte* raw_bytecodes, int frame_size, int parameter_count,
HandleFor<Impl, FixedArray> constant_pool) {
Handle<FixedArray> constant_pool) {
if (length < 0 || length > BytecodeArray::kMaxLength) {
isolate()->FatalProcessOutOfHeapMemory("invalid array length");
}
@ -174,8 +173,7 @@ HandleFor<Impl, BytecodeArray> FactoryBase<Impl>::NewBytecodeArray(
int size = BytecodeArray::SizeFor(length);
HeapObject result = AllocateRawWithImmortalMap(
size, AllocationType::kOld, read_only_roots().bytecode_array_map());
HandleFor<Impl, BytecodeArray> instance(BytecodeArray::cast(result),
isolate());
Handle<BytecodeArray> instance(BytecodeArray::cast(result), isolate());
instance->set_length(length);
instance->set_frame_size(frame_size);
instance->set_parameter_count(parameter_count);
@ -194,18 +192,17 @@ HandleFor<Impl, BytecodeArray> FactoryBase<Impl>::NewBytecodeArray(
}
template <typename Impl>
HandleFor<Impl, Script> FactoryBase<Impl>::NewScript(
HandleFor<Impl, String> source) {
Handle<Script> FactoryBase<Impl>::NewScript(Handle<String> source) {
return NewScriptWithId(source, isolate()->GetNextScriptId());
}
template <typename Impl>
HandleFor<Impl, Script> FactoryBase<Impl>::NewScriptWithId(
HandleFor<Impl, String> source, int script_id) {
Handle<Script> FactoryBase<Impl>::NewScriptWithId(Handle<String> source,
int script_id) {
// Create and initialize script object.
ReadOnlyRoots roots = read_only_roots();
HandleFor<Impl, Script> script = HandleFor<Impl, Script>::cast(
NewStruct(SCRIPT_TYPE, AllocationType::kOld));
Handle<Script> script =
Handle<Script>::cast(NewStruct(SCRIPT_TYPE, AllocationType::kOld));
script->set_source(*source);
script->set_name(roots.undefined_value());
script->set_id(script_id);
@ -228,14 +225,12 @@ HandleFor<Impl, Script> FactoryBase<Impl>::NewScriptWithId(
}
template <typename Impl>
HandleFor<Impl, SharedFunctionInfo>
FactoryBase<Impl>::NewSharedFunctionInfoForLiteral(
FunctionLiteral* literal, HandleFor<Impl, Script> script,
bool is_toplevel) {
Handle<SharedFunctionInfo> FactoryBase<Impl>::NewSharedFunctionInfoForLiteral(
FunctionLiteral* literal, Handle<Script> script, bool is_toplevel) {
FunctionKind kind = literal->kind();
HandleFor<Impl, SharedFunctionInfo> shared = NewSharedFunctionInfo(
literal->GetName(isolate()), MaybeHandleFor<Impl, Code>(),
Builtins::kCompileLazy, kind);
Handle<SharedFunctionInfo> shared =
NewSharedFunctionInfo(literal->GetName(isolate()), MaybeHandle<Code>(),
Builtins::kCompileLazy, kind);
SharedFunctionInfo::InitFromFunctionLiteral(isolate(), shared, literal,
is_toplevel);
shared->SetScript(read_only_roots(), *script, literal->function_literal_id(),
@ -244,10 +239,10 @@ FactoryBase<Impl>::NewSharedFunctionInfoForLiteral(
}
template <typename Impl>
HandleFor<Impl, PreparseData> FactoryBase<Impl>::NewPreparseData(
int data_length, int children_length) {
Handle<PreparseData> FactoryBase<Impl>::NewPreparseData(int data_length,
int children_length) {
int size = PreparseData::SizeFor(data_length, children_length);
HandleFor<Impl, PreparseData> result = handle(
Handle<PreparseData> result = handle(
PreparseData::cast(AllocateRawWithImmortalMap(
size, AllocationType::kOld, read_only_roots().preparse_data_map())),
isolate());
@ -260,11 +255,11 @@ HandleFor<Impl, PreparseData> FactoryBase<Impl>::NewPreparseData(
}
template <typename Impl>
HandleFor<Impl, UncompiledDataWithoutPreparseData>
Handle<UncompiledDataWithoutPreparseData>
FactoryBase<Impl>::NewUncompiledDataWithoutPreparseData(
HandleFor<Impl, String> inferred_name, int32_t start_position,
Handle<String> inferred_name, int32_t start_position,
int32_t end_position) {
HandleFor<Impl, UncompiledDataWithoutPreparseData> result = handle(
Handle<UncompiledDataWithoutPreparseData> result = handle(
UncompiledDataWithoutPreparseData::cast(NewWithImmortalMap(
impl()->read_only_roots().uncompiled_data_without_preparse_data_map(),
AllocationType::kOld)),
@ -275,11 +270,11 @@ FactoryBase<Impl>::NewUncompiledDataWithoutPreparseData(
}
template <typename Impl>
HandleFor<Impl, UncompiledDataWithPreparseData>
Handle<UncompiledDataWithPreparseData>
FactoryBase<Impl>::NewUncompiledDataWithPreparseData(
HandleFor<Impl, String> inferred_name, int32_t start_position,
int32_t end_position, HandleFor<Impl, PreparseData> preparse_data) {
HandleFor<Impl, UncompiledDataWithPreparseData> result = handle(
Handle<String> inferred_name, int32_t start_position, int32_t end_position,
Handle<PreparseData> preparse_data) {
Handle<UncompiledDataWithPreparseData> result = handle(
UncompiledDataWithPreparseData::cast(NewWithImmortalMap(
impl()->read_only_roots().uncompiled_data_with_preparse_data_map(),
AllocationType::kOld)),
@ -292,14 +287,13 @@ FactoryBase<Impl>::NewUncompiledDataWithPreparseData(
}
template <typename Impl>
HandleFor<Impl, SharedFunctionInfo> FactoryBase<Impl>::NewSharedFunctionInfo(
MaybeHandleFor<Impl, String> maybe_name,
MaybeHandleFor<Impl, HeapObject> maybe_function_data,
Handle<SharedFunctionInfo> FactoryBase<Impl>::NewSharedFunctionInfo(
MaybeHandle<String> maybe_name, MaybeHandle<HeapObject> maybe_function_data,
int maybe_builtin_index, FunctionKind kind) {
HandleFor<Impl, SharedFunctionInfo> shared = NewSharedFunctionInfo();
Handle<SharedFunctionInfo> shared = NewSharedFunctionInfo();
// Function names are assumed to be flat elsewhere.
HandleFor<Impl, String> shared_name;
Handle<String> shared_name;
bool has_shared_name = maybe_name.ToHandle(&shared_name);
if (has_shared_name) {
DCHECK(shared_name->IsFlat());
@ -309,7 +303,7 @@ HandleFor<Impl, SharedFunctionInfo> FactoryBase<Impl>::NewSharedFunctionInfo(
SharedFunctionInfo::kNoSharedNameSentinel);
}
HandleFor<Impl, HeapObject> function_data;
Handle<HeapObject> function_data;
if (maybe_function_data.ToHandle(&function_data)) {
// If we pass function_data then we shouldn't pass a builtin index, and
// the function_data should not be code with a builtin.
@ -333,7 +327,7 @@ HandleFor<Impl, SharedFunctionInfo> FactoryBase<Impl>::NewSharedFunctionInfo(
}
template <typename Impl>
HandleFor<Impl, ObjectBoilerplateDescription>
Handle<ObjectBoilerplateDescription>
FactoryBase<Impl>::NewObjectBoilerplateDescription(int boilerplate,
int all_properties,
int index_keys,
@ -356,8 +350,8 @@ FactoryBase<Impl>::NewObjectBoilerplateDescription(int boilerplate,
size++;
}
HandleFor<Impl, ObjectBoilerplateDescription> description =
HandleFor<Impl, ObjectBoilerplateDescription>::cast(NewFixedArrayWithMap(
Handle<ObjectBoilerplateDescription> description =
Handle<ObjectBoilerplateDescription>::cast(NewFixedArrayWithMap(
read_only_roots().object_boilerplate_description_map(), size,
AllocationType::kOld));
@ -373,12 +367,11 @@ FactoryBase<Impl>::NewObjectBoilerplateDescription(int boilerplate,
}
template <typename Impl>
HandleFor<Impl, ArrayBoilerplateDescription>
Handle<ArrayBoilerplateDescription>
FactoryBase<Impl>::NewArrayBoilerplateDescription(
ElementsKind elements_kind,
HandleFor<Impl, FixedArrayBase> constant_values) {
HandleFor<Impl, ArrayBoilerplateDescription> result =
HandleFor<Impl, ArrayBoilerplateDescription>::cast(
ElementsKind elements_kind, Handle<FixedArrayBase> constant_values) {
Handle<ArrayBoilerplateDescription> result =
Handle<ArrayBoilerplateDescription>::cast(
NewStruct(ARRAY_BOILERPLATE_DESCRIPTION_TYPE, AllocationType::kOld));
result->set_elements_kind(elements_kind);
result->set_constant_elements(*constant_values);
@ -386,14 +379,13 @@ FactoryBase<Impl>::NewArrayBoilerplateDescription(
}
template <typename Impl>
HandleFor<Impl, TemplateObjectDescription>
Handle<TemplateObjectDescription>
FactoryBase<Impl>::NewTemplateObjectDescription(
HandleFor<Impl, FixedArray> raw_strings,
HandleFor<Impl, FixedArray> cooked_strings) {
Handle<FixedArray> raw_strings, Handle<FixedArray> cooked_strings) {
DCHECK_EQ(raw_strings->length(), cooked_strings->length());
DCHECK_LT(0, raw_strings->length());
HandleFor<Impl, TemplateObjectDescription> result =
HandleFor<Impl, TemplateObjectDescription>::cast(
Handle<TemplateObjectDescription> result =
Handle<TemplateObjectDescription>::cast(
NewStruct(TEMPLATE_OBJECT_DESCRIPTION_TYPE, AllocationType::kOld));
result->set_raw_strings(*raw_strings);
result->set_cooked_strings(*cooked_strings);
@ -401,7 +393,7 @@ FactoryBase<Impl>::NewTemplateObjectDescription(
}
template <typename Impl>
HandleFor<Impl, CoverageInfo> FactoryBase<Impl>::NewCoverageInfo(
Handle<CoverageInfo> FactoryBase<Impl>::NewCoverageInfo(
const ZoneVector<SourceRange>& slots) {
const int slot_count = static_cast<int>(slots.size());
@ -409,7 +401,7 @@ HandleFor<Impl, CoverageInfo> FactoryBase<Impl>::NewCoverageInfo(
Map map = read_only_roots().coverage_info_map();
HeapObject result =
AllocateRawWithImmortalMap(size, AllocationType::kYoung, map);
HandleFor<Impl, CoverageInfo> info(CoverageInfo::cast(result), isolate());
Handle<CoverageInfo> info(CoverageInfo::cast(result), isolate());
info->set_slot_count(slot_count);
for (int i = 0; i < slot_count; i++) {
@ -421,10 +413,9 @@ HandleFor<Impl, CoverageInfo> FactoryBase<Impl>::NewCoverageInfo(
}
template <typename Impl>
HandleFor<Impl, SeqOneByteString>
FactoryBase<Impl>::NewOneByteInternalizedString(
Handle<SeqOneByteString> FactoryBase<Impl>::NewOneByteInternalizedString(
const Vector<const uint8_t>& str, uint32_t hash_field) {
HandleFor<Impl, SeqOneByteString> result =
Handle<SeqOneByteString> result =
AllocateRawOneByteInternalizedString(str.length(), hash_field);
DisallowHeapAllocation no_gc;
MemCopy(result->GetChars(no_gc), str.begin(), str.length());
@ -432,10 +423,9 @@ FactoryBase<Impl>::NewOneByteInternalizedString(
}
template <typename Impl>
HandleFor<Impl, SeqTwoByteString>
FactoryBase<Impl>::NewTwoByteInternalizedString(const Vector<const uc16>& str,
uint32_t hash_field) {
HandleFor<Impl, SeqTwoByteString> result =
Handle<SeqTwoByteString> FactoryBase<Impl>::NewTwoByteInternalizedString(
const Vector<const uc16>& str, uint32_t hash_field) {
Handle<SeqTwoByteString> result =
AllocateRawTwoByteInternalizedString(str.length(), hash_field);
DisallowHeapAllocation no_gc;
MemCopy(result->GetChars(no_gc), str.begin(), str.length() * kUC16Size);
@ -443,7 +433,7 @@ FactoryBase<Impl>::NewTwoByteInternalizedString(const Vector<const uc16>& str,
}
template <typename Impl>
MaybeHandleFor<Impl, SeqOneByteString> FactoryBase<Impl>::NewRawOneByteString(
MaybeHandle<SeqOneByteString> FactoryBase<Impl>::NewRawOneByteString(
int length, AllocationType allocation) {
if (length > String::kMaxLength || length < 0) {
THROW_NEW_ERROR(isolate(), NewInvalidStringLengthError(), SeqOneByteString);
@ -454,7 +444,7 @@ MaybeHandleFor<Impl, SeqOneByteString> FactoryBase<Impl>::NewRawOneByteString(
HeapObject result = AllocateRawWithImmortalMap(
size, allocation, read_only_roots().one_byte_string_map());
HandleFor<Impl, SeqOneByteString> string =
Handle<SeqOneByteString> string =
handle(SeqOneByteString::cast(result), isolate());
string->set_length(length);
string->set_hash_field(String::kEmptyHashField);
@ -463,7 +453,7 @@ MaybeHandleFor<Impl, SeqOneByteString> FactoryBase<Impl>::NewRawOneByteString(
}
template <typename Impl>
MaybeHandleFor<Impl, SeqTwoByteString> FactoryBase<Impl>::NewRawTwoByteString(
MaybeHandle<SeqTwoByteString> FactoryBase<Impl>::NewRawTwoByteString(
int length, AllocationType allocation) {
if (length > String::kMaxLength || length < 0) {
THROW_NEW_ERROR(isolate(), NewInvalidStringLengthError(), SeqTwoByteString);
@ -474,7 +464,7 @@ MaybeHandleFor<Impl, SeqTwoByteString> FactoryBase<Impl>::NewRawTwoByteString(
HeapObject result = AllocateRawWithImmortalMap(
size, allocation, read_only_roots().string_map());
HandleFor<Impl, SeqTwoByteString> string =
Handle<SeqTwoByteString> string =
handle(SeqTwoByteString::cast(result), isolate());
string->set_length(length);
string->set_hash_field(String::kEmptyHashField);
@ -483,9 +473,8 @@ MaybeHandleFor<Impl, SeqTwoByteString> FactoryBase<Impl>::NewRawTwoByteString(
}
template <typename Impl>
MaybeHandleFor<Impl, String> FactoryBase<Impl>::NewConsString(
HandleFor<Impl, String> left, HandleFor<Impl, String> right,
AllocationType allocation) {
MaybeHandle<String> FactoryBase<Impl>::NewConsString(
Handle<String> left, Handle<String> right, AllocationType allocation) {
if (left->IsThinString()) {
left = handle(ThinString::cast(*left).actual(), isolate());
}
@ -524,7 +513,7 @@ MaybeHandleFor<Impl, String> FactoryBase<Impl>::NewConsString(
STATIC_ASSERT(ConsString::kMinLength <= String::kMaxLength);
if (is_one_byte) {
HandleFor<Impl, SeqOneByteString> result =
Handle<SeqOneByteString> result =
NewRawOneByteString(length, allocation).ToHandleChecked();
DisallowHeapAllocation no_gc;
uint8_t* dest = result->GetChars(no_gc);
@ -537,7 +526,7 @@ MaybeHandleFor<Impl, String> FactoryBase<Impl>::NewConsString(
return result;
}
HandleFor<Impl, SeqTwoByteString> result =
Handle<SeqTwoByteString> result =
NewRawTwoByteString(length, allocation).ToHandleChecked();
DisallowHeapAllocation pointer_stays_valid;
@ -551,15 +540,16 @@ MaybeHandleFor<Impl, String> FactoryBase<Impl>::NewConsString(
}
template <typename Impl>
HandleFor<Impl, String> FactoryBase<Impl>::NewConsString(
HandleFor<Impl, String> left, HandleFor<Impl, String> right, int length,
bool one_byte, AllocationType allocation) {
Handle<String> FactoryBase<Impl>::NewConsString(Handle<String> left,
Handle<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);
HandleFor<Impl, ConsString> result = handle(
Handle<ConsString> result = handle(
ConsString::cast(
one_byte
? NewWithImmortalMap(read_only_roots().cons_one_byte_string_map(),
@ -579,7 +569,7 @@ HandleFor<Impl, String> FactoryBase<Impl>::NewConsString(
}
template <typename Impl>
HandleFor<Impl, FreshlyAllocatedBigInt> FactoryBase<Impl>::NewBigInt(
Handle<FreshlyAllocatedBigInt> FactoryBase<Impl>::NewBigInt(
int length, AllocationType allocation) {
if (length < 0 || length > BigInt::kMaxLength) {
isolate()->FatalProcessOutOfHeapMemory("invalid BigInt length");
@ -592,26 +582,25 @@ HandleFor<Impl, FreshlyAllocatedBigInt> FactoryBase<Impl>::NewBigInt(
}
template <typename Impl>
HandleFor<Impl, ScopeInfo> FactoryBase<Impl>::NewScopeInfo(
int length, AllocationType type) {
Handle<ScopeInfo> FactoryBase<Impl>::NewScopeInfo(int length,
AllocationType type) {
DCHECK(type == AllocationType::kOld || type == AllocationType::kReadOnly);
return HandleFor<Impl, ScopeInfo>::cast(
return Handle<ScopeInfo>::cast(
NewFixedArrayWithMap(read_only_roots().scope_info_map(), length, type));
}
template <typename Impl>
HandleFor<Impl, SourceTextModuleInfo>
FactoryBase<Impl>::NewSourceTextModuleInfo() {
return HandleFor<Impl, SourceTextModuleInfo>::cast(NewFixedArrayWithMap(
Handle<SourceTextModuleInfo> FactoryBase<Impl>::NewSourceTextModuleInfo() {
return Handle<SourceTextModuleInfo>::cast(NewFixedArrayWithMap(
read_only_roots().module_info_map(), SourceTextModuleInfo::kLength,
AllocationType::kOld));
}
template <typename Impl>
HandleFor<Impl, SharedFunctionInfo> FactoryBase<Impl>::NewSharedFunctionInfo() {
Handle<SharedFunctionInfo> FactoryBase<Impl>::NewSharedFunctionInfo() {
Map map = read_only_roots().shared_function_info_map();
HandleFor<Impl, SharedFunctionInfo> shared = handle(
Handle<SharedFunctionInfo> shared = handle(
SharedFunctionInfo::cast(NewWithImmortalMap(map, AllocationType::kOld)),
isolate());
int unique_id = -1;
@ -628,7 +617,7 @@ HandleFor<Impl, SharedFunctionInfo> FactoryBase<Impl>::NewSharedFunctionInfo() {
}
template <typename Impl>
HandleFor<Impl, SeqOneByteString>
Handle<SeqOneByteString>
FactoryBase<Impl>::AllocateRawOneByteInternalizedString(int length,
uint32_t hash_field) {
CHECK_GE(String::kMaxLength, length);
@ -642,7 +631,7 @@ FactoryBase<Impl>::AllocateRawOneByteInternalizedString(int length,
impl()->CanAllocateInReadOnlySpace() ? AllocationType::kReadOnly
: AllocationType::kOld,
map);
HandleFor<Impl, SeqOneByteString> answer =
Handle<SeqOneByteString> answer =
handle(SeqOneByteString::cast(result), isolate());
answer->set_length(length);
answer->set_hash_field(hash_field);
@ -651,7 +640,7 @@ FactoryBase<Impl>::AllocateRawOneByteInternalizedString(int length,
}
template <typename Impl>
HandleFor<Impl, SeqTwoByteString>
Handle<SeqTwoByteString>
FactoryBase<Impl>::AllocateRawTwoByteInternalizedString(int length,
uint32_t hash_field) {
CHECK_GE(String::kMaxLength, length);
@ -661,7 +650,7 @@ FactoryBase<Impl>::AllocateRawTwoByteInternalizedString(int length,
int size = SeqTwoByteString::SizeFor(length);
HeapObject result =
AllocateRawWithImmortalMap(size, AllocationType::kOld, map);
HandleFor<Impl, SeqTwoByteString> answer =
Handle<SeqTwoByteString> answer =
handle(SeqTwoByteString::cast(result), isolate());
answer->set_length(length);
answer->set_hash_field(hash_field);

View File

@ -7,7 +7,6 @@
#include "src/base/export-template.h"
#include "src/common/globals.h"
#include "src/handles/handle-for.h"
#include "src/objects/function-kind.h"
#include "src/objects/instance-type.h"
#include "src/roots/roots.h"
@ -38,147 +37,137 @@ template <typename Impl>
class EXPORT_TEMPLATE_DECLARE(V8_EXPORT_PRIVATE) FactoryBase {
public:
// Converts the given boolean condition to JavaScript boolean value.
inline HandleFor<Impl, Oddball> ToBoolean(bool value);
inline Handle<Oddball> ToBoolean(bool value);
// Numbers (e.g. literals) are pretenured by the parser.
// The return value may be a smi or a heap number.
template <AllocationType allocation = AllocationType::kYoung>
inline HandleFor<Impl, Object> NewNumber(double value);
inline Handle<Object> NewNumber(double value);
template <AllocationType allocation = AllocationType::kYoung>
inline HandleFor<Impl, Object> NewNumberFromInt(int32_t value);
inline Handle<Object> NewNumberFromInt(int32_t value);
template <AllocationType allocation = AllocationType::kYoung>
inline HandleFor<Impl, Object> NewNumberFromUint(uint32_t value);
inline Handle<Object> NewNumberFromUint(uint32_t value);
template <AllocationType allocation = AllocationType::kYoung>
inline HandleFor<Impl, Object> NewNumberFromSize(size_t value);
inline Handle<Object> NewNumberFromSize(size_t value);
template <AllocationType allocation = AllocationType::kYoung>
inline HandleFor<Impl, Object> NewNumberFromInt64(int64_t value);
inline Handle<Object> NewNumberFromInt64(int64_t value);
template <AllocationType allocation = AllocationType::kYoung>
inline HandleFor<Impl, HeapNumber> NewHeapNumber(double value);
inline Handle<HeapNumber> NewHeapNumber(double value);
template <AllocationType allocation = AllocationType::kYoung>
inline HandleFor<Impl, HeapNumber> NewHeapNumberFromBits(uint64_t bits);
inline Handle<HeapNumber> NewHeapNumberFromBits(uint64_t bits);
template <AllocationType allocation = AllocationType::kYoung>
inline HandleFor<Impl, HeapNumber> NewHeapNumberWithHoleNaN();
inline Handle<HeapNumber> NewHeapNumberWithHoleNaN();
template <AllocationType allocation>
HandleFor<Impl, HeapNumber> NewHeapNumber();
Handle<HeapNumber> NewHeapNumber();
HandleFor<Impl, Struct> NewStruct(
InstanceType type, AllocationType allocation = AllocationType::kYoung);
Handle<Struct> NewStruct(InstanceType type,
AllocationType allocation = AllocationType::kYoung);
// Allocates a fixed array initialized with undefined values.
HandleFor<Impl, FixedArray> NewFixedArray(
Handle<FixedArray> NewFixedArray(
int length, AllocationType allocation = AllocationType::kYoung);
// Allocates a fixed array-like object with given map and initialized with
// undefined values.
HandleFor<Impl, FixedArray> NewFixedArrayWithMap(
Handle<FixedArray> NewFixedArrayWithMap(
Map map, int length, AllocationType allocation = AllocationType::kYoung);
// Allocate a new fixed array with non-existing entries (the hole).
HandleFor<Impl, FixedArray> NewFixedArrayWithHoles(
Handle<FixedArray> NewFixedArrayWithHoles(
int length, AllocationType allocation = AllocationType::kYoung);
// Allocate a new uninitialized fixed double array.
// The function returns a pre-allocated empty fixed array for length = 0,
// so the return type must be the general fixed array class.
HandleFor<Impl, FixedArrayBase> NewFixedDoubleArray(
Handle<FixedArrayBase> NewFixedDoubleArray(
int length, AllocationType allocation = AllocationType::kYoung);
// Allocates a weak fixed array-like object with given map and initialized
// with undefined values.
HandleFor<Impl, WeakFixedArray> NewWeakFixedArrayWithMap(
Handle<WeakFixedArray> NewWeakFixedArrayWithMap(
Map map, int length, AllocationType allocation = AllocationType::kYoung);
// Allocates a fixed array which may contain in-place weak references. The
// array is initialized with undefined values
HandleFor<Impl, WeakFixedArray> NewWeakFixedArray(
Handle<WeakFixedArray> NewWeakFixedArray(
int length, AllocationType allocation = AllocationType::kYoung);
HandleFor<Impl, ByteArray> NewByteArray(
Handle<ByteArray> NewByteArray(
int length, AllocationType allocation = AllocationType::kYoung);
HandleFor<Impl, BytecodeArray> NewBytecodeArray(
int length, const byte* raw_bytecodes, int frame_size,
int parameter_count, HandleFor<Impl, FixedArray> constant_pool);
Handle<BytecodeArray> NewBytecodeArray(int length, const byte* raw_bytecodes,
int frame_size, int parameter_count,
Handle<FixedArray> constant_pool);
// Allocates a fixed array for name-value pairs of boilerplate properties and
// calculates the number of properties we need to store in the backing store.
HandleFor<Impl, ObjectBoilerplateDescription> NewObjectBoilerplateDescription(
Handle<ObjectBoilerplateDescription> NewObjectBoilerplateDescription(
int boilerplate, int all_properties, int index_keys, bool has_seen_proto);
// Create a new ArrayBoilerplateDescription struct.
HandleFor<Impl, ArrayBoilerplateDescription> NewArrayBoilerplateDescription(
ElementsKind elements_kind,
HandleFor<Impl, FixedArrayBase> constant_values);
Handle<ArrayBoilerplateDescription> NewArrayBoilerplateDescription(
ElementsKind elements_kind, Handle<FixedArrayBase> constant_values);
// Create a new TemplateObjectDescription struct.
HandleFor<Impl, TemplateObjectDescription> NewTemplateObjectDescription(
HandleFor<Impl, FixedArray> raw_strings,
HandleFor<Impl, FixedArray> cooked_strings);
Handle<TemplateObjectDescription> NewTemplateObjectDescription(
Handle<FixedArray> raw_strings, Handle<FixedArray> cooked_strings);
HandleFor<Impl, Script> NewScript(HandleFor<Impl, String> source);
HandleFor<Impl, Script> NewScriptWithId(HandleFor<Impl, String> source,
int script_id);
Handle<Script> NewScript(Handle<String> source);
Handle<Script> NewScriptWithId(Handle<String> source, int script_id);
HandleFor<Impl, SharedFunctionInfo> NewSharedFunctionInfoForLiteral(
FunctionLiteral* literal, HandleFor<Impl, Script> script,
bool is_toplevel);
Handle<SharedFunctionInfo> NewSharedFunctionInfoForLiteral(
FunctionLiteral* literal, Handle<Script> script, bool is_toplevel);
HandleFor<Impl, PreparseData> NewPreparseData(int data_length,
int children_length);
Handle<PreparseData> NewPreparseData(int data_length, int children_length);
HandleFor<Impl, UncompiledDataWithoutPreparseData>
NewUncompiledDataWithoutPreparseData(HandleFor<Impl, String> inferred_name,
Handle<UncompiledDataWithoutPreparseData>
NewUncompiledDataWithoutPreparseData(Handle<String> inferred_name,
int32_t start_position,
int32_t end_position);
HandleFor<Impl, UncompiledDataWithPreparseData>
NewUncompiledDataWithPreparseData(HandleFor<Impl, String> inferred_name,
int32_t start_position,
int32_t end_position,
HandleFor<Impl, PreparseData>);
Handle<UncompiledDataWithPreparseData> NewUncompiledDataWithPreparseData(
Handle<String> inferred_name, int32_t start_position,
int32_t end_position, Handle<PreparseData>);
HandleFor<Impl, CoverageInfo> NewCoverageInfo(
const ZoneVector<SourceRange>& slots);
Handle<CoverageInfo> NewCoverageInfo(const ZoneVector<SourceRange>& slots);
HandleFor<Impl, SeqOneByteString> NewOneByteInternalizedString(
Handle<SeqOneByteString> NewOneByteInternalizedString(
const Vector<const uint8_t>& str, uint32_t hash_field);
HandleFor<Impl, SeqTwoByteString> NewTwoByteInternalizedString(
Handle<SeqTwoByteString> NewTwoByteInternalizedString(
const Vector<const uc16>& str, uint32_t hash_field);
HandleFor<Impl, SeqOneByteString> AllocateRawOneByteInternalizedString(
Handle<SeqOneByteString> AllocateRawOneByteInternalizedString(
int length, uint32_t hash_field);
HandleFor<Impl, SeqTwoByteString> AllocateRawTwoByteInternalizedString(
Handle<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 MaybeHandleFor<Impl, SeqOneByteString>
NewRawOneByteString(int length,
AllocationType allocation = AllocationType::kYoung);
V8_WARN_UNUSED_RESULT MaybeHandleFor<Impl, SeqTwoByteString>
NewRawTwoByteString(int length,
AllocationType allocation = AllocationType::kYoung);
V8_WARN_UNUSED_RESULT MaybeHandle<SeqOneByteString> NewRawOneByteString(
int length, AllocationType allocation = AllocationType::kYoung);
V8_WARN_UNUSED_RESULT MaybeHandle<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 MaybeHandleFor<Impl, String> NewConsString(
HandleFor<Impl, String> left, HandleFor<Impl, String> right,
V8_WARN_UNUSED_RESULT MaybeHandle<String> NewConsString(
Handle<String> left, Handle<String> right,
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);
V8_WARN_UNUSED_RESULT Handle<String> NewConsString(
Handle<String> left, Handle<String> right, int length, bool one_byte,
AllocationType allocation = AllocationType::kYoung);
// Allocates a new BigInt with {length} digits. Only to be used by
// MutableBigInt::New*.
HandleFor<Impl, FreshlyAllocatedBigInt> NewBigInt(
Handle<FreshlyAllocatedBigInt> NewBigInt(
int length, AllocationType allocation = AllocationType::kYoung);
// Create a serialized scope info.
HandleFor<Impl, ScopeInfo> NewScopeInfo(
int length, AllocationType type = AllocationType::kOld);
Handle<ScopeInfo> NewScopeInfo(int length,
AllocationType type = AllocationType::kOld);
HandleFor<Impl, SourceTextModuleInfo> NewSourceTextModuleInfo();
Handle<SourceTextModuleInfo> NewSourceTextModuleInfo();
protected:
// Allocate memory for an uninitialized array (e.g., a FixedArray or similar).
@ -191,14 +180,15 @@ class EXPORT_TEMPLATE_DECLARE(V8_EXPORT_PRIVATE) FactoryBase {
AllocationAlignment alignment = kWordAligned);
HeapObject NewWithImmortalMap(Map map, AllocationType allocation);
HandleFor<Impl, FixedArray> NewFixedArrayWithFiller(
Map map, int length, Oddball filler, AllocationType allocation);
Handle<FixedArray> NewFixedArrayWithFiller(Map map, int length,
Oddball filler,
AllocationType allocation);
HandleFor<Impl, SharedFunctionInfo> NewSharedFunctionInfo();
HandleFor<Impl, SharedFunctionInfo> NewSharedFunctionInfo(
MaybeHandleFor<Impl, String> maybe_name,
MaybeHandleFor<Impl, HeapObject> maybe_function_data,
int maybe_builtin_index, FunctionKind kind = kNormalFunction);
Handle<SharedFunctionInfo> NewSharedFunctionInfo();
Handle<SharedFunctionInfo> NewSharedFunctionInfo(
MaybeHandle<String> maybe_name,
MaybeHandle<HeapObject> maybe_function_data, int maybe_builtin_index,
FunctionKind kind = kNormalFunction);
private:
Impl* impl() { return static_cast<Impl*>(this); }

View File

@ -98,17 +98,6 @@ enum FunctionMode {
kWithReadonlyPrototypeBit | kWithNameBit,
};
class Factory;
template <>
struct HandleTraits<Factory> {
template <typename T>
using HandleType = Handle<T>;
template <typename T>
using MaybeHandleType = MaybeHandle<T>;
using HandleScopeType = HandleScope;
};
// Interface for handle based allocation.
class V8_EXPORT_PRIVATE Factory : public FactoryBase<Factory> {
public:

View File

@ -14,8 +14,8 @@ namespace v8 {
namespace internal {
#define ROOT_ACCESSOR(Type, name, CamelName) \
OffThreadHandle<Type> OffThreadFactory::name() { \
return OffThreadHandle<Type>(read_only_roots().name()); \
Handle<Type> OffThreadFactory::name() { \
return Handle<Type>(read_only_roots().name##_handle()); \
}
READ_ONLY_ROOT_LIST(ROOT_ACCESSOR)
#undef ROOT_ACCESSOR

View File

@ -175,41 +175,40 @@ void OffThreadFactory::Publish(Isolate* isolate) {
scripts = WeakArrayList::Append(isolate, scripts,
MaybeObjectHandle::Weak(script_handle));
}
isolate->heap()->SetRootScriptList(*scripts);
}
// Hacky method for creating a simple object with a slot pointing to a string.
// TODO(leszeks): Remove once we have full FixedArray support.
OffThreadHandle<FixedArray> OffThreadFactory::StringWrapperForTest(
OffThreadHandle<String> string) {
Handle<FixedArray> OffThreadFactory::StringWrapperForTest(
Handle<String> string) {
HeapObject wrapper =
AllocateRaw(FixedArray::SizeFor(1), AllocationType::kOld);
wrapper.set_map_after_allocation(read_only_roots().fixed_array_map());
FixedArray array = FixedArray::cast(wrapper);
array.set_length(1);
array.data_start().Relaxed_Store(*string);
return OffThreadHandle<FixedArray>(array);
return handle(array, isolate());
}
OffThreadHandle<String> OffThreadFactory::MakeOrFindTwoCharacterString(
uint16_t c1, uint16_t c2) {
Handle<String> OffThreadFactory::MakeOrFindTwoCharacterString(uint16_t c1,
uint16_t c2) {
// TODO(leszeks): Do some real caching here. Also, these strings should be
// internalized.
if ((c1 | c2) <= unibrow::Latin1::kMaxChar) {
OffThreadHandle<SeqOneByteString> ret =
NewRawOneByteString(2, AllocationType::kOld);
Handle<SeqOneByteString> ret =
NewRawOneByteString(2, AllocationType::kOld).ToHandleChecked();
ret->SeqOneByteStringSet(0, c1);
ret->SeqOneByteStringSet(1, c2);
return ret;
}
OffThreadHandle<SeqTwoByteString> ret =
NewRawTwoByteString(2, AllocationType::kOld);
Handle<SeqTwoByteString> ret =
NewRawTwoByteString(2, AllocationType::kOld).ToHandleChecked();
ret->SeqTwoByteStringSet(0, c1);
ret->SeqTwoByteStringSet(1, c2);
return ret;
}
void OffThreadFactory::AddToScriptList(OffThreadHandle<Script> shared) {
void OffThreadFactory::AddToScriptList(Handle<Script> shared) {
script_list_.push_back(*shared);
}

View File

@ -28,17 +28,6 @@ class AstRawString;
class AstConsString;
class OffThreadIsolate;
class OffThreadFactory;
template <>
struct HandleTraits<OffThreadFactory> {
template <typename T>
using HandleType = OffThreadHandle<T>;
template <typename T>
using MaybeHandleType = OffThreadHandle<T>;
using HandleScopeType = OffThreadHandleScope;
};
struct RelativeSlot {
RelativeSlot() = default;
RelativeSlot(Address object_address, int slot_offset)
@ -55,8 +44,7 @@ class V8_EXPORT_PRIVATE OffThreadFactory
ReadOnlyRoots read_only_roots() const { return roots_; }
#define ROOT_ACCESSOR(Type, name, CamelName) \
inline OffThreadHandle<Type> name();
#define ROOT_ACCESSOR(Type, name, CamelName) inline Handle<Type> name();
READ_ONLY_ROOT_LIST(ROOT_ACCESSOR)
#undef ROOT_ACCESSOR
@ -65,13 +53,12 @@ class V8_EXPORT_PRIVATE OffThreadFactory
// The parser shouldn't allow the OffThreadFactory to get into a state where
// it generates errors.
OffThreadHandle<Object> NewInvalidStringLengthError() { UNREACHABLE(); }
OffThreadHandle<Object> NewRangeError(MessageTemplate template_index) {
Handle<Object> NewInvalidStringLengthError() { UNREACHABLE(); }
Handle<Object> NewRangeError(MessageTemplate template_index) {
UNREACHABLE();
}
OffThreadHandle<FixedArray> StringWrapperForTest(
OffThreadHandle<String> string);
Handle<FixedArray> StringWrapperForTest(Handle<String> string);
private:
friend class FactoryBase<OffThreadFactory>;
@ -92,10 +79,9 @@ class V8_EXPORT_PRIVATE OffThreadFactory
inline bool EmptyStringRootIsInitialized() { return true; }
// ------
OffThreadHandle<String> MakeOrFindTwoCharacterString(uint16_t c1,
uint16_t c2);
Handle<String> MakeOrFindTwoCharacterString(uint16_t c1, uint16_t c2);
void AddToScriptList(OffThreadHandle<Script> shared);
void AddToScriptList(Handle<Script> shared);
// ------
ReadOnlyRoots roots_;

View File

@ -82,9 +82,9 @@ Register BytecodeArrayBuilder::Local(int index) const {
return Register(index);
}
template <typename Isolate>
HandleFor<Isolate, BytecodeArray> BytecodeArrayBuilder::ToBytecodeArray(
Isolate* isolate) {
template <typename LocalIsolate>
Handle<BytecodeArray> BytecodeArrayBuilder::ToBytecodeArray(
LocalIsolate* isolate) {
DCHECK(RemainderOfBlockIsDead());
DCHECK(!bytecode_generated_);
bytecode_generated_ = true;
@ -96,7 +96,7 @@ HandleFor<Isolate, BytecodeArray> BytecodeArrayBuilder::ToBytecodeArray(
register_count = register_optimizer_->maxiumum_register_index() + 1;
}
HandleFor<Isolate, ByteArray> handler_table =
Handle<ByteArray> handler_table =
handler_table_builder()->ToHandlerTable(isolate);
return bytecode_array_writer_.ToBytecodeArray(
isolate, register_count, parameter_count(), handler_table);
@ -106,7 +106,7 @@ template EXPORT_TEMPLATE_DEFINE(V8_EXPORT_PRIVATE)
Handle<BytecodeArray> BytecodeArrayBuilder::ToBytecodeArray(
Isolate* isolate);
template EXPORT_TEMPLATE_DEFINE(V8_EXPORT_PRIVATE)
OffThreadHandle<BytecodeArray> BytecodeArrayBuilder::ToBytecodeArray(
Handle<BytecodeArray> BytecodeArrayBuilder::ToBytecodeArray(
OffThreadIsolate* isolate);
#ifdef DEBUG
@ -116,9 +116,9 @@ int BytecodeArrayBuilder::CheckBytecodeMatches(BytecodeArray bytecode) {
}
#endif
template <typename Isolate>
HandleFor<Isolate, ByteArray> BytecodeArrayBuilder::ToSourcePositionTable(
Isolate* isolate) {
template <typename LocalIsolate>
Handle<ByteArray> BytecodeArrayBuilder::ToSourcePositionTable(
LocalIsolate* isolate) {
DCHECK(RemainderOfBlockIsDead());
return bytecode_array_writer_.ToSourcePositionTable(isolate);
@ -128,7 +128,7 @@ template EXPORT_TEMPLATE_DEFINE(V8_EXPORT_PRIVATE)
Handle<ByteArray> BytecodeArrayBuilder::ToSourcePositionTable(
Isolate* isolate);
template EXPORT_TEMPLATE_DEFINE(V8_EXPORT_PRIVATE)
OffThreadHandle<ByteArray> BytecodeArrayBuilder::ToSourcePositionTable(
Handle<ByteArray> BytecodeArrayBuilder::ToSourcePositionTable(
OffThreadIsolate* isolate);
BytecodeSourceInfo BytecodeArrayBuilder::CurrentSourcePosition(
@ -1568,8 +1568,8 @@ size_t BytecodeArrayBuilder::AllocateDeferredConstantPoolEntry() {
return constant_array_builder()->InsertDeferred();
}
void BytecodeArrayBuilder::SetDeferredConstantPoolEntry(
size_t entry, HandleOrOffThreadHandle<Object> object) {
void BytecodeArrayBuilder::SetDeferredConstantPoolEntry(size_t entry,
Handle<Object> object) {
constant_array_builder()->SetDeferredAt(entry, object);
}

View File

@ -43,12 +43,12 @@ class V8_EXPORT_PRIVATE BytecodeArrayBuilder final {
SourcePositionTableBuilder::RecordingMode source_position_mode =
SourcePositionTableBuilder::RECORD_SOURCE_POSITIONS);
template <typename Isolate>
template <typename LocalIsolate>
EXPORT_TEMPLATE_DECLARE(V8_EXPORT_PRIVATE)
HandleFor<Isolate, BytecodeArray> ToBytecodeArray(Isolate* isolate);
template <typename Isolate>
Handle<BytecodeArray> ToBytecodeArray(LocalIsolate* isolate);
template <typename LocalIsolate>
EXPORT_TEMPLATE_DECLARE(V8_EXPORT_PRIVATE)
HandleFor<Isolate, ByteArray> ToSourcePositionTable(Isolate* isolate);
Handle<ByteArray> ToSourcePositionTable(LocalIsolate* isolate);
#ifdef DEBUG
int CheckBytecodeMatches(BytecodeArray bytecode);
@ -503,8 +503,7 @@ class V8_EXPORT_PRIVATE BytecodeArrayBuilder final {
// Allocates a slot in the constant pool which can later be set.
size_t AllocateDeferredConstantPoolEntry();
// Sets the deferred value into an allocated constant pool entry.
void SetDeferredConstantPoolEntry(size_t entry,
HandleOrOffThreadHandle<Object> object);
void SetDeferredConstantPoolEntry(size_t entry, Handle<Object> object);
void InitializeReturnPosition(FunctionLiteral* literal);

View File

@ -37,20 +37,19 @@ BytecodeArrayWriter::BytecodeArrayWriter(
bytecodes_.reserve(512); // Derived via experimentation.
}
template <typename Isolate>
HandleFor<Isolate, BytecodeArray> BytecodeArrayWriter::ToBytecodeArray(
Isolate* isolate, int register_count, int parameter_count,
HandleFor<Isolate, ByteArray> handler_table) {
template <typename LocalIsolate>
Handle<BytecodeArray> BytecodeArrayWriter::ToBytecodeArray(
LocalIsolate* isolate, int register_count, int parameter_count,
Handle<ByteArray> handler_table) {
DCHECK_EQ(0, unbound_jumps_);
int bytecode_size = static_cast<int>(bytecodes()->size());
int frame_size = register_count * kSystemPointerSize;
HandleFor<Isolate, FixedArray> constant_pool =
Handle<FixedArray> constant_pool =
constant_array_builder()->ToFixedArray(isolate);
HandleFor<Isolate, BytecodeArray> bytecode_array =
isolate->factory()->NewBytecodeArray(bytecode_size, &bytecodes()->front(),
frame_size, parameter_count,
constant_pool);
Handle<BytecodeArray> bytecode_array = isolate->factory()->NewBytecodeArray(
bytecode_size, &bytecodes()->front(), frame_size, parameter_count,
constant_pool);
bytecode_array->set_handler_table(*handler_table);
return bytecode_array;
}
@ -60,15 +59,15 @@ template EXPORT_TEMPLATE_DEFINE(V8_EXPORT_PRIVATE)
Isolate* isolate, int register_count, int parameter_count,
Handle<ByteArray> handler_table);
template EXPORT_TEMPLATE_DEFINE(V8_EXPORT_PRIVATE)
OffThreadHandle<BytecodeArray> BytecodeArrayWriter::ToBytecodeArray(
Handle<BytecodeArray> BytecodeArrayWriter::ToBytecodeArray(
OffThreadIsolate* isolate, int register_count, int parameter_count,
OffThreadHandle<ByteArray> handler_table);
Handle<ByteArray> handler_table);
template <typename Isolate>
HandleFor<Isolate, ByteArray> BytecodeArrayWriter::ToSourcePositionTable(
Isolate* isolate) {
template <typename LocalIsolate>
Handle<ByteArray> BytecodeArrayWriter::ToSourcePositionTable(
LocalIsolate* isolate) {
DCHECK(!source_position_table_builder_.Lazy());
HandleFor<Isolate, ByteArray> source_position_table =
Handle<ByteArray> source_position_table =
source_position_table_builder_.Omit()
? isolate->factory()->empty_byte_array()
: source_position_table_builder_.ToSourcePositionTable(isolate);
@ -79,7 +78,7 @@ template EXPORT_TEMPLATE_DEFINE(V8_EXPORT_PRIVATE)
Handle<ByteArray> BytecodeArrayWriter::ToSourcePositionTable(
Isolate* isolate);
template EXPORT_TEMPLATE_DEFINE(V8_EXPORT_PRIVATE)
OffThreadHandle<ByteArray> BytecodeArrayWriter::ToSourcePositionTable(
Handle<ByteArray> BytecodeArrayWriter::ToSourcePositionTable(
OffThreadIsolate* isolate);
#ifdef DEBUG

View File

@ -53,15 +53,15 @@ class V8_EXPORT_PRIVATE BytecodeArrayWriter final {
void SetFunctionEntrySourcePosition(int position);
template <typename Isolate>
template <typename LocalIsolate>
EXPORT_TEMPLATE_DECLARE(V8_EXPORT_PRIVATE)
HandleFor<Isolate, BytecodeArray> ToBytecodeArray(
Isolate* isolate, int register_count, int parameter_count,
HandleFor<Isolate, ByteArray> handler_table);
Handle<BytecodeArray> ToBytecodeArray(LocalIsolate* isolate,
int register_count, int parameter_count,
Handle<ByteArray> handler_table);
template <typename Isolate>
template <typename LocalIsolate>
EXPORT_TEMPLATE_DECLARE(V8_EXPORT_PRIVATE)
HandleFor<Isolate, ByteArray> ToSourcePositionTable(Isolate* isolate);
Handle<ByteArray> ToSourcePositionTable(LocalIsolate* isolate);
#ifdef DEBUG
// Returns -1 if they match or the offset of the first mismatching byte.

View File

@ -729,13 +729,14 @@ class BytecodeGenerator::TestResultScope final : public ExpressionResultScope {
// Used to build a list of toplevel declaration data.
class BytecodeGenerator::TopLevelDeclarationsBuilder final : public ZoneObject {
public:
template <typename Isolate>
HandleFor<Isolate, FixedArray> AllocateDeclarations(
UnoptimizedCompilationInfo* info, BytecodeGenerator* generator,
HandleFor<Isolate, Script> script, Isolate* isolate) {
template <typename LocalIsolate>
Handle<FixedArray> AllocateDeclarations(UnoptimizedCompilationInfo* info,
BytecodeGenerator* generator,
Handle<Script> script,
LocalIsolate* isolate) {
DCHECK(has_constant_pool_entry_);
HandleFor<Isolate, FixedArray> data =
Handle<FixedArray> data =
isolate->factory()->NewFixedArray(entry_slots_, AllocationType::kOld);
int array_index = 0;
@ -749,11 +750,11 @@ class BytecodeGenerator::TopLevelDeclarationsBuilder final : public ZoneObject {
#endif
if (decl->IsFunctionDeclaration()) {
FunctionLiteral* f = static_cast<FunctionDeclaration*>(decl)->fun();
HandleFor<Isolate, SharedFunctionInfo> sfi(
Handle<SharedFunctionInfo> sfi(
Compiler::GetSharedFunctionInfo(f, script, isolate));
// Return a null handle if any initial values can't be created. Caller
// will set stack overflow.
if (sfi.is_null()) return HandleFor<Isolate, FixedArray>();
if (sfi.is_null()) return Handle<FixedArray>();
data->set(array_index++, *sfi);
int literal_index = generator->GetCachedCreateClosureSlot(f);
data->set(array_index++, Smi::FromInt(literal_index));
@ -774,15 +775,15 @@ class BytecodeGenerator::TopLevelDeclarationsBuilder final : public ZoneObject {
int start = array_index;
#endif
if (decl->IsVariableDeclaration()) {
data->set(array_index++, *var->raw_name()->string().get<Isolate>());
data->set(array_index++, *var->raw_name()->string());
DCHECK_EQ(start + kGlobalVariableDeclarationSize, array_index);
} else {
FunctionLiteral* f = static_cast<FunctionDeclaration*>(decl)->fun();
HandleFor<Isolate, SharedFunctionInfo> sfi(
Handle<SharedFunctionInfo> sfi(
Compiler::GetSharedFunctionInfo(f, script, isolate));
// Return a null handle if any initial values can't be created. Caller
// will set stack overflow.
if (sfi.is_null()) return HandleFor<Isolate, FixedArray>();
if (sfi.is_null()) return Handle<FixedArray>();
data->set(array_index++, *sfi);
int literal_index = generator->GetCachedCreateClosureSlot(f);
data->set(array_index++, Smi::FromInt(literal_index));
@ -1074,20 +1075,20 @@ using NullContextScopeFor = typename NullContextScopeHelper<Isolate>::Type;
} // namespace
template <typename Isolate>
HandleFor<Isolate, BytecodeArray> BytecodeGenerator::FinalizeBytecode(
Isolate* isolate, HandleFor<Isolate, Script> script) {
template <typename LocalIsolate>
Handle<BytecodeArray> BytecodeGenerator::FinalizeBytecode(
LocalIsolate* isolate, Handle<Script> script) {
DCHECK_EQ(ThreadId::Current(), isolate->thread_id());
#ifdef DEBUG
// Unoptimized compilation should be context-independent. Verify that we don't
// access the native context by nulling it out during finalization.
NullContextScopeFor<Isolate> null_context_scope(isolate);
NullContextScopeFor<LocalIsolate> null_context_scope(isolate);
#endif
AllocateDeferredConstants(isolate, script);
if (block_coverage_builder_) {
HandleFor<Isolate, CoverageInfo> coverage_info =
Handle<CoverageInfo> coverage_info =
isolate->factory()->NewCoverageInfo(block_coverage_builder_->slots());
info()->set_coverage_info(coverage_info);
if (FLAG_trace_block_coverage) {
@ -1096,9 +1097,8 @@ HandleFor<Isolate, BytecodeArray> BytecodeGenerator::FinalizeBytecode(
}
}
if (HasStackOverflow()) return HandleFor<Isolate, BytecodeArray>();
HandleFor<Isolate, BytecodeArray> bytecode_array =
builder()->ToBytecodeArray(isolate);
if (HasStackOverflow()) return Handle<BytecodeArray>();
Handle<BytecodeArray> bytecode_array = builder()->ToBytecodeArray(isolate);
if (incoming_new_target_or_generator_.is_valid()) {
bytecode_array->set_incoming_new_target_or_generator_register(
@ -1110,34 +1110,34 @@ HandleFor<Isolate, BytecodeArray> BytecodeGenerator::FinalizeBytecode(
template Handle<BytecodeArray> BytecodeGenerator::FinalizeBytecode(
Isolate* isolate, Handle<Script> script);
template OffThreadHandle<BytecodeArray> BytecodeGenerator::FinalizeBytecode(
OffThreadIsolate* isolate, OffThreadHandle<Script> script);
template Handle<BytecodeArray> BytecodeGenerator::FinalizeBytecode(
OffThreadIsolate* isolate, Handle<Script> script);
template <typename Isolate>
HandleFor<Isolate, ByteArray> BytecodeGenerator::FinalizeSourcePositionTable(
Isolate* isolate) {
template <typename LocalIsolate>
Handle<ByteArray> BytecodeGenerator::FinalizeSourcePositionTable(
LocalIsolate* isolate) {
DCHECK_EQ(ThreadId::Current(), isolate->thread_id());
#ifdef DEBUG
// Unoptimized compilation should be context-independent. Verify that we don't
// access the native context by nulling it out during finalization.
NullContextScopeFor<Isolate> null_context_scope(isolate);
NullContextScopeFor<LocalIsolate> null_context_scope(isolate);
#endif
HandleFor<Isolate, ByteArray> source_position_table =
Handle<ByteArray> source_position_table =
builder()->ToSourcePositionTable(isolate);
LOG_CODE_EVENT(
isolate, CodeLinePosInfoRecordEvent(
info_->bytecode_array<Isolate>()->GetFirstBytecodeAddress(),
*source_position_table));
LOG_CODE_EVENT(isolate,
CodeLinePosInfoRecordEvent(
info_->bytecode_array()->GetFirstBytecodeAddress(),
*source_position_table));
return source_position_table;
}
template Handle<ByteArray> BytecodeGenerator::FinalizeSourcePositionTable(
Isolate* isolate);
template OffThreadHandle<ByteArray>
BytecodeGenerator::FinalizeSourcePositionTable(OffThreadIsolate* isolate);
template Handle<ByteArray> BytecodeGenerator::FinalizeSourcePositionTable(
OffThreadIsolate* isolate);
#ifdef DEBUG
int BytecodeGenerator::CheckBytecodeMatches(BytecodeArray bytecode) {
@ -1145,14 +1145,13 @@ int BytecodeGenerator::CheckBytecodeMatches(BytecodeArray bytecode) {
}
#endif
template <typename Isolate>
void BytecodeGenerator::AllocateDeferredConstants(
Isolate* isolate, HandleFor<Isolate, Script> script) {
template <typename LocalIsolate>
void BytecodeGenerator::AllocateDeferredConstants(LocalIsolate* isolate,
Handle<Script> script) {
if (top_level_builder()->has_top_level_declaration()) {
// Build global declaration pair array.
HandleFor<Isolate, FixedArray> declarations =
top_level_builder()->AllocateDeclarations(info(), this, script,
isolate);
Handle<FixedArray> declarations = top_level_builder()->AllocateDeclarations(
info(), this, script, isolate);
if (declarations.is_null()) return SetStackOverflow();
builder()->SetDeferredConstantPoolEntry(
top_level_builder()->constant_pool_entry(), declarations);
@ -1161,7 +1160,7 @@ void BytecodeGenerator::AllocateDeferredConstants(
// Find or build shared function infos.
for (std::pair<FunctionLiteral*, size_t> literal : function_literals_) {
FunctionLiteral* expr = literal.first;
HandleFor<Isolate, SharedFunctionInfo> shared_info =
Handle<SharedFunctionInfo> shared_info =
Compiler::GetSharedFunctionInfo(expr, script, isolate);
if (shared_info.is_null()) return SetStackOverflow();
builder()->SetDeferredConstantPoolEntry(literal.second, shared_info);
@ -1182,7 +1181,7 @@ void BytecodeGenerator::AllocateDeferredConstants(
v8_isolate, Utils::ToLocal(expr->name()));
DCHECK(!info.IsEmpty());
HandleFor<Isolate, SharedFunctionInfo> shared_info =
Handle<SharedFunctionInfo> shared_info =
FunctionTemplateInfo::GetOrCreateSharedFunctionInfo(
isolate, Utils::OpenHandle(*info), expr->name());
DCHECK(!shared_info.is_null());
@ -1195,7 +1194,7 @@ void BytecodeGenerator::AllocateDeferredConstants(
if (object_literal->properties_count() > 0) {
// If constant properties is an empty fixed array, we've already added it
// to the constant pool when visiting the object literal.
HandleFor<Isolate, ObjectBoilerplateDescription> constant_properties =
Handle<ObjectBoilerplateDescription> constant_properties =
object_literal->GetOrBuildBoilerplateDescription(isolate);
builder()->SetDeferredConstantPoolEntry(literal.second,
@ -1206,7 +1205,7 @@ void BytecodeGenerator::AllocateDeferredConstants(
// Build array literal constant elements
for (std::pair<ArrayLiteral*, size_t> literal : array_literals_) {
ArrayLiteral* array_literal = literal.first;
HandleFor<Isolate, ArrayBoilerplateDescription> constant_elements =
Handle<ArrayBoilerplateDescription> constant_elements =
array_literal->GetOrBuildBoilerplateDescription(isolate);
builder()->SetDeferredConstantPoolEntry(literal.second, constant_elements);
}
@ -1214,7 +1213,7 @@ void BytecodeGenerator::AllocateDeferredConstants(
// Build class literal boilerplates.
for (std::pair<ClassLiteral*, size_t> literal : class_literals_) {
ClassLiteral* class_literal = literal.first;
HandleFor<Isolate, ClassBoilerplate> class_boilerplate =
Handle<ClassBoilerplate> class_boilerplate =
ClassBoilerplate::BuildClassBoilerplate(isolate, class_literal);
builder()->SetDeferredConstantPoolEntry(literal.second, class_boilerplate);
}
@ -1222,7 +1221,7 @@ void BytecodeGenerator::AllocateDeferredConstants(
// Build template literals.
for (std::pair<GetTemplateObject*, size_t> literal : template_objects_) {
GetTemplateObject* get_template_object = literal.first;
HandleFor<Isolate, TemplateObjectDescription> description =
Handle<TemplateObjectDescription> description =
get_template_object->GetOrBuildDescription(isolate);
builder()->SetDeferredConstantPoolEntry(literal.second, description);
}
@ -1231,7 +1230,7 @@ void BytecodeGenerator::AllocateDeferredConstants(
template void BytecodeGenerator::AllocateDeferredConstants(
Isolate* isolate, Handle<Script> script);
template void BytecodeGenerator::AllocateDeferredConstants(
OffThreadIsolate* isolate, OffThreadHandle<Script> script);
OffThreadIsolate* isolate, Handle<Script> script);
namespace {
bool NeedsContextInitialization(DeclarationScope* scope) {

View File

@ -37,11 +37,11 @@ class BytecodeGenerator final : public AstVisitor<BytecodeGenerator> {
std::vector<FunctionLiteral*>* eager_inner_literals);
void GenerateBytecode(uintptr_t stack_limit);
template <typename Isolate>
HandleFor<Isolate, BytecodeArray> FinalizeBytecode(
Isolate* isolate, HandleFor<Isolate, Script> script);
template <typename Isolate>
HandleFor<Isolate, ByteArray> FinalizeSourcePositionTable(Isolate* isolate);
template <typename LocalIsolate>
Handle<BytecodeArray> FinalizeBytecode(LocalIsolate* isolate,
Handle<Script> script);
template <typename LocalIsolate>
Handle<ByteArray> FinalizeSourcePositionTable(LocalIsolate* isolate);
#ifdef DEBUG
int CheckBytecodeMatches(BytecodeArray bytecode);
@ -163,9 +163,8 @@ class BytecodeGenerator final : public AstVisitor<BytecodeGenerator> {
};
void GenerateBytecodeBody();
template <typename Isolate>
void AllocateDeferredConstants(Isolate* isolate,
HandleFor<Isolate, Script> script);
template <typename LocalIsolate>
void AllocateDeferredConstants(LocalIsolate* isolate, Handle<Script> script);
DEFINE_AST_VISITOR_SUBCLASS_MEMBERS();

View File

@ -65,9 +65,9 @@ const ConstantArrayBuilder::Entry& ConstantArrayBuilder::ConstantArraySlice::At(
}
#if DEBUG
template <typename Isolate>
template <typename LocalIsolate>
void ConstantArrayBuilder::ConstantArraySlice::CheckAllElementsAreUnique(
Isolate* isolate) const {
LocalIsolate* isolate) const {
std::set<Smi> smis;
std::set<double> heap_numbers;
std::set<const AstRawString*> strings;
@ -93,8 +93,7 @@ void ConstantArrayBuilder::ConstantArraySlice::CheckAllElementsAreUnique(
duplicate = !scopes.insert(entry.scope_).second;
break;
case Entry::Tag::kHandle:
duplicate =
!deferred_objects.insert(*entry.handle_.get<Isolate>()).second;
duplicate = !deferred_objects.insert(*entry.handle_).second;
break;
case Entry::Tag::kDeferred:
UNREACHABLE(); // Should be kHandle at this point.
@ -169,31 +168,29 @@ ConstantArrayBuilder::ConstantArraySlice* ConstantArrayBuilder::IndexToSlice(
UNREACHABLE();
}
template <typename Isolate>
MaybeHandleFor<Isolate, Object> ConstantArrayBuilder::At(
size_t index, Isolate* isolate) const {
template <typename LocalIsolate>
MaybeHandle<Object> ConstantArrayBuilder::At(size_t index,
LocalIsolate* isolate) const {
const ConstantArraySlice* slice = IndexToSlice(index);
DCHECK_LT(index, slice->capacity());
if (index < slice->start_index() + slice->size()) {
const Entry& entry = slice->At(index);
if (!entry.IsDeferred()) return entry.ToHandle(isolate);
}
return MaybeHandleFor<Isolate, Object>();
return MaybeHandle<Object>();
}
template EXPORT_TEMPLATE_DEFINE(V8_EXPORT_PRIVATE)
MaybeHandle<Object> ConstantArrayBuilder::At(size_t index,
Isolate* isolate) const;
template EXPORT_TEMPLATE_DEFINE(V8_EXPORT_PRIVATE)
OffThreadHandle<Object> ConstantArrayBuilder::At(
MaybeHandle<Object> ConstantArrayBuilder::At(
size_t index, OffThreadIsolate* isolate) const;
template <typename Isolate>
HandleFor<Isolate, FixedArray> ConstantArrayBuilder::ToFixedArray(
Isolate* isolate) {
HandleFor<Isolate, FixedArray> fixed_array =
isolate->factory()->NewFixedArrayWithHoles(static_cast<int>(size()),
AllocationType::kOld);
template <typename LocalIsolate>
Handle<FixedArray> ConstantArrayBuilder::ToFixedArray(LocalIsolate* isolate) {
Handle<FixedArray> fixed_array = isolate->factory()->NewFixedArrayWithHoles(
static_cast<int>(size()), AllocationType::kOld);
int array_index = 0;
for (const ConstantArraySlice* slice : idx_slice_) {
DCHECK_EQ(slice->reserved(), 0);
@ -206,7 +203,7 @@ HandleFor<Isolate, FixedArray> ConstantArrayBuilder::ToFixedArray(
#endif
// Copy objects from slice into array.
for (size_t i = 0; i < slice->size(); ++i) {
HandleFor<Isolate, Object> value =
Handle<Object> value =
slice->At(slice->start_index() + i).ToHandle(isolate);
fixed_array->set(array_index++, *value);
}
@ -224,7 +221,7 @@ HandleFor<Isolate, FixedArray> ConstantArrayBuilder::ToFixedArray(
template EXPORT_TEMPLATE_DEFINE(V8_EXPORT_PRIVATE)
Handle<FixedArray> ConstantArrayBuilder::ToFixedArray(Isolate* isolate);
template EXPORT_TEMPLATE_DEFINE(V8_EXPORT_PRIVATE)
OffThreadHandle<FixedArray> ConstantArrayBuilder::ToFixedArray(
Handle<FixedArray> ConstantArrayBuilder::ToFixedArray(
OffThreadIsolate* isolate);
size_t ConstantArrayBuilder::Insert(Smi smi) {
@ -326,8 +323,7 @@ size_t ConstantArrayBuilder::InsertJumpTable(size_t size) {
return AllocateIndexArray(Entry::UninitializedJumpTableSmi(), size);
}
void ConstantArrayBuilder::SetDeferredAt(
size_t index, HandleOrOffThreadHandle<Object> object) {
void ConstantArrayBuilder::SetDeferredAt(size_t index, Handle<Object> object) {
ConstantArraySlice* slice = IndexToSlice(index);
return slice->At(index).SetDeferred(object);
}
@ -383,9 +379,9 @@ void ConstantArrayBuilder::DiscardReservedEntry(OperandSize operand_size) {
OperandSizeToSlice(operand_size)->Unreserve();
}
template <typename Isolate>
HandleFor<Isolate, Object> ConstantArrayBuilder::Entry::ToHandle(
Isolate* isolate) const {
template <typename LocalIsolate>
Handle<Object> ConstantArrayBuilder::Entry::ToHandle(
LocalIsolate* isolate) const {
switch (tag_) {
case Tag::kDeferred:
// We shouldn't have any deferred entries by now.
@ -420,7 +416,7 @@ HandleFor<Isolate, Object> ConstantArrayBuilder::Entry::ToHandle(
template Handle<Object> ConstantArrayBuilder::Entry::ToHandle(
Isolate* isolate) const;
template OffThreadHandle<Object> ConstantArrayBuilder::Entry::ToHandle(
template Handle<Object> ConstantArrayBuilder::Entry::ToHandle(
OffThreadIsolate* isolate) const;
} // namespace interpreter

View File

@ -53,16 +53,16 @@ class V8_EXPORT_PRIVATE ConstantArrayBuilder final {
explicit ConstantArrayBuilder(Zone* zone);
// Generate a fixed array of constant handles based on inserted objects.
template <typename Isolate>
template <typename LocalIsolate>
EXPORT_TEMPLATE_DECLARE(V8_EXPORT_PRIVATE)
HandleFor<Isolate, FixedArray> ToFixedArray(Isolate* isolate);
Handle<FixedArray> ToFixedArray(LocalIsolate* isolate);
// Returns the object, as a handle in |isolate|, that is in the constant pool
// array at index |index|. Returns null if there is no handle at this index.
// Only expected to be used in tests.
template <typename Isolate>
template <typename LocalIsolate>
EXPORT_TEMPLATE_DECLARE(V8_EXPORT_PRIVATE)
MaybeHandleFor<Isolate, Object> At(size_t index, Isolate* isolate) const;
MaybeHandle<Object> At(size_t index, LocalIsolate* isolate) const;
// Returns the number of elements in the array.
size_t size() const;
@ -89,7 +89,7 @@ class V8_EXPORT_PRIVATE ConstantArrayBuilder final {
size_t InsertJumpTable(size_t size);
// Sets the deferred value at |index| to |object|.
void SetDeferredAt(size_t index, HandleOrOffThreadHandle<Object> object);
void SetDeferredAt(size_t index, Handle<Object> object);
// Sets the jump table entry at |index| to |smi|. Note that |index| is the
// constant pool index, not the switch case value.
@ -143,7 +143,7 @@ class V8_EXPORT_PRIVATE ConstantArrayBuilder final {
tag_ == Tag::kJumpTableSmi;
}
void SetDeferred(HandleOrOffThreadHandle<Object> handle) {
void SetDeferred(Handle<Object> handle) {
DCHECK_EQ(tag_, Tag::kDeferred);
tag_ = Tag::kHandle;
handle_ = handle;
@ -155,14 +155,14 @@ class V8_EXPORT_PRIVATE ConstantArrayBuilder final {
smi_ = smi;
}
template <typename Isolate>
HandleFor<Isolate, Object> ToHandle(Isolate* isolate) const;
template <typename LocalIsolate>
Handle<Object> ToHandle(LocalIsolate* isolate) const;
private:
explicit Entry(Tag tag) : tag_(tag) {}
union {
HandleOrOffThreadHandle<Object> handle_;
Handle<Object> handle_;
Smi smi_;
double heap_number_;
const AstRawString* raw_string_;
@ -205,8 +205,8 @@ class V8_EXPORT_PRIVATE ConstantArrayBuilder final {
const Entry& At(size_t index) const;
#if DEBUG
template <typename Isolate>
void CheckAllElementsAreUnique(Isolate* isolate) const;
template <typename LocalIsolate>
void CheckAllElementsAreUnique(LocalIsolate* isolate) const;
#endif
inline size_t available() const { return capacity() - reserved() - size(); }

View File

@ -15,14 +15,11 @@ namespace interpreter {
HandlerTableBuilder::HandlerTableBuilder(Zone* zone) : entries_(zone) {}
template <typename Isolate>
HandleFor<Isolate, ByteArray> HandlerTableBuilder::ToHandlerTable(
Isolate* isolate) {
template <typename LocalIsolate>
Handle<ByteArray> HandlerTableBuilder::ToHandlerTable(LocalIsolate* isolate) {
int handler_table_size = static_cast<int>(entries_.size());
HandleFor<Isolate, ByteArray> table_byte_array =
isolate->factory()->NewByteArray(
HandlerTable::LengthForRange(handler_table_size),
AllocationType::kOld);
Handle<ByteArray> table_byte_array = isolate->factory()->NewByteArray(
HandlerTable::LengthForRange(handler_table_size), AllocationType::kOld);
HandlerTable table(*table_byte_array);
for (int i = 0; i < handler_table_size; ++i) {
Entry& entry = entries_[i];
@ -37,7 +34,7 @@ HandleFor<Isolate, ByteArray> HandlerTableBuilder::ToHandlerTable(
template Handle<ByteArray> HandlerTableBuilder::ToHandlerTable(
Isolate* isolate);
template OffThreadHandle<ByteArray> HandlerTableBuilder::ToHandlerTable(
template Handle<ByteArray> HandlerTableBuilder::ToHandlerTable(
OffThreadIsolate* isolate);
int HandlerTableBuilder::NewHandlerEntry() {

View File

@ -28,8 +28,8 @@ class V8_EXPORT_PRIVATE HandlerTableBuilder final {
// Builds the actual handler table by copying the current values into a heap
// object. Any further mutations to the builder won't be reflected.
template <typename Isolate>
HandleFor<Isolate, ByteArray> ToHandlerTable(Isolate* isolate);
template <typename LocalIsolate>
Handle<ByteArray> ToHandlerTable(LocalIsolate* isolate);
// Creates a new handler table entry and returns a {hander_id} identifying the
// entry, so that it can be referenced by below setter functions.

View File

@ -210,7 +210,7 @@ InterpreterCompilationJob::Status InterpreterCompilationJob::FinalizeJobImpl(
TRACE_EVENT0(TRACE_DISABLED_BY_DEFAULT("v8.compile"),
"V8.CompileIgnitionFinalization");
Handle<BytecodeArray> bytecodes = compilation_info_.bytecode_array<Isolate>();
Handle<BytecodeArray> bytecodes = compilation_info_.bytecode_array();
if (bytecodes.is_null()) {
bytecodes = generator()->FinalizeBytecode(
isolate, handle(Script::cast(shared_info->script()), isolate));

View File

@ -180,24 +180,23 @@ enum class Sign { kNegative, kPositive, kNone };
// ES6 18.2.5 parseInt(string, radix) (with NumberParseIntHelper subclass);
// and BigInt parsing cases from https://tc39.github.io/proposal-bigint/
// (with StringToBigIntHelper subclass).
template <typename Isolate>
template <typename LocalIsolate>
class StringToIntHelper {
public:
StringToIntHelper(Isolate* isolate, HandleFor<Isolate, String> subject,
int radix)
StringToIntHelper(LocalIsolate* isolate, Handle<String> subject, int radix)
: isolate_(isolate), subject_(subject), radix_(radix) {
DCHECK(subject->IsFlat());
}
// Used for the StringToBigInt operation.
StringToIntHelper(Isolate* isolate, HandleFor<Isolate, String> subject)
StringToIntHelper(LocalIsolate* isolate, Handle<String> subject)
: isolate_(isolate), subject_(subject) {
DCHECK(subject->IsFlat());
}
// Used for parsing BigInt literals, where the input is a Zone-allocated
// buffer of one-byte digits, along with an optional radix prefix.
StringToIntHelper(Isolate* isolate, const uint8_t* subject, int length)
StringToIntHelper(LocalIsolate* isolate, const uint8_t* subject, int length)
: isolate_(isolate), raw_one_byte_subject_(subject), length_(length) {}
virtual ~StringToIntHelper() = default;
@ -237,7 +236,7 @@ class StringToIntHelper {
return subject_->GetFlatContent(no_gc).ToUC16Vector();
}
Isolate* isolate() { return isolate_; }
LocalIsolate* isolate() { return isolate_; }
int radix() { return radix_; }
int cursor() { return cursor_; }
int length() { return length_; }
@ -252,8 +251,8 @@ class StringToIntHelper {
template <class Char>
void ParseInternal(Char start);
Isolate* isolate_;
HandleFor<Isolate, String> subject_;
LocalIsolate* isolate_;
Handle<String> subject_;
const uint8_t* raw_one_byte_subject_ = nullptr;
int radix_ = 0;
int cursor_ = 0;
@ -265,8 +264,8 @@ class StringToIntHelper {
State state_ = State::kRunning;
};
template <typename Isolate>
void StringToIntHelper<Isolate>::ParseInt() {
template <typename LocalIsolate>
void StringToIntHelper<LocalIsolate>::ParseInt() {
{
DisallowHeapAllocation no_gc;
if (IsOneByte()) {
@ -296,9 +295,10 @@ void StringToIntHelper<Isolate>::ParseInt() {
DCHECK_NE(state_, State::kRunning);
}
template <typename Isolate>
template <typename LocalIsolate>
template <class Char>
void StringToIntHelper<Isolate>::DetectRadixInternal(Char current, int length) {
void StringToIntHelper<LocalIsolate>::DetectRadixInternal(Char current,
int length) {
Char start = current;
length_ = length;
Char end = start + length;
@ -375,9 +375,9 @@ void StringToIntHelper<Isolate>::DetectRadixInternal(Char current, int length) {
cursor_ = static_cast<int>(current - start);
}
template <typename Isolate>
template <typename LocalIsolate>
template <class Char>
void StringToIntHelper<Isolate>::ParseInternal(Char start) {
void StringToIntHelper<LocalIsolate>::ParseInternal(Char start) {
Char current = start + cursor_;
Char end = start + length_;
@ -836,14 +836,14 @@ double StringToInt(Isolate* isolate, Handle<String> string, int radix) {
return helper.GetResult();
}
template <typename Isolate>
class StringToBigIntHelper : public StringToIntHelper<Isolate> {
template <typename LocalIsolate>
class StringToBigIntHelper : public StringToIntHelper<LocalIsolate> {
public:
enum class Behavior { kStringToBigInt, kLiteral };
// Used for StringToBigInt operation (BigInt constructor and == operator).
StringToBigIntHelper(Isolate* isolate, HandleFor<Isolate, String> string)
: StringToIntHelper<Isolate>(isolate, string),
StringToBigIntHelper(LocalIsolate* isolate, Handle<String> string)
: StringToIntHelper<LocalIsolate>(isolate, string),
behavior_(Behavior::kStringToBigInt) {
this->set_allow_binary_and_octal_prefixes();
this->set_disallow_trailing_junk();
@ -851,17 +851,17 @@ class StringToBigIntHelper : public StringToIntHelper<Isolate> {
// Used for parsing BigInt literals, where the input is a buffer of
// one-byte ASCII digits, along with an optional radix prefix.
StringToBigIntHelper(Isolate* isolate, const uint8_t* string, int length)
: StringToIntHelper<Isolate>(isolate, string, length),
StringToBigIntHelper(LocalIsolate* isolate, const uint8_t* string, int length)
: StringToIntHelper<LocalIsolate>(isolate, string, length),
behavior_(Behavior::kLiteral) {
this->set_allow_binary_and_octal_prefixes();
}
MaybeHandleFor<Isolate, BigInt> GetResult() {
MaybeHandle<BigInt> GetResult() {
this->ParseInt();
if (behavior_ == Behavior::kStringToBigInt && this->sign() != Sign::kNone &&
this->radix() != 10) {
return MaybeHandleFor<Isolate, BigInt>();
return MaybeHandle<BigInt>();
}
if (this->state() == State::kEmpty) {
if (behavior_ == Behavior::kStringToBigInt) {
@ -873,7 +873,7 @@ class StringToBigIntHelper : public StringToIntHelper<Isolate> {
switch (this->state()) {
case State::kJunk:
case State::kError:
return MaybeHandleFor<Isolate, BigInt>();
return MaybeHandle<BigInt>();
case State::kZero:
return BigInt::Zero(this->isolate());
case State::kDone:
@ -897,7 +897,7 @@ class StringToBigIntHelper : public StringToIntHelper<Isolate> {
AllocationType allocation = behavior_ == Behavior::kLiteral
? AllocationType::kOld
: AllocationType::kYoung;
MaybeHandleFor<Isolate, FreshlyAllocatedBigInt> maybe = BigInt::AllocateFor(
MaybeHandle<FreshlyAllocatedBigInt> maybe = BigInt::AllocateFor(
this->isolate(), this->radix(), charcount, kDontThrow, allocation);
if (!maybe.ToHandle(&result_)) {
this->set_state(State::kError);
@ -910,7 +910,7 @@ class StringToBigIntHelper : public StringToIntHelper<Isolate> {
}
private:
HandleFor<Isolate, FreshlyAllocatedBigInt> result_;
Handle<FreshlyAllocatedBigInt> result_;
Behavior behavior_;
};
@ -920,19 +920,18 @@ MaybeHandle<BigInt> StringToBigInt(Isolate* isolate, Handle<String> string) {
return helper.GetResult();
}
template <typename Isolate>
MaybeHandleFor<Isolate, BigInt> BigIntLiteral(Isolate* isolate,
const char* string) {
StringToBigIntHelper<Isolate> helper(isolate,
reinterpret_cast<const uint8_t*>(string),
static_cast<int>(strlen(string)));
template <typename LocalIsolate>
MaybeHandle<BigInt> BigIntLiteral(LocalIsolate* isolate, const char* string) {
StringToBigIntHelper<LocalIsolate> helper(
isolate, reinterpret_cast<const uint8_t*>(string),
static_cast<int>(strlen(string)));
return helper.GetResult();
}
template EXPORT_TEMPLATE_DEFINE(V8_EXPORT_PRIVATE)
MaybeHandle<BigInt> BigIntLiteral(Isolate* isolate, const char* string);
template EXPORT_TEMPLATE_DEFINE(V8_EXPORT_PRIVATE)
OffThreadHandle<BigInt> BigIntLiteral(OffThreadIsolate* isolate,
const char* string);
MaybeHandle<BigInt> BigIntLiteral(OffThreadIsolate* isolate,
const char* string);
const char* DoubleToCString(double v, Vector<char> buffer) {
switch (FPCLASSIFY_NAMESPACE::fpclassify(v)) {

View File

@ -8,7 +8,6 @@
#include "src/base/export-template.h"
#include "src/base/logging.h"
#include "src/common/globals.h"
#include "src/handles/handle-for.h"
#include "src/utils/vector.h"
namespace v8 {
@ -101,10 +100,9 @@ MaybeHandle<BigInt> StringToBigInt(Isolate* isolate, Handle<String> string);
// 0x -> hex
// 0o -> octal
// 0b -> binary
template <typename Isolate>
template <typename LocalIsolate>
EXPORT_TEMPLATE_DECLARE(V8_EXPORT_PRIVATE)
MaybeHandleFor<Isolate, BigInt> BigIntLiteral(Isolate* isolate,
const char* string);
MaybeHandle<BigInt> BigIntLiteral(LocalIsolate* isolate, const char* string);
const int kDoubleToCStringMinBufferSize = 100;

View File

@ -46,36 +46,30 @@ class MutableBigInt : public FreshlyAllocatedBigInt {
// Bottleneck for converting MutableBigInts to BigInts.
static MaybeHandle<BigInt> MakeImmutable(MaybeHandle<MutableBigInt> maybe);
template <typename Isolate = v8::internal::Isolate>
static HandleFor<Isolate, BigInt> MakeImmutable(
HandleFor<Isolate, MutableBigInt> result);
static Handle<BigInt> MakeImmutable(Handle<MutableBigInt> result);
static void Canonicalize(MutableBigInt result);
// Allocation helpers.
template <typename Isolate>
static MaybeHandleFor<Isolate, MutableBigInt> New(
Isolate* isolate, int length,
template <typename LocalIsolate>
static MaybeHandle<MutableBigInt> New(
LocalIsolate* isolate, int length,
AllocationType allocation = AllocationType::kYoung);
static Handle<BigInt> NewFromInt(Isolate* isolate, int value);
static Handle<BigInt> NewFromDouble(Isolate* isolate, double value);
void InitializeDigits(int length, byte value = 0);
static Handle<MutableBigInt> Copy(Isolate* isolate,
Handle<BigIntBase> source);
template <typename Isolate>
static HandleFor<Isolate, BigInt> Zero(Isolate* isolate) {
template <typename LocalIsolate>
static Handle<BigInt> Zero(LocalIsolate* isolate) {
// TODO(jkummerow): Consider caching a canonical zero-BigInt.
return MakeImmutable<Isolate>(New(isolate, 0).ToHandleChecked());
return MakeImmutable<LocalIsolate>(New(isolate, 0).ToHandleChecked());
}
static Handle<MutableBigInt> Cast(Handle<FreshlyAllocatedBigInt> bigint) {
SLOW_DCHECK(bigint->IsBigInt());
return Handle<MutableBigInt>::cast(bigint);
}
static OffThreadHandle<MutableBigInt> Cast(
OffThreadHandle<FreshlyAllocatedBigInt> bigint) {
SLOW_DCHECK(bigint->IsBigInt());
return OffThreadHandle<MutableBigInt>::cast(bigint);
}
static MutableBigInt cast(Object o) {
SLOW_DCHECK(o.IsBigInt());
return MutableBigInt(o.ptr());
@ -247,7 +241,7 @@ NEVER_READ_ONLY_SPACE_IMPL(MutableBigInt)
#include "src/objects/object-macros-undef.h"
template <typename T, typename Isolate>
MaybeHandleFor<Isolate, T> ThrowBigIntTooBig(Isolate* isolate) {
MaybeHandle<T> ThrowBigIntTooBig(Isolate* isolate) {
// If the result of a BigInt computation is truncated to 64 bit, Turbofan
// can sometimes truncate intermediate results already, which can prevent
// those from exceeding the maximum length, effectively preventing a
@ -260,13 +254,13 @@ MaybeHandleFor<Isolate, T> ThrowBigIntTooBig(Isolate* isolate) {
THROW_NEW_ERROR(isolate, NewRangeError(MessageTemplate::kBigIntTooBig), T);
}
template <typename Isolate>
MaybeHandleFor<Isolate, MutableBigInt> MutableBigInt::New(
Isolate* isolate, int length, AllocationType allocation) {
template <typename LocalIsolate>
MaybeHandle<MutableBigInt> MutableBigInt::New(LocalIsolate* isolate, int length,
AllocationType allocation) {
if (length > BigInt::kMaxLength) {
return ThrowBigIntTooBig<MutableBigInt>(isolate);
}
HandleFor<Isolate, MutableBigInt> result =
Handle<MutableBigInt> result =
Cast(isolate->factory()->NewBigInt(length, allocation));
result->initialize_bitfield(false, length);
#if DEBUG
@ -378,16 +372,15 @@ void MutableBigInt::InitializeDigits(int length, byte value) {
MaybeHandle<BigInt> MutableBigInt::MakeImmutable(
MaybeHandle<MutableBigInt> maybe) {
HandleFor<Isolate, MutableBigInt> result;
if (!maybe.ToHandle(&result)) return MaybeHandleFor<Isolate, BigInt>();
Handle<MutableBigInt> result;
if (!maybe.ToHandle(&result)) return MaybeHandle<BigInt>();
return MakeImmutable(result);
}
template <typename Isolate>
HandleFor<Isolate, BigInt> MutableBigInt::MakeImmutable(
HandleFor<Isolate, MutableBigInt> result) {
template <typename LocalIsolate>
Handle<BigInt> MutableBigInt::MakeImmutable(Handle<MutableBigInt> result) {
MutableBigInt::Canonicalize(*result);
return HandleFor<Isolate, BigInt>::cast(result);
return Handle<BigInt>::cast(result);
}
void MutableBigInt::Canonicalize(MutableBigInt result) {
@ -418,12 +411,12 @@ void MutableBigInt::Canonicalize(MutableBigInt result) {
result.digit(result.length() - 1) != 0); // MSD is non-zero.
}
template <typename Isolate>
HandleFor<Isolate, BigInt> BigInt::Zero(Isolate* isolate) {
template <typename LocalIsolate>
Handle<BigInt> BigInt::Zero(LocalIsolate* isolate) {
return MutableBigInt::Zero(isolate);
}
template Handle<BigInt> BigInt::Zero<Isolate>(Isolate* isolate);
template OffThreadHandle<BigInt> BigInt::Zero<OffThreadIsolate>(
template Handle<BigInt> BigInt::Zero<OffThreadIsolate>(
OffThreadIsolate* isolate);
Handle<BigInt> BigInt::UnaryMinus(Isolate* isolate, Handle<BigInt> x) {
@ -1924,9 +1917,9 @@ constexpr uint8_t kMaxBitsPerChar[] = {
static const int kBitsPerCharTableShift = 5;
static const size_t kBitsPerCharTableMultiplier = 1u << kBitsPerCharTableShift;
template <typename Isolate>
MaybeHandleFor<Isolate, FreshlyAllocatedBigInt> BigInt::AllocateFor(
Isolate* isolate, int radix, int charcount, ShouldThrow should_throw,
template <typename LocalIsolate>
MaybeHandle<FreshlyAllocatedBigInt> BigInt::AllocateFor(
LocalIsolate* isolate, int radix, int charcount, ShouldThrow should_throw,
AllocationType allocation) {
DCHECK(2 <= radix && radix <= 36);
DCHECK_GE(charcount, 0);
@ -1941,7 +1934,7 @@ MaybeHandleFor<Isolate, FreshlyAllocatedBigInt> BigInt::AllocateFor(
// Divide by kDigitsBits, rounding up.
int length = static_cast<int>((bits_min + kDigitBits - 1) / kDigitBits);
if (length <= kMaxLength) {
HandleFor<Isolate, MutableBigInt> result =
Handle<MutableBigInt> result =
MutableBigInt::New(isolate, length, allocation).ToHandleChecked();
result->InitializeDigits(length);
return result;
@ -1952,30 +1945,28 @@ MaybeHandleFor<Isolate, FreshlyAllocatedBigInt> BigInt::AllocateFor(
if (should_throw == kThrowOnError) {
return ThrowBigIntTooBig<FreshlyAllocatedBigInt>(isolate);
} else {
return MaybeHandleFor<Isolate, FreshlyAllocatedBigInt>();
return MaybeHandle<FreshlyAllocatedBigInt>();
}
}
template MaybeHandle<FreshlyAllocatedBigInt> BigInt::AllocateFor<Isolate>(
Isolate* isolate, int radix, int charcount, ShouldThrow should_throw,
AllocationType allocation);
template OffThreadHandle<FreshlyAllocatedBigInt>
template MaybeHandle<FreshlyAllocatedBigInt>
BigInt::AllocateFor<OffThreadIsolate>(OffThreadIsolate* isolate, int radix,
int charcount, ShouldThrow should_throw,
AllocationType allocation);
template <typename Isolate>
HandleFor<Isolate, BigInt> BigInt::Finalize(
HandleFor<Isolate, FreshlyAllocatedBigInt> x, bool sign) {
HandleFor<Isolate, MutableBigInt> bigint =
HandleFor<Isolate, MutableBigInt>::cast(x);
template <typename LocalIsolate>
Handle<BigInt> BigInt::Finalize(Handle<FreshlyAllocatedBigInt> x, bool sign) {
Handle<MutableBigInt> bigint = Handle<MutableBigInt>::cast(x);
bigint->set_sign(sign);
return MutableBigInt::MakeImmutable<Isolate>(bigint);
}
template Handle<BigInt> BigInt::Finalize<Isolate>(
Handle<FreshlyAllocatedBigInt>, bool);
template OffThreadHandle<BigInt> BigInt::Finalize<OffThreadIsolate>(
OffThreadHandle<FreshlyAllocatedBigInt>, bool);
template Handle<BigInt> BigInt::Finalize<OffThreadIsolate>(
Handle<FreshlyAllocatedBigInt>, bool);
// The serialization format MUST NOT CHANGE without updating the format
// version in value-serializer.cc!

View File

@ -6,7 +6,6 @@
#define V8_OBJECTS_BIGINT_H_
#include "src/common/globals.h"
#include "src/handles/handle-for.h"
#include "src/objects/objects.h"
#include "src/objects/primitive-heap-object.h"
#include "src/utils/utils.h"
@ -239,23 +238,22 @@ class BigInt : public BigIntBase {
class BodyDescriptor;
private:
template <typename Isolate>
template <typename LocalIsolate>
friend class StringToBigIntHelper;
friend class ValueDeserializer;
friend class ValueSerializer;
// Special functions for StringToBigIntHelper:
template <typename Isolate>
static HandleFor<Isolate, BigInt> Zero(Isolate* isolate);
template <typename Isolate>
static MaybeHandleFor<Isolate, FreshlyAllocatedBigInt> AllocateFor(
Isolate* isolate, int radix, int charcount, ShouldThrow should_throw,
template <typename LocalIsolate>
static Handle<BigInt> Zero(LocalIsolate* isolate);
template <typename LocalIsolate>
static MaybeHandle<FreshlyAllocatedBigInt> AllocateFor(
LocalIsolate* isolate, int radix, int charcount, ShouldThrow should_throw,
AllocationType allocation);
static void InplaceMultiplyAdd(FreshlyAllocatedBigInt x, uintptr_t factor,
uintptr_t summand);
template <typename Isolate>
static HandleFor<Isolate, BigInt> Finalize(
HandleFor<Isolate, FreshlyAllocatedBigInt> x, bool sign);
template <typename LocalIsolate>
static Handle<BigInt> Finalize(Handle<FreshlyAllocatedBigInt> x, bool sign);
// Special functions for ValueSerializer/ValueDeserializer:
uint32_t GetBitfieldForSerialization() const;

View File

@ -568,7 +568,7 @@ Handle<ClassBoilerplate> ClassBoilerplate::BuildClassBoilerplate(
return scope.CloseAndEscape(class_boilerplate);
}
OffThreadHandle<ClassBoilerplate> ClassBoilerplate::BuildClassBoilerplate(
Handle<ClassBoilerplate> ClassBoilerplate::BuildClassBoilerplate(
OffThreadIsolate* isolate, ClassLiteral* expr) {
// TODO(leszeks): Add class boilerplate support to off-thread finalization.
UNREACHABLE();

View File

@ -130,7 +130,7 @@ class ClassBoilerplate : public FixedArray {
static Handle<ClassBoilerplate> BuildClassBoilerplate(Isolate* isolate,
ClassLiteral* expr);
static OffThreadHandle<ClassBoilerplate> BuildClassBoilerplate(
static Handle<ClassBoilerplate> BuildClassBoilerplate(
OffThreadIsolate* isolate, ClassLiteral* expr);
enum {

View File

@ -4708,9 +4708,9 @@ int Script::GetEvalPosition(Isolate* isolate, Handle<Script> script) {
return position;
}
template <typename Isolate>
template <typename LocalIsolate>
// static
void Script::InitLineEnds(Isolate* isolate, HandleFor<Isolate, Script> script) {
void Script::InitLineEnds(LocalIsolate* isolate, Handle<Script> script) {
if (!script->line_ends().IsUndefined(isolate)) return;
DCHECK(script->type() != Script::TYPE_WASM ||
script->source_mapping_url().IsString());
@ -4721,9 +4721,8 @@ void Script::InitLineEnds(Isolate* isolate, HandleFor<Isolate, Script> script) {
script->set_line_ends(ReadOnlyRoots(isolate).empty_fixed_array());
} else {
DCHECK(src_obj.IsString());
HandleFor<Isolate, String> src(String::cast(src_obj), isolate);
HandleFor<Isolate, FixedArray> array =
String::CalculateLineEnds(isolate, src, true);
Handle<String> src(String::cast(src_obj), isolate);
Handle<FixedArray> array = String::CalculateLineEnds(isolate, src, true);
script->set_line_ends(*array);
}
@ -4733,7 +4732,7 @@ void Script::InitLineEnds(Isolate* isolate, HandleFor<Isolate, Script> script) {
template EXPORT_TEMPLATE_DEFINE(V8_EXPORT_PRIVATE) void Script::InitLineEnds(
Isolate* isolate, Handle<Script> script);
template EXPORT_TEMPLATE_DEFINE(V8_EXPORT_PRIVATE) void Script::InitLineEnds(
OffThreadIsolate* isolate, OffThreadHandle<Script> script);
OffThreadIsolate* isolate, Handle<Script> script);
bool Script::GetPositionInfo(Handle<Script> script, int position,
PositionInfo* info, OffsetFlag offset_flag) {
@ -4898,9 +4897,9 @@ Object Script::GetNameOrSourceURL() {
return name();
}
template <typename Isolate>
MaybeHandleFor<Isolate, SharedFunctionInfo> Script::FindSharedFunctionInfo(
Isolate* isolate, const FunctionLiteral* fun) {
template <typename LocalIsolate>
MaybeHandle<SharedFunctionInfo> Script::FindSharedFunctionInfo(
LocalIsolate* isolate, const FunctionLiteral* fun) {
CHECK_NE(fun->function_literal_id(), kFunctionLiteralIdInvalid);
// If this check fails, the problem is most probably the function id
// renumbering done by AstFunctionLiteralIdReindexer; in particular, that
@ -4911,13 +4910,13 @@ MaybeHandleFor<Isolate, SharedFunctionInfo> Script::FindSharedFunctionInfo(
HeapObject heap_object;
if (!shared->GetHeapObject(&heap_object) ||
heap_object.IsUndefined(isolate)) {
return MaybeHandleFor<Isolate, SharedFunctionInfo>();
return MaybeHandle<SharedFunctionInfo>();
}
return handle(SharedFunctionInfo::cast(heap_object), isolate);
}
template MaybeHandle<SharedFunctionInfo> Script::FindSharedFunctionInfo(
Isolate* isolate, const FunctionLiteral* fun);
template OffThreadHandle<SharedFunctionInfo> Script::FindSharedFunctionInfo(
template MaybeHandle<SharedFunctionInfo> Script::FindSharedFunctionInfo(
OffThreadIsolate* isolate, const FunctionLiteral* fun);
Script::Iterator::Iterator(Isolate* isolate)
@ -5344,9 +5343,9 @@ void SharedFunctionInfo::DisableOptimization(BailoutReason reason) {
}
// static
template <typename Isolate>
template <typename LocalIsolate>
void SharedFunctionInfo::InitFromFunctionLiteral(
Isolate* isolate, HandleFor<Isolate, SharedFunctionInfo> shared_info,
LocalIsolate* isolate, Handle<SharedFunctionInfo> shared_info,
FunctionLiteral* lit, bool is_toplevel) {
DCHECK(!shared_info->name_or_scope_info().IsScopeInfo());
@ -5372,8 +5371,7 @@ void SharedFunctionInfo::InitFromFunctionLiteral(
if (!is_toplevel) {
Scope* outer_scope = lit->scope()->GetOuterScopeWithContext();
if (outer_scope) {
shared_info->set_outer_scope_info(
*outer_scope->scope_info().get<Isolate>());
shared_info->set_outer_scope_info(*outer_scope->scope_info());
shared_info->set_private_name_lookup_skips_outer_class(
lit->scope()->private_name_lookup_skips_outer_class());
}
@ -5400,12 +5398,11 @@ void SharedFunctionInfo::InitFromFunctionLiteral(
shared_info->set_is_safe_to_skip_arguments_adaptor(false);
shared_info->UpdateExpectedNofPropertiesFromEstimate(lit);
HandleFor<Isolate, UncompiledData> data;
Handle<UncompiledData> data;
ProducedPreparseData* scope_data = lit->produced_preparse_data();
if (scope_data != nullptr) {
HandleFor<Isolate, PreparseData> preparse_data =
scope_data->Serialize(isolate);
Handle<PreparseData> preparse_data = scope_data->Serialize(isolate);
data = isolate->factory()->NewUncompiledDataWithPreparseData(
lit->GetInferredName(isolate), lit->start_position(),
@ -5425,9 +5422,8 @@ template EXPORT_TEMPLATE_DEFINE(V8_EXPORT_PRIVATE) void SharedFunctionInfo::
FunctionLiteral* lit, bool is_toplevel);
template EXPORT_TEMPLATE_DEFINE(V8_EXPORT_PRIVATE) void SharedFunctionInfo::
InitFromFunctionLiteral<OffThreadIsolate>(
OffThreadIsolate* isolate,
OffThreadHandle<SharedFunctionInfo> shared_info, FunctionLiteral* lit,
bool is_toplevel);
OffThreadIsolate* isolate, Handle<SharedFunctionInfo> shared_info,
FunctionLiteral* lit, bool is_toplevel);
uint16_t SharedFunctionInfo::get_property_estimate_from_literal(
FunctionLiteral* literal) {

View File

@ -61,10 +61,10 @@ bool ScopeInfo::Equals(ScopeInfo other) const {
#endif
// static
template <typename Isolate>
HandleFor<Isolate, ScopeInfo> ScopeInfo::Create(
Isolate* isolate, Zone* zone, Scope* scope,
MaybeHandleFor<Isolate, ScopeInfo> outer_scope) {
template <typename LocalIsolate>
Handle<ScopeInfo> ScopeInfo::Create(LocalIsolate* isolate, Zone* zone,
Scope* scope,
MaybeHandle<ScopeInfo> outer_scope) {
// Collect variables.
int context_local_count = 0;
int module_vars_count = 0;
@ -168,7 +168,7 @@ HandleFor<Isolate, ScopeInfo> ScopeInfo::Create(
? 2 + kModuleVariableEntryLength * module_vars_count
: 0);
HandleFor<Isolate, ScopeInfo> scope_info_handle =
Handle<ScopeInfo> scope_info_handle =
isolate->factory()->NewScopeInfo(length);
int index = kVariablePartIndex;
{
@ -242,15 +242,14 @@ HandleFor<Isolate, ScopeInfo> ScopeInfo::Create(
MaybeAssignedFlagField::encode(var->maybe_assigned()) |
ParameterNumberField::encode(ParameterNumberField::kMax) |
IsStaticFlagField::encode(var->is_static_flag());
scope_info.set(context_local_base + local_index,
*var->name().get<Isolate>(), mode);
scope_info.set(context_local_base + local_index, *var->name(), mode);
scope_info.set(context_local_info_base + local_index,
Smi::FromInt(info));
break;
}
case VariableLocation::MODULE: {
scope_info.set(module_var_entry + kModuleVariableNameOffset,
*var->name().get<Isolate>(), mode);
*var->name(), mode);
scope_info.set(module_var_entry + kModuleVariableIndexOffset,
Smi::FromInt(var->index()));
uint32_t properties =
@ -298,8 +297,7 @@ HandleFor<Isolate, ScopeInfo> ScopeInfo::Create(
MaybeAssignedFlagField::encode(var->maybe_assigned()) |
ParameterNumberField::encode(ParameterNumberField::kMax) |
IsStaticFlagField::encode(var->is_static_flag());
scope_info.set(context_local_base + local_index,
*var->name().get<Isolate>(), mode);
scope_info.set(context_local_base + local_index, *var->name(), mode);
scope_info.set(context_local_info_base + local_index,
Smi::FromInt(info));
}
@ -335,7 +333,7 @@ HandleFor<Isolate, ScopeInfo> ScopeInfo::Create(
Object name = Smi::zero();
if (var != nullptr) {
var_index = var->index();
name = *var->name().get<Isolate>();
name = *var->name();
}
scope_info.set(index++, name, mode);
scope_info.set(index++, Smi::FromInt(var_index));
@ -364,9 +362,8 @@ HandleFor<Isolate, ScopeInfo> ScopeInfo::Create(
// Module-specific information (only for module scopes).
if (scope->is_module_scope()) {
HandleFor<Isolate, SourceTextModuleInfo> module_info =
SourceTextModuleInfo::New(isolate, zone,
scope->AsModuleScope()->module());
Handle<SourceTextModuleInfo> module_info = SourceTextModuleInfo::New(
isolate, zone, scope->AsModuleScope()->module());
DCHECK_EQ(index, scope_info_handle->ModuleInfoIndex());
scope_info_handle->set(index++, *module_info);
DCHECK_EQ(index, scope_info_handle->ModuleVariableCountIndex());
@ -387,9 +384,9 @@ template EXPORT_TEMPLATE_DEFINE(V8_EXPORT_PRIVATE)
Isolate* isolate, Zone* zone, Scope* scope,
MaybeHandle<ScopeInfo> outer_scope);
template EXPORT_TEMPLATE_DEFINE(V8_EXPORT_PRIVATE)
OffThreadHandle<ScopeInfo> ScopeInfo::Create<OffThreadIsolate>(
Handle<ScopeInfo> ScopeInfo::Create<OffThreadIsolate>(
OffThreadIsolate* isolate, Zone* zone, Scope* scope,
OffThreadHandle<ScopeInfo> outer_scope);
MaybeHandle<ScopeInfo> outer_scope);
// static
Handle<ScopeInfo> ScopeInfo::CreateForWithScope(
@ -1046,16 +1043,15 @@ std::ostream& operator<<(std::ostream& os, VariableAllocationInfo var_info) {
return os;
}
template <typename Isolate>
HandleFor<Isolate, SourceTextModuleInfoEntry> SourceTextModuleInfoEntry::New(
Isolate* isolate, HandleFor<Isolate, PrimitiveHeapObject> export_name,
HandleFor<Isolate, PrimitiveHeapObject> local_name,
HandleFor<Isolate, PrimitiveHeapObject> import_name, int module_request,
int cell_index, int beg_pos, int end_pos) {
HandleFor<Isolate, SourceTextModuleInfoEntry> result =
HandleFor<Isolate, SourceTextModuleInfoEntry>::cast(
isolate->factory()->NewStruct(SOURCE_TEXT_MODULE_INFO_ENTRY_TYPE,
AllocationType::kOld));
template <typename LocalIsolate>
Handle<SourceTextModuleInfoEntry> SourceTextModuleInfoEntry::New(
LocalIsolate* isolate, Handle<PrimitiveHeapObject> export_name,
Handle<PrimitiveHeapObject> local_name,
Handle<PrimitiveHeapObject> import_name, int module_request, int cell_index,
int beg_pos, int end_pos) {
Handle<SourceTextModuleInfoEntry> result =
Handle<SourceTextModuleInfoEntry>::cast(isolate->factory()->NewStruct(
SOURCE_TEXT_MODULE_INFO_ENTRY_TYPE, AllocationType::kOld));
result->set_export_name(*export_name);
result->set_local_name(*local_name);
result->set_import_name(*import_name);
@ -1071,74 +1067,67 @@ template Handle<SourceTextModuleInfoEntry> SourceTextModuleInfoEntry::New(
Handle<PrimitiveHeapObject> local_name,
Handle<PrimitiveHeapObject> import_name, int module_request, int cell_index,
int beg_pos, int end_pos);
template OffThreadHandle<SourceTextModuleInfoEntry>
SourceTextModuleInfoEntry::New(OffThreadIsolate* isolate,
OffThreadHandle<PrimitiveHeapObject> export_name,
OffThreadHandle<PrimitiveHeapObject> local_name,
OffThreadHandle<PrimitiveHeapObject> import_name,
int module_request, int cell_index, int beg_pos,
int end_pos);
template Handle<SourceTextModuleInfoEntry> SourceTextModuleInfoEntry::New(
OffThreadIsolate* isolate, Handle<PrimitiveHeapObject> export_name,
Handle<PrimitiveHeapObject> local_name,
Handle<PrimitiveHeapObject> import_name, int module_request, int cell_index,
int beg_pos, int end_pos);
template <typename Isolate>
HandleFor<Isolate, SourceTextModuleInfo> SourceTextModuleInfo::New(
Isolate* isolate, Zone* zone, SourceTextModuleDescriptor* descr) {
template <typename LocalIsolate>
Handle<SourceTextModuleInfo> SourceTextModuleInfo::New(
LocalIsolate* isolate, Zone* zone, SourceTextModuleDescriptor* descr) {
// Serialize module requests.
int size = static_cast<int>(descr->module_requests().size());
HandleFor<Isolate, FixedArray> module_requests =
isolate->factory()->NewFixedArray(size);
HandleFor<Isolate, FixedArray> module_request_positions =
Handle<FixedArray> module_requests = isolate->factory()->NewFixedArray(size);
Handle<FixedArray> module_request_positions =
isolate->factory()->NewFixedArray(size);
for (const auto& elem : descr->module_requests()) {
module_requests->set(elem.second.index,
*elem.first->string().get<Isolate>());
module_requests->set(elem.second.index, *elem.first->string());
module_request_positions->set(elem.second.index,
Smi::FromInt(elem.second.position));
}
// Serialize special exports.
HandleFor<Isolate, FixedArray> special_exports =
isolate->factory()->NewFixedArray(
static_cast<int>(descr->special_exports().size()));
Handle<FixedArray> special_exports = isolate->factory()->NewFixedArray(
static_cast<int>(descr->special_exports().size()));
{
int i = 0;
for (auto entry : descr->special_exports()) {
HandleFor<Isolate, SourceTextModuleInfoEntry> serialized_entry =
Handle<SourceTextModuleInfoEntry> serialized_entry =
entry->Serialize(isolate);
special_exports->set(i++, *serialized_entry);
}
}
// Serialize namespace imports.
HandleFor<Isolate, FixedArray> namespace_imports =
isolate->factory()->NewFixedArray(
static_cast<int>(descr->namespace_imports().size()));
Handle<FixedArray> namespace_imports = isolate->factory()->NewFixedArray(
static_cast<int>(descr->namespace_imports().size()));
{
int i = 0;
for (auto entry : descr->namespace_imports()) {
HandleFor<Isolate, SourceTextModuleInfoEntry> serialized_entry =
Handle<SourceTextModuleInfoEntry> serialized_entry =
entry->Serialize(isolate);
namespace_imports->set(i++, *serialized_entry);
}
}
// Serialize regular exports.
HandleFor<Isolate, FixedArray> regular_exports =
Handle<FixedArray> regular_exports =
descr->SerializeRegularExports(isolate, zone);
// Serialize regular imports.
HandleFor<Isolate, FixedArray> regular_imports =
isolate->factory()->NewFixedArray(
static_cast<int>(descr->regular_imports().size()));
Handle<FixedArray> regular_imports = isolate->factory()->NewFixedArray(
static_cast<int>(descr->regular_imports().size()));
{
int i = 0;
for (const auto& elem : descr->regular_imports()) {
HandleFor<Isolate, SourceTextModuleInfoEntry> serialized_entry =
Handle<SourceTextModuleInfoEntry> serialized_entry =
elem.second->Serialize(isolate);
regular_imports->set(i++, *serialized_entry);
}
}
HandleFor<Isolate, SourceTextModuleInfo> result =
Handle<SourceTextModuleInfo> result =
isolate->factory()->NewSourceTextModuleInfo();
result->set(kModuleRequestsIndex, *module_requests);
result->set(kSpecialExportsIndex, *special_exports);
@ -1150,7 +1139,7 @@ HandleFor<Isolate, SourceTextModuleInfo> SourceTextModuleInfo::New(
}
template Handle<SourceTextModuleInfo> SourceTextModuleInfo::New(
Isolate* isolate, Zone* zone, SourceTextModuleDescriptor* descr);
template OffThreadHandle<SourceTextModuleInfo> SourceTextModuleInfo::New(
template Handle<SourceTextModuleInfo> SourceTextModuleInfo::New(
OffThreadIsolate* isolate, Zone* zone, SourceTextModuleDescriptor* descr);
int SourceTextModuleInfo::RegularExportCount() const {

View File

@ -6,7 +6,6 @@
#define V8_OBJECTS_SCOPE_INFO_H_
#include "src/common/globals.h"
#include "src/handles/handle-for.h"
#include "src/objects/fixed-array.h"
#include "src/objects/function-kind.h"
#include "src/objects/objects.h"
@ -221,10 +220,10 @@ class ScopeInfo : public FixedArray {
bool Equals(ScopeInfo other) const;
#endif
template <typename Isolate>
static HandleFor<Isolate, ScopeInfo> Create(
Isolate* isolate, Zone* zone, Scope* scope,
MaybeHandleFor<Isolate, ScopeInfo> outer_scope);
template <typename LocalIsolate>
static Handle<ScopeInfo> Create(LocalIsolate* isolate, Zone* zone,
Scope* scope,
MaybeHandle<ScopeInfo> outer_scope);
static Handle<ScopeInfo> CreateForWithScope(
Isolate* isolate, MaybeHandle<ScopeInfo> outer_scope);
V8_EXPORT_PRIVATE static Handle<ScopeInfo> CreateForEmptyFunction(

View File

@ -155,9 +155,9 @@ class Script : public Struct {
bool ContainsAsmModule();
// Init line_ends array with source code positions of line ends.
template <typename Isolate>
template <typename LocalIsolate>
EXPORT_TEMPLATE_DECLARE(V8_EXPORT_PRIVATE)
static void InitLineEnds(Isolate* isolate, HandleFor<Isolate, Script> script);
static void InitLineEnds(LocalIsolate* isolate, Handle<Script> script);
// Carries information about a source position.
struct PositionInfo {
@ -195,9 +195,9 @@ class Script : public Struct {
// Look through the list of existing shared function infos to find one
// that matches the function literal. Return empty handle if not found.
template <typename Isolate>
MaybeHandleFor<Isolate, SharedFunctionInfo> FindSharedFunctionInfo(
Isolate* isolate, const FunctionLiteral* fun);
template <typename LocalIsolate>
MaybeHandle<SharedFunctionInfo> FindSharedFunctionInfo(
LocalIsolate* isolate, const FunctionLiteral* fun);
// Iterate over all script objects on the heap.
class V8_EXPORT_PRIVATE Iterator {

View File

@ -619,8 +619,8 @@ void SharedFunctionInfo::ClearPreparseData() {
DCHECK(HasUncompiledDataWithoutPreparseData());
}
template <typename Isolate>
void UncompiledData::Init(Isolate* isolate, String inferred_name,
template <typename LocalIsolate>
void UncompiledData::Init(LocalIsolate* isolate, String inferred_name,
int start_position, int end_position) {
set_inferred_name(inferred_name);
set_start_position(start_position);
@ -638,8 +638,8 @@ void UncompiledData::InitAfterBytecodeFlush(
set_end_position(end_position);
}
template <typename Isolate>
void UncompiledDataWithPreparseData::Init(Isolate* isolate,
template <typename LocalIsolate>
void UncompiledDataWithPreparseData::Init(LocalIsolate* isolate,
String inferred_name,
int start_position, int end_position,
PreparseData scope_data) {

View File

@ -9,7 +9,6 @@
#include "src/base/bit-field.h"
#include "src/codegen/bailout-reason.h"
#include "src/handles/handle-for.h"
#include "src/objects/compressed-slots.h"
#include "src/objects/function-kind.h"
#include "src/objects/function-syntax-kind.h"
@ -100,9 +99,9 @@ class PreparseData
class UncompiledData
: public TorqueGeneratedUncompiledData<UncompiledData, HeapObject> {
public:
template <typename Isolate>
inline void Init(Isolate* isolate, String inferred_name, int start_position,
int end_position);
template <typename LocalIsolate>
inline void Init(LocalIsolate* isolate, String inferred_name,
int start_position, int end_position);
inline void InitAfterBytecodeFlush(
String inferred_name, int start_position, int end_position,
@ -139,9 +138,10 @@ class UncompiledDataWithPreparseData
public:
DECL_PRINTER(UncompiledDataWithPreparseData)
template <typename Isolate>
inline void Init(Isolate* isolate, String inferred_name, int start_position,
int end_position, PreparseData scope_data);
template <typename LocalIsolate>
inline void Init(LocalIsolate* isolate, String inferred_name,
int start_position, int end_position,
PreparseData scope_data);
using BodyDescriptor = SubclassBodyDescriptor<
UncompiledData::BodyDescriptor,
@ -554,10 +554,10 @@ class SharedFunctionInfo : public HeapObject {
inline bool has_simple_parameters();
// Initialize a SharedFunctionInfo from a parsed function literal.
template <typename Isolate>
static void InitFromFunctionLiteral(
Isolate* isolate, HandleFor<Isolate, SharedFunctionInfo> shared_info,
FunctionLiteral* lit, bool is_toplevel);
template <typename LocalIsolate>
static void InitFromFunctionLiteral(LocalIsolate* isolate,
Handle<SharedFunctionInfo> shared_info,
FunctionLiteral* lit, bool is_toplevel);
// Updates the expected number of properties based on estimate from parser.
void UpdateExpectedNofPropertiesFromEstimate(FunctionLiteral* literal);

View File

@ -197,9 +197,9 @@ class SourceTextModuleInfo : public FixedArray {
public:
DECL_CAST(SourceTextModuleInfo)
template <typename Isolate>
static HandleFor<Isolate, SourceTextModuleInfo> New(
Isolate* isolate, Zone* zone, SourceTextModuleDescriptor* descr);
template <typename LocalIsolate>
static Handle<SourceTextModuleInfo> New(LocalIsolate* isolate, Zone* zone,
SourceTextModuleDescriptor* descr);
inline FixedArray module_requests() const;
inline FixedArray special_exports() const;
@ -253,11 +253,11 @@ class SourceTextModuleInfoEntry
DECL_INT_ACCESSORS(beg_pos)
DECL_INT_ACCESSORS(end_pos)
template <typename Isolate>
static HandleFor<Isolate, SourceTextModuleInfoEntry> New(
Isolate* isolate, HandleFor<Isolate, PrimitiveHeapObject> export_name,
HandleFor<Isolate, PrimitiveHeapObject> local_name,
HandleFor<Isolate, PrimitiveHeapObject> import_name, int module_request,
template <typename LocalIsolate>
static Handle<SourceTextModuleInfoEntry> New(
LocalIsolate* isolate, Handle<PrimitiveHeapObject> export_name,
Handle<PrimitiveHeapObject> local_name,
Handle<PrimitiveHeapObject> import_name, int module_request,
int cell_index, int beg_pos, int end_pos);
TQ_OBJECT_CONSTRUCTORS(SourceTextModuleInfoEntry)

View File

@ -397,9 +397,8 @@ Handle<String> String::Flatten(Isolate* isolate, Handle<String> string,
return string;
}
OffThreadHandle<String> String::Flatten(OffThreadIsolate* isolate,
OffThreadHandle<String> string,
AllocationType allocation) {
Handle<String> String::Flatten(OffThreadIsolate* isolate, Handle<String> string,
AllocationType allocation) {
// We should never pass non-flat strings to String::Flatten when off-thread.
DCHECK(string->IsFlat());
return string;

View File

@ -709,10 +709,10 @@ static void CalculateLineEndsImpl(std::vector<int>* line_ends,
}
}
template <typename Isolate>
HandleFor<Isolate, FixedArray> String::CalculateLineEnds(
Isolate* isolate, HandleFor<Isolate, String> src,
bool include_ending_line) {
template <typename LocalIsolate>
Handle<FixedArray> String::CalculateLineEnds(LocalIsolate* isolate,
Handle<String> src,
bool include_ending_line) {
src = Flatten(isolate, src);
// Rough estimate of line count based on a roughly estimated average
// length of (unpacked) code.
@ -733,7 +733,7 @@ HandleFor<Isolate, FixedArray> String::CalculateLineEnds(
}
}
int line_count = static_cast<int>(line_ends.size());
HandleFor<Isolate, FixedArray> array =
Handle<FixedArray> array =
isolate->factory()->NewFixedArray(line_count, AllocationType::kOld);
for (int i = 0; i < line_count; i++) {
array->set(i, Smi::FromInt(line_ends[i]));
@ -744,9 +744,9 @@ HandleFor<Isolate, FixedArray> String::CalculateLineEnds(
template Handle<FixedArray> String::CalculateLineEnds(Isolate* isolate,
Handle<String> src,
bool include_ending_line);
template OffThreadHandle<FixedArray> String::CalculateLineEnds(
OffThreadIsolate* isolate, OffThreadHandle<String> src,
bool include_ending_line);
template Handle<FixedArray> String::CalculateLineEnds(OffThreadIsolate* isolate,
Handle<String> src,
bool include_ending_line);
bool String::SlowEquals(String other) {
DisallowHeapAllocation no_gc;

View File

@ -9,7 +9,6 @@
#include "src/base/bits.h"
#include "src/base/export-template.h"
#include "src/handles/handle-for.h"
#include "src/objects/instance-type.h"
#include "src/objects/name.h"
#include "src/objects/smi.h"
@ -204,8 +203,8 @@ class String : public TorqueGeneratedString<String, Name> {
static inline Handle<String> Flatten(
Isolate* isolate, Handle<String> string,
AllocationType allocation = AllocationType::kYoung);
static inline OffThreadHandle<String> Flatten(
OffThreadIsolate* isolate, OffThreadHandle<String> string,
static inline Handle<String> Flatten(
OffThreadIsolate* isolate, Handle<String> string,
AllocationType allocation = AllocationType::kYoung);
// Tries to return the content of a flat string as a structure holding either
@ -458,10 +457,10 @@ class String : public TorqueGeneratedString<String, Name> {
static inline ConsString VisitFlat(Visitor* visitor, String string,
int offset = 0);
template <typename Isolate>
static HandleFor<Isolate, FixedArray> CalculateLineEnds(
Isolate* isolate, HandleFor<Isolate, String> string,
bool include_ending_line);
template <typename LocalIsolate>
static Handle<FixedArray> CalculateLineEnds(LocalIsolate* isolate,
Handle<String> string,
bool include_ending_line);
private:
friend class Name;

View File

@ -124,7 +124,7 @@ class FunctionTemplateInfo
Isolate* isolate, Handle<FunctionTemplateInfo> info,
MaybeHandle<Name> maybe_name);
static OffThreadHandle<SharedFunctionInfo> GetOrCreateSharedFunctionInfo(
static Handle<SharedFunctionInfo> GetOrCreateSharedFunctionInfo(
OffThreadIsolate* isolate, Handle<FunctionTemplateInfo> info,
Handle<Name> maybe_name) {
// We don't support streaming compilation of scripts with natives, so we

View File

@ -164,13 +164,14 @@ ParseInfo::~ParseInfo() = default;
DeclarationScope* ParseInfo::scope() const { return literal()->scope(); }
template <typename Isolate>
HandleFor<Isolate, Script> ParseInfo::CreateScript(
Isolate* isolate, HandleFor<Isolate, String> source,
ScriptOriginOptions origin_options, REPLMode repl_mode,
NativesFlag natives) {
template <typename LocalIsolate>
Handle<Script> ParseInfo::CreateScript(LocalIsolate* isolate,
Handle<String> source,
ScriptOriginOptions origin_options,
REPLMode repl_mode,
NativesFlag natives) {
// Create a script object describing the script to be compiled.
HandleFor<Isolate, Script> script;
Handle<Script> script;
if (script_id_ == -1) {
script = isolate->factory()->NewScript(source);
} else {
@ -204,10 +205,11 @@ template EXPORT_TEMPLATE_DEFINE(V8_EXPORT_PRIVATE)
REPLMode repl_mode,
NativesFlag natives);
template EXPORT_TEMPLATE_DEFINE(V8_EXPORT_PRIVATE)
OffThreadHandle<Script> ParseInfo::CreateScript(
OffThreadIsolate* isolate, OffThreadHandle<String> source,
ScriptOriginOptions origin_options, REPLMode repl_mode,
NativesFlag natives);
Handle<Script> ParseInfo::CreateScript(OffThreadIsolate* isolate,
Handle<String> source,
ScriptOriginOptions origin_options,
REPLMode repl_mode,
NativesFlag natives);
AstValueFactory* ParseInfo::GetOrCreateAstValueFactory() {
if (!ast_value_factory_.get()) {
@ -230,9 +232,9 @@ void ParseInfo::set_character_stream(
character_stream_.swap(character_stream);
}
template <typename Isolate>
template <typename LocalIsolate>
void ParseInfo::SetFlagsForToplevelCompileFromScript(
Isolate* isolate, Script script, bool is_collecting_type_profile) {
LocalIsolate* isolate, Script script, bool is_collecting_type_profile) {
SetFlagsFromScript(isolate, script);
set_allow_lazy_parsing();
set_toplevel();
@ -244,8 +246,8 @@ void ParseInfo::SetFlagsForToplevelCompileFromScript(
}
}
template <typename Isolate>
void ParseInfo::SetFlagsFromScript(Isolate* isolate, Script script) {
template <typename LocalIsolate>
void ParseInfo::SetFlagsFromScript(LocalIsolate* isolate, Script script) {
DCHECK(script_id_ == -1 || script_id_ == script.id());
script_id_ = script.id();
@ -259,10 +261,10 @@ void ParseInfo::SetFlagsFromScript(Isolate* isolate, Script script) {
if (script.is_wrapped()) {
// This should only ever happen on the main thread. Convert this templated
// handle into a real Handle via HandleOrOffThreadHandle to avoid having to
// handle into a real Handle via Handle to avoid having to
// use template specialization for this.
DCHECK((std::is_same<Isolate, v8::internal::Isolate>::value));
HandleOrOffThreadHandle<FixedArray> wrapped_arguments_handle =
Handle<FixedArray> wrapped_arguments_handle =
handle(script.wrapped_arguments(), isolate);
set_wrapped_arguments(wrapped_arguments_handle);
}

View File

@ -55,12 +55,12 @@ class V8_EXPORT_PRIVATE ParseInfo {
~ParseInfo();
template <typename Isolate>
template <typename LocalIsolate>
EXPORT_TEMPLATE_DECLARE(V8_EXPORT_PRIVATE)
HandleFor<Isolate, Script> CreateScript(
Isolate* isolate, HandleFor<Isolate, String> source,
ScriptOriginOptions origin_options, REPLMode repl_mode = REPLMode::kNo,
NativesFlag natives = NOT_NATIVES_CODE);
Handle<Script> CreateScript(LocalIsolate* isolate, Handle<String> source,
ScriptOriginOptions origin_options,
REPLMode repl_mode = REPLMode::kNo,
NativesFlag natives = NOT_NATIVES_CODE);
// Either returns the ast-value-factory associcated with this ParseInfo, or
// creates and returns a new factory if none exists.
@ -259,8 +259,8 @@ class V8_EXPORT_PRIVATE ParseInfo {
ParallelTasks* parallel_tasks() { return parallel_tasks_.get(); }
template <typename Isolate>
void SetFlagsFromScript(Isolate* isolate, Script script);
template <typename LocalIsolate>
void SetFlagsFromScript(LocalIsolate* isolate, Script script);
//--------------------------------------------------------------------------
// TODO(titzer): these should not be part of ParseInfo.
@ -289,8 +289,9 @@ class V8_EXPORT_PRIVATE ParseInfo {
}
private:
template <typename Isolate>
void SetFlagsForToplevelCompileFromScript(Isolate* isolate, Script script,
template <typename LocalIsolate>
void SetFlagsForToplevelCompileFromScript(LocalIsolate* isolate,
Script script,
bool is_collecting_type_profile);
// Set function info flags based on those in either FunctionLiteral or

View File

@ -199,7 +199,7 @@ class ZonePreparseData : public ZoneObject {
int child_length);
Handle<PreparseData> Serialize(Isolate* isolate);
OffThreadHandle<PreparseData> Serialize(OffThreadIsolate* isolate);
Handle<PreparseData> Serialize(OffThreadIsolate* isolate);
int children_length() const { return static_cast<int>(children_.size()); }

View File

@ -433,12 +433,11 @@ Handle<PreparseData> PreparseDataBuilder::ByteData::CopyToHeap(
return data;
}
OffThreadHandle<PreparseData>
PreparseDataBuilder::ByteData::CopyToOffThreadHeap(OffThreadIsolate* isolate,
int children_length) {
Handle<PreparseData> PreparseDataBuilder::ByteData::CopyToOffThreadHeap(
OffThreadIsolate* isolate, int children_length) {
DCHECK(is_finalized_);
int data_length = zone_byte_data_.length();
OffThreadHandle<PreparseData> data =
Handle<PreparseData> data =
isolate->factory()->NewPreparseData(data_length, children_length);
data->copy_in(0, zone_byte_data_.begin(), data_length);
return data;
@ -460,17 +459,16 @@ Handle<PreparseData> PreparseDataBuilder::Serialize(Isolate* isolate) {
return data;
}
OffThreadHandle<PreparseData> PreparseDataBuilder::Serialize(
OffThreadIsolate* isolate) {
Handle<PreparseData> PreparseDataBuilder::Serialize(OffThreadIsolate* isolate) {
DCHECK(HasData());
DCHECK(!ThisOrParentBailedOut());
OffThreadHandle<PreparseData> data =
Handle<PreparseData> data =
byte_data_.CopyToOffThreadHeap(isolate, num_inner_with_data_);
int i = 0;
DCHECK(finalized_children_);
for (const auto& builder : children_) {
if (!builder->HasData()) continue;
OffThreadHandle<PreparseData> child_data = builder->Serialize(isolate);
Handle<PreparseData> child_data = builder->Serialize(isolate);
data->set_child(i++, *child_data);
}
DCHECK_EQ(i, data->children_length());
@ -503,7 +501,7 @@ class BuilderProducedPreparseData final : public ProducedPreparseData {
return builder_->Serialize(isolate);
}
OffThreadHandle<PreparseData> Serialize(OffThreadIsolate* isolate) final {
Handle<PreparseData> Serialize(OffThreadIsolate* isolate) final {
return builder_->Serialize(isolate);
}
@ -525,7 +523,7 @@ class OnHeapProducedPreparseData final : public ProducedPreparseData {
return data_;
}
OffThreadHandle<PreparseData> Serialize(OffThreadIsolate* isolate) final {
Handle<PreparseData> Serialize(OffThreadIsolate* isolate) final {
// Not required.
UNREACHABLE();
}
@ -547,7 +545,7 @@ class ZoneProducedPreparseData final : public ProducedPreparseData {
return data_->Serialize(isolate);
}
OffThreadHandle<PreparseData> Serialize(OffThreadIsolate* isolate) final {
Handle<PreparseData> Serialize(OffThreadIsolate* isolate) final {
return data_->Serialize(isolate);
}
@ -793,18 +791,17 @@ Handle<PreparseData> ZonePreparseData::Serialize(Isolate* isolate) {
return result;
}
OffThreadHandle<PreparseData> ZonePreparseData::Serialize(
OffThreadIsolate* isolate) {
Handle<PreparseData> ZonePreparseData::Serialize(OffThreadIsolate* isolate) {
int data_size = static_cast<int>(byte_data()->size());
int child_data_length = children_length();
OffThreadHandle<PreparseData> result =
Handle<PreparseData> result =
isolate->factory()->NewPreparseData(data_size, child_data_length);
result->copy_in(0, byte_data()->data(), data_size);
for (int i = 0; i < child_data_length; i++) {
ZonePreparseData* child = get_child(i);
DCHECK_NOT_NULL(child);
OffThreadHandle<PreparseData> child_data = child->Serialize(isolate);
Handle<PreparseData> child_data = child->Serialize(isolate);
result->set_child(i, *child_data);
}
return result;

View File

@ -140,8 +140,8 @@ class V8_EXPORT_PRIVATE PreparseDataBuilder : public ZoneObject,
void Finalize(Zone* zone);
Handle<PreparseData> CopyToHeap(Isolate* isolate, int children_length);
OffThreadHandle<PreparseData> CopyToOffThreadHeap(OffThreadIsolate* isolate,
int children_length);
Handle<PreparseData> CopyToOffThreadHeap(OffThreadIsolate* isolate,
int children_length);
inline ZonePreparseData* CopyToZone(Zone* zone, int children_length);
void Reserve(size_t bytes);
@ -210,7 +210,7 @@ class V8_EXPORT_PRIVATE PreparseDataBuilder : public ZoneObject,
friend class BuilderProducedPreparseData;
Handle<PreparseData> Serialize(Isolate* isolate);
OffThreadHandle<PreparseData> Serialize(OffThreadIsolate* isolate);
Handle<PreparseData> Serialize(OffThreadIsolate* isolate);
ZonePreparseData* Serialize(Zone* zone);
void FinalizeChildren(Zone* zone);
@ -256,8 +256,7 @@ class ProducedPreparseData : public ZoneObject {
// If there is data (if the Scope contains skippable inner functions), move
// the data into the heap and return a Handle to it; otherwise return a null
// MaybeHandle.
virtual OffThreadHandle<PreparseData> Serialize(
OffThreadIsolate* isolate) = 0;
virtual Handle<PreparseData> Serialize(OffThreadIsolate* isolate) = 0;
// If there is data (if the Scope contains skippable inner functions), return
// an off-heap ZonePreparseData representing the data; otherwise

View File

@ -195,8 +195,7 @@ TEST(InterpreterLoadLiteral) {
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<Isolate>()));
CHECK(i::String::cast(*return_val).Equals(*raw_string->string()));
}
}

View File

@ -55,8 +55,8 @@ class OffThreadFactoryTest : public TestWithIsolateAndZone {
public:
OffThreadFactoryTest()
: TestWithIsolateAndZone(),
off_thread_isolate_(isolate()),
parse_info_(isolate()) {}
parse_info_(isolate()),
off_thread_isolate_(isolate(), parse_info_.zone()) {}
FunctionLiteral* ParseProgram(const char* source) {
auto utf16_source = DecodeUtf8(source);
@ -91,9 +91,8 @@ class OffThreadFactoryTest : public TestWithIsolateAndZone {
ScriptOriginOptions());
// Create the SFI list on the script so that SFI SetScript works.
OffThreadHandle<WeakFixedArray> infos =
off_thread_factory()->NewWeakFixedArray(
parse_info()->max_function_literal_id() + 1, AllocationType::kOld);
Handle<WeakFixedArray> infos = off_thread_factory()->NewWeakFixedArray(
parse_info()->max_function_literal_id() + 1, AllocationType::kOld);
script_->set_shared_function_infos(*infos);
return parse_info()->literal();
@ -101,7 +100,7 @@ class OffThreadFactoryTest : public TestWithIsolateAndZone {
ParseInfo* parse_info() { return &parse_info_; }
OffThreadHandle<Script> script() { return script_; }
Handle<Script> script() { return script_; }
OffThreadIsolate* off_thread_isolate() { return &off_thread_isolate_; }
OffThreadFactory* off_thread_factory() {
@ -110,49 +109,38 @@ class OffThreadFactoryTest : public TestWithIsolateAndZone {
// We only internalize strings which are referred to in other slots, so create
// a wrapper pointing at the off_thread_string.
OffThreadHandle<FixedArray> WrapString(OffThreadHandle<String> string) {
Handle<FixedArray> WrapString(Handle<String> string) {
// TODO(leszeks): Replace with a different factory method (e.g. FixedArray)
// once OffThreadFactory supports it.
return off_thread_factory()->StringWrapperForTest(string);
}
private:
OffThreadIsolate off_thread_isolate_;
ParseInfo parse_info_;
OffThreadIsolate off_thread_isolate_;
Handle<String> source_string_;
OffThreadHandle<Script> script_;
Handle<Script> script_;
};
TEST_F(OffThreadFactoryTest, HandleOrOffThreadHandle_IsNullWhenConstructed) {
// Default constructed HandleOrOffThreadHandles should be considered both null
// and uninitialized.
EXPECT_TRUE(HandleOrOffThreadHandle<HeapObject>().is_null());
#ifdef DEBUG
EXPECT_TRUE(!HandleOrOffThreadHandle<HeapObject>().is_initialized());
#endif
// Default constructed HandleOrOffThreadHandles should work as both null
// handles and null off-thread handles.
EXPECT_TRUE(HandleOrOffThreadHandle<HeapObject>().get<Isolate>().is_null());
EXPECT_TRUE(
HandleOrOffThreadHandle<HeapObject>().get<OffThreadIsolate>().is_null());
}
TEST_F(OffThreadFactoryTest, OneByteInternalizedString_IsAddedToStringTable) {
Vector<const uint8_t> string_vector = StaticCharVector("foo");
uint32_t hash_field = StringHasher::HashSequentialString<uint8_t>(
string_vector.begin(), string_vector.length(), HashSeed(isolate()));
OffThreadHandle<String> off_thread_string =
off_thread_factory()->NewOneByteInternalizedString(string_vector,
hash_field);
FixedArray off_thread_wrapper;
{
OffThreadHandleScope handle_scope(off_thread_isolate());
OffThreadHandle<FixedArray> off_thread_wrapper =
off_thread_factory()->StringWrapperForTest(off_thread_string);
Handle<String> off_thread_string =
off_thread_factory()->NewOneByteInternalizedString(string_vector,
hash_field);
off_thread_factory()->FinishOffThread();
off_thread_wrapper =
*off_thread_factory()->StringWrapperForTest(off_thread_string);
off_thread_factory()->FinishOffThread();
}
Handle<FixedArray> wrapper = handle(*off_thread_wrapper, isolate());
Handle<FixedArray> wrapper = handle(off_thread_wrapper, isolate());
off_thread_factory()->Publish(isolate());
Handle<String> string = handle(String::cast(wrapper->get(0)), isolate());
@ -178,22 +166,25 @@ TEST_F(OffThreadFactoryTest,
uint32_t hash_field = StringHasher::HashSequentialString<uint8_t>(
string_vector.begin(), string_vector.length(), HashSeed(isolate()));
OffThreadHandle<String> off_thread_string_1 =
off_thread_factory()->NewOneByteInternalizedString(string_vector,
hash_field);
OffThreadHandle<String> off_thread_string_2 =
off_thread_factory()->NewOneByteInternalizedString(string_vector,
hash_field);
FixedArray off_thread_wrapper_1;
FixedArray off_thread_wrapper_2;
{
OffThreadHandleScope handle_scope(off_thread_isolate());
OffThreadHandle<FixedArray> off_thread_wrapper_1 =
WrapString(off_thread_string_1);
OffThreadHandle<FixedArray> off_thread_wrapper_2 =
WrapString(off_thread_string_2);
Handle<String> off_thread_string_1 =
off_thread_factory()->NewOneByteInternalizedString(string_vector,
hash_field);
Handle<String> off_thread_string_2 =
off_thread_factory()->NewOneByteInternalizedString(string_vector,
hash_field);
off_thread_factory()->FinishOffThread();
off_thread_wrapper_1 = *WrapString(off_thread_string_1);
off_thread_wrapper_2 = *WrapString(off_thread_string_2);
off_thread_factory()->FinishOffThread();
}
Handle<FixedArray> wrapper_1 = handle(*off_thread_wrapper_1, isolate());
Handle<FixedArray> wrapper_2 = handle(*off_thread_wrapper_2, isolate());
Handle<FixedArray> wrapper_1 = handle(off_thread_wrapper_1, isolate());
Handle<FixedArray> wrapper_2 = handle(off_thread_wrapper_2, isolate());
off_thread_factory()->Publish(isolate());
Handle<String> string_1 = handle(String::cast(wrapper_1->get(0)), isolate());
@ -210,14 +201,17 @@ TEST_F(OffThreadFactoryTest, AstRawString_IsInternalized) {
const AstRawString* raw_string = ast_value_factory.GetOneByteString("foo");
ast_value_factory.Internalize(off_thread_isolate());
FixedArray off_thread_wrapper;
{
OffThreadHandleScope handle_scope(off_thread_isolate());
OffThreadHandle<FixedArray> off_thread_wrapper =
WrapString(raw_string->string().get<OffThreadIsolate>());
ast_value_factory.Internalize(off_thread_isolate());
off_thread_factory()->FinishOffThread();
off_thread_wrapper = *WrapString(raw_string->string());
off_thread_factory()->FinishOffThread();
}
Handle<FixedArray> wrapper = handle(*off_thread_wrapper, isolate());
Handle<FixedArray> wrapper = handle(off_thread_wrapper, isolate());
off_thread_factory()->Publish(isolate());
Handle<String> string = handle(String::cast(wrapper->get(0)), isolate());
@ -230,20 +224,24 @@ TEST_F(OffThreadFactoryTest, AstConsString_CreatesConsString) {
AstValueFactory ast_value_factory(zone(), isolate()->ast_string_constants(),
HashSeed(isolate()));
const AstRawString* foo_string = ast_value_factory.GetOneByteString("foo");
const AstRawString* bar_string =
ast_value_factory.GetOneByteString("bar-plus-padding-for-length");
AstConsString* foobar_string =
ast_value_factory.NewConsString(foo_string, bar_string);
FixedArray off_thread_wrapper;
{
OffThreadHandleScope handle_scope(off_thread_isolate());
ast_value_factory.Internalize(off_thread_isolate());
const AstRawString* foo_string = ast_value_factory.GetOneByteString("foo");
const AstRawString* bar_string =
ast_value_factory.GetOneByteString("bar-plus-padding-for-length");
AstConsString* foobar_string =
ast_value_factory.NewConsString(foo_string, bar_string);
OffThreadHandle<FixedArray> off_thread_wrapper =
WrapString(foobar_string->GetString(off_thread_isolate()));
ast_value_factory.Internalize(off_thread_isolate());
off_thread_factory()->FinishOffThread();
off_thread_wrapper =
*WrapString(foobar_string->GetString(off_thread_isolate()));
off_thread_factory()->FinishOffThread();
}
Handle<FixedArray> wrapper = handle(*off_thread_wrapper, isolate());
Handle<FixedArray> wrapper = handle(off_thread_wrapper, isolate());
off_thread_factory()->Publish(isolate());
Handle<String> string = handle(String::cast(wrapper->get(0)), isolate());
@ -256,11 +254,15 @@ TEST_F(OffThreadFactoryTest, AstConsString_CreatesConsString) {
TEST_F(OffThreadFactoryTest, EmptyScript) {
FunctionLiteral* program = ParseProgram("");
SharedFunctionInfo shared =
*off_thread_factory()->NewSharedFunctionInfoForLiteral(program, script(),
true);
SharedFunctionInfo shared;
{
OffThreadHandleScope handle_scope(off_thread_isolate());
off_thread_factory()->FinishOffThread();
shared = *off_thread_factory()->NewSharedFunctionInfoForLiteral(
program, script(), true);
off_thread_factory()->FinishOffThread();
}
Handle<SharedFunctionInfo> root_sfi = handle(shared, isolate());
off_thread_factory()->Publish(isolate());
@ -276,11 +278,15 @@ TEST_F(OffThreadFactoryTest, LazyFunction) {
->AsFunctionDeclaration()
->fun();
SharedFunctionInfo shared =
*off_thread_factory()->NewSharedFunctionInfoForLiteral(lazy, script(),
true);
SharedFunctionInfo shared;
{
OffThreadHandleScope handle_scope(off_thread_isolate());
off_thread_factory()->FinishOffThread();
shared = *off_thread_factory()->NewSharedFunctionInfoForLiteral(
lazy, script(), true);
off_thread_factory()->FinishOffThread();
}
Handle<SharedFunctionInfo> lazy_sfi = handle(shared, isolate());
off_thread_factory()->Publish(isolate());
@ -299,11 +305,15 @@ TEST_F(OffThreadFactoryTest, EagerFunction) {
->expression()
->AsFunctionLiteral();
SharedFunctionInfo shared =
*off_thread_factory()->NewSharedFunctionInfoForLiteral(eager, script(),
true);
SharedFunctionInfo shared;
{
OffThreadHandleScope handle_scope(off_thread_isolate());
off_thread_factory()->FinishOffThread();
shared = *off_thread_factory()->NewSharedFunctionInfoForLiteral(
eager, script(), true);
off_thread_factory()->FinishOffThread();
}
Handle<SharedFunctionInfo> eager_sfi = handle(shared, isolate());
off_thread_factory()->Publish(isolate());
@ -329,11 +339,15 @@ TEST_F(OffThreadFactoryTest, ImplicitNameFunction) {
->value()
->AsFunctionLiteral();
SharedFunctionInfo shared =
*off_thread_factory()->NewSharedFunctionInfoForLiteral(implicit_name,
script(), true);
SharedFunctionInfo shared;
{
OffThreadHandleScope handle_scope(off_thread_isolate());
off_thread_factory()->FinishOffThread();
shared = *off_thread_factory()->NewSharedFunctionInfoForLiteral(
implicit_name, script(), true);
off_thread_factory()->FinishOffThread();
}
Handle<SharedFunctionInfo> implicit_name_sfi = handle(shared, isolate());
off_thread_factory()->Publish(isolate());