diff options
author | Sergio Ahumada <sergio.ahumada@digia.com> | 2013-03-19 09:25:14 +0100 |
---|---|---|
committer | Sergio Ahumada <sergio.ahumada@digia.com> | 2013-03-19 09:56:31 +0100 |
commit | 6313e1fe4c27755adde87e62db1c2f9fac534ae4 (patch) | |
tree | c57bb29f65e02fbfcc07895a8cc2903fff9300ba /src/3rdparty/v8/src/ast.cc | |
parent | b5a49a260d03249c386f1b63c249089383dd81fa (diff) | |
parent | cac65e7a222b848a735a974b0aeb43209b0cfa18 (diff) | |
download | qtjsbackend-6313e1fe4c27755adde87e62db1c2f9fac534ae4.tar.gz |
Merge branch 'dev' into stable
This starts Qt 5.1 release cycle
Change-Id: I892bbc73c276842894a720f761ce31ad1b015672
Diffstat (limited to 'src/3rdparty/v8/src/ast.cc')
-rw-r--r-- | src/3rdparty/v8/src/ast.cc | 110 |
1 files changed, 68 insertions, 42 deletions
diff --git a/src/3rdparty/v8/src/ast.cc b/src/3rdparty/v8/src/ast.cc index a02cede..3015b1e 100644 --- a/src/3rdparty/v8/src/ast.cc +++ b/src/3rdparty/v8/src/ast.cc @@ -85,8 +85,8 @@ VariableProxy::VariableProxy(Isolate* isolate, Variable* var) VariableProxy::VariableProxy(Isolate* isolate, Handle<String> name, bool is_this, - int position, - Interface* interface) + Interface* interface, + int position) : Expression(isolate), name_(name), var_(NULL), @@ -125,10 +125,7 @@ Assignment::Assignment(Isolate* isolate, value_(value), pos_(pos), binary_operation_(NULL), - compound_load_id_(kNoNumber), assignment_id_(GetNextId(isolate)), - block_start_(false), - block_end_(false), is_monomorphic_(false) { } @@ -156,6 +153,11 @@ bool FunctionLiteral::AllowsLazyCompilation() { } +bool FunctionLiteral::AllowsLazyCompilationWithoutContext() { + return scope()->AllowsLazyCompilationWithoutContext(); +} + + int FunctionLiteral::start_position() const { return scope()->start_position(); } @@ -247,8 +249,11 @@ bool IsEqualNumber(void* first, void* second) { } -void ObjectLiteral::CalculateEmitStore() { - ZoneHashMap table(Literal::Match); +void ObjectLiteral::CalculateEmitStore(Zone* zone) { + ZoneAllocationPolicy allocator(zone); + + ZoneHashMap table(Literal::Match, ZoneHashMap::kDefaultHashMapCapacity, + allocator); for (int i = properties()->length() - 1; i >= 0; i--) { ObjectLiteral::Property* property = properties()->at(i); Literal* literal = property->key(); @@ -257,23 +262,23 @@ void ObjectLiteral::CalculateEmitStore() { // If the key of a computed property is in the table, do not emit // a store for the property later. if (property->kind() == ObjectLiteral::Property::COMPUTED && - table.Lookup(literal, hash, false) != NULL) { + table.Lookup(literal, hash, false, allocator) != NULL) { property->set_emit_store(false); } else { // Add key to the table. - table.Lookup(literal, hash, true); + table.Lookup(literal, hash, true, allocator); } } } -void TargetCollector::AddTarget(Label* target) { +void TargetCollector::AddTarget(Label* target, Zone* zone) { // Add the label to the collector, but discard duplicates. int length = targets_.length(); for (int i = 0; i < length; i++) { if (targets_[i] == target) return; } - targets_.Add(target); + targets_.Add(target, zone); } @@ -402,7 +407,8 @@ bool FunctionDeclaration::IsInlineable() const { // ---------------------------------------------------------------------------- // Recording of type feedback -void Property::RecordTypeFeedback(TypeFeedbackOracle* oracle) { +void Property::RecordTypeFeedback(TypeFeedbackOracle* oracle, + Zone* zone) { // Record type feedback from the oracle in the AST. is_uninitialized_ = oracle->LoadIsUninitialized(this); if (is_uninitialized_) return; @@ -426,18 +432,21 @@ void Property::RecordTypeFeedback(TypeFeedbackOracle* oracle) { } else if (oracle->LoadIsBuiltin(this, Builtins::kKeyedLoadIC_String)) { is_string_access_ = true; } else if (is_monomorphic_) { - receiver_types_.Add(oracle->LoadMonomorphicReceiverType(this)); + receiver_types_.Add(oracle->LoadMonomorphicReceiverType(this), + zone); } else if (oracle->LoadIsMegamorphicWithTypeInfo(this)) { - receiver_types_.Reserve(kMaxKeyedPolymorphism); - oracle->CollectKeyedReceiverTypes(this->id(), &receiver_types_); + receiver_types_.Reserve(kMaxKeyedPolymorphism, zone); + oracle->CollectKeyedReceiverTypes(PropertyFeedbackId(), &receiver_types_); } } -void Assignment::RecordTypeFeedback(TypeFeedbackOracle* oracle) { +void Assignment::RecordTypeFeedback(TypeFeedbackOracle* oracle, + Zone* zone) { Property* prop = target()->AsProperty(); ASSERT(prop != NULL); - is_monomorphic_ = oracle->StoreIsMonomorphicNormal(this); + TypeFeedbackId id = AssignmentFeedbackId(); + is_monomorphic_ = oracle->StoreIsMonomorphicNormal(id); receiver_types_.Clear(); if (prop->key()->IsPropertyName()) { Literal* lit_key = prop->key()->AsLiteral(); @@ -446,23 +455,26 @@ void Assignment::RecordTypeFeedback(TypeFeedbackOracle* oracle) { oracle->StoreReceiverTypes(this, name, &receiver_types_); } else if (is_monomorphic_) { // Record receiver type for monomorphic keyed stores. - receiver_types_.Add(oracle->StoreMonomorphicReceiverType(this)); - } else if (oracle->StoreIsMegamorphicWithTypeInfo(this)) { - receiver_types_.Reserve(kMaxKeyedPolymorphism); - oracle->CollectKeyedReceiverTypes(this->id(), &receiver_types_); + receiver_types_.Add(oracle->StoreMonomorphicReceiverType(id), zone); + } else if (oracle->StoreIsMegamorphicWithTypeInfo(id)) { + receiver_types_.Reserve(kMaxKeyedPolymorphism, zone); + oracle->CollectKeyedReceiverTypes(id, &receiver_types_); } } -void CountOperation::RecordTypeFeedback(TypeFeedbackOracle* oracle) { - is_monomorphic_ = oracle->StoreIsMonomorphicNormal(this); +void CountOperation::RecordTypeFeedback(TypeFeedbackOracle* oracle, + Zone* zone) { + TypeFeedbackId id = CountStoreFeedbackId(); + is_monomorphic_ = oracle->StoreIsMonomorphicNormal(id); receiver_types_.Clear(); if (is_monomorphic_) { // Record receiver type for monomorphic keyed stores. - receiver_types_.Add(oracle->StoreMonomorphicReceiverType(this)); - } else if (oracle->StoreIsMegamorphicWithTypeInfo(this)) { - receiver_types_.Reserve(kMaxKeyedPolymorphism); - oracle->CollectKeyedReceiverTypes(this->id(), &receiver_types_); + receiver_types_.Add( + oracle->StoreMonomorphicReceiverType(id), zone); + } else if (oracle->StoreIsMegamorphicWithTypeInfo(id)) { + receiver_types_.Reserve(kMaxKeyedPolymorphism, zone); + oracle->CollectKeyedReceiverTypes(id, &receiver_types_); } } @@ -496,7 +508,7 @@ bool Call::ComputeTarget(Handle<Map> type, Handle<String> name) { } LookupResult lookup(type->GetIsolate()); while (true) { - type->LookupInDescriptors(NULL, *name, &lookup); + type->LookupDescriptor(NULL, *name, &lookup); if (lookup.IsFound()) { switch (lookup.type()) { case CONSTANT_FUNCTION: @@ -511,11 +523,9 @@ bool Call::ComputeTarget(Handle<Map> type, Handle<String> name) { case INTERCEPTOR: // We don't know the target. return false; - case MAP_TRANSITION: - case ELEMENTS_TRANSITION: - case CONSTANT_TRANSITION: - case NULL_DESCRIPTOR: - // Perhaps something interesting is up in the prototype chain... + case TRANSITION: + case NONEXISTENT: + UNREACHABLE(); break; } } @@ -523,6 +533,7 @@ bool Call::ComputeTarget(Handle<Map> type, Handle<String> name) { if (!type->prototype()->IsJSObject()) return false; // Go up the prototype chain, recording where we are currently. holder_ = Handle<JSObject>(JSObject::cast(type->prototype())); + if (!holder_->HasFastProperties()) return false; type = Handle<Map>(holder()->map()); } } @@ -794,7 +805,7 @@ bool RegExpCapture::IsAnchoredAtEnd() { // output formats are alike. class RegExpUnparser: public RegExpVisitor { public: - RegExpUnparser(); + explicit RegExpUnparser(Zone* zone); void VisitCharacterRange(CharacterRange that); SmartArrayPointer<const char> ToString() { return stream_.ToCString(); } #define MAKE_CASE(Name) virtual void* Visit##Name(RegExp##Name*, void* data); @@ -804,10 +815,11 @@ class RegExpUnparser: public RegExpVisitor { StringStream* stream() { return &stream_; } HeapStringAllocator alloc_; StringStream stream_; + Zone* zone_; }; -RegExpUnparser::RegExpUnparser() : stream_(&alloc_) { +RegExpUnparser::RegExpUnparser(Zone* zone) : stream_(&alloc_), zone_(zone) { } @@ -847,9 +859,9 @@ void* RegExpUnparser::VisitCharacterClass(RegExpCharacterClass* that, if (that->is_negated()) stream()->Add("^"); stream()->Add("["); - for (int i = 0; i < that->ranges()->length(); i++) { + for (int i = 0; i < that->ranges(zone_)->length(); i++) { if (i > 0) stream()->Add(" "); - VisitCharacterRange(that->ranges()->at(i)); + VisitCharacterRange(that->ranges(zone_)->at(i)); } stream()->Add("]"); return NULL; @@ -951,8 +963,8 @@ void* RegExpUnparser::VisitEmpty(RegExpEmpty* that, void* data) { } -SmartArrayPointer<const char> RegExpTree::ToString() { - RegExpUnparser unparser; +SmartArrayPointer<const char> RegExpTree::ToString(Zone* zone) { + RegExpUnparser unparser(zone); Accept(&unparser, NULL); return unparser.ToString(); } @@ -1029,6 +1041,14 @@ CaseClause::CaseClause(Isolate* isolate, increase_node_count(); \ add_flag(kDontSelfOptimize); \ } +#define DONT_CACHE_NODE(NodeType) \ + void AstConstructionVisitor::Visit##NodeType(NodeType* node) { \ + increase_node_count(); \ + add_flag(kDontOptimize); \ + add_flag(kDontInline); \ + add_flag(kDontSelfOptimize); \ + add_flag(kDontCache); \ + } REGULAR_NODE(VariableDeclaration) REGULAR_NODE(FunctionDeclaration) @@ -1043,6 +1063,7 @@ REGULAR_NODE(SwitchStatement) REGULAR_NODE(Conditional) REGULAR_NODE(Literal) REGULAR_NODE(ObjectLiteral) +REGULAR_NODE(RegExpLiteral) REGULAR_NODE(Assignment) REGULAR_NODE(Throw) REGULAR_NODE(Property) @@ -1059,10 +1080,13 @@ REGULAR_NODE(CallNew) // LOOKUP variables only result from constructs that cannot be inlined anyway. REGULAR_NODE(VariableProxy) +// We currently do not optimize any modules. Note in particular, that module +// instance objects associated with ModuleLiterals are allocated during +// scope resolution, and references to them are embedded into the code. +// That code may hence neither be cached nor re-compiled. DONT_OPTIMIZE_NODE(ModuleDeclaration) DONT_OPTIMIZE_NODE(ImportDeclaration) DONT_OPTIMIZE_NODE(ExportDeclaration) -DONT_OPTIMIZE_NODE(ModuleLiteral) DONT_OPTIMIZE_NODE(ModuleVariable) DONT_OPTIMIZE_NODE(ModulePath) DONT_OPTIMIZE_NODE(ModuleUrl) @@ -1072,15 +1096,16 @@ DONT_OPTIMIZE_NODE(TryFinallyStatement) DONT_OPTIMIZE_NODE(DebuggerStatement) DONT_OPTIMIZE_NODE(SharedFunctionInfoLiteral) -DONT_INLINE_NODE(FunctionLiteral) -DONT_INLINE_NODE(RegExpLiteral) // TODO(1322): Allow materialized literals. DONT_INLINE_NODE(ArrayLiteral) // TODO(1322): Allow materialized literals. +DONT_INLINE_NODE(FunctionLiteral) DONT_SELFOPTIMIZE_NODE(DoWhileStatement) DONT_SELFOPTIMIZE_NODE(WhileStatement) DONT_SELFOPTIMIZE_NODE(ForStatement) DONT_SELFOPTIMIZE_NODE(ForInStatement) +DONT_CACHE_NODE(ModuleLiteral) + void AstConstructionVisitor::VisitCallRuntime(CallRuntime* node) { increase_node_count(); if (node->is_jsruntime()) { @@ -1101,6 +1126,7 @@ void AstConstructionVisitor::VisitCallRuntime(CallRuntime* node) { #undef DONT_OPTIMIZE_NODE #undef DONT_INLINE_NODE #undef DONT_SELFOPTIMIZE_NODE +#undef DONT_CACHE_NODE Handle<String> Literal::ToString() { |