diff options
Diffstat (limited to 'deps/v8/src/ia32/full-codegen-ia32.cc')
-rw-r--r-- | deps/v8/src/ia32/full-codegen-ia32.cc | 59 |
1 files changed, 44 insertions, 15 deletions
diff --git a/deps/v8/src/ia32/full-codegen-ia32.cc b/deps/v8/src/ia32/full-codegen-ia32.cc index b42ce95f8d..62a2c2af33 100644 --- a/deps/v8/src/ia32/full-codegen-ia32.cc +++ b/deps/v8/src/ia32/full-codegen-ia32.cc @@ -34,6 +34,7 @@ #include "compiler.h" #include "debug.h" #include "full-codegen.h" +#include "isolate-inl.h" #include "parser.h" #include "scopes.h" #include "stub-cache.h" @@ -100,7 +101,9 @@ class JumpPatchSite BASE_EMBEDDED { }; +// TODO(jkummerow): Obsolete as soon as x64 is updated. Remove. int FullCodeGenerator::self_optimization_header_size() { + UNREACHABLE(); return 13; } @@ -321,12 +324,20 @@ void FullCodeGenerator::EmitProfilingCounterReset() { // Self-optimization is a one-off thing: if it fails, don't try again. reset_value = Smi::kMaxValue; } + if (isolate()->IsDebuggerActive()) { + // Detect debug break requests as soon as possible. + reset_value = 10; + } __ mov(ebx, Immediate(profiling_counter_)); __ mov(FieldOperand(ebx, JSGlobalPropertyCell::kValueOffset), Immediate(Smi::FromInt(reset_value))); } +static const int kMaxBackEdgeWeight = 127; +static const int kBackEdgeDistanceDivisor = 100; + + void FullCodeGenerator::EmitStackCheck(IterationStatement* stmt, Label* back_edge_target) { Comment cmnt(masm_, "[ Stack check"); @@ -337,7 +348,8 @@ void FullCodeGenerator::EmitStackCheck(IterationStatement* stmt, if (FLAG_weighted_back_edges) { ASSERT(back_edge_target->is_bound()); int distance = masm_->SizeOfCodeGeneratedSince(back_edge_target); - weight = Min(127, Max(1, distance / 100)); + weight = Min(kMaxBackEdgeWeight, + Max(1, distance / kBackEdgeDistanceDivisor)); } EmitProfilingCounterDecrement(weight); __ j(positive, &ok, Label::kNear); @@ -398,7 +410,8 @@ void FullCodeGenerator::EmitReturnSequence() { weight = FLAG_interrupt_budget / FLAG_self_opt_count; } else if (FLAG_weighted_back_edges) { int distance = masm_->pc_offset(); - weight = Min(127, Max(1, distance / 100)); + weight = Min(kMaxBackEdgeWeight, + Max(1, distance / kBackEdgeDistanceDivisor)); } EmitProfilingCounterDecrement(weight); Label ok; @@ -1411,6 +1424,15 @@ void FullCodeGenerator::VisitRegExpLiteral(RegExpLiteral* expr) { } +void FullCodeGenerator::EmitAccessor(Expression* expression) { + if (expression == NULL) { + __ push(Immediate(isolate()->factory()->null_value())); + } else { + VisitForStackValue(expression); + } +} + + void FullCodeGenerator::VisitObjectLiteral(ObjectLiteral* expr) { Comment cmnt(masm_, "[ ObjectLiteral"); Handle<FixedArray> constant_properties = expr->constant_properties(); @@ -1445,6 +1467,7 @@ void FullCodeGenerator::VisitObjectLiteral(ObjectLiteral* expr) { // marked expressions, no store code is emitted. expr->CalculateEmitStore(); + AccessorTable accessor_table(isolate()->zone()); for (int i = 0; i < expr->properties()->length(); i++) { ObjectLiteral::Property* property = expr->properties()->at(i); if (property->IsCompileTimeValue()) continue; @@ -1456,6 +1479,8 @@ void FullCodeGenerator::VisitObjectLiteral(ObjectLiteral* expr) { result_saved = true; } switch (property->kind()) { + case ObjectLiteral::Property::CONSTANT: + UNREACHABLE(); case ObjectLiteral::Property::MATERIALIZED_LITERAL: ASSERT(!CompileTimeValue::IsCompileTimeValue(value)); // Fall through. @@ -1487,24 +1512,28 @@ void FullCodeGenerator::VisitObjectLiteral(ObjectLiteral* expr) { __ Drop(3); } break; - case ObjectLiteral::Property::SETTER: case ObjectLiteral::Property::GETTER: - __ push(Operand(esp, 0)); // Duplicate receiver. - VisitForStackValue(key); - if (property->kind() == ObjectLiteral::Property::GETTER) { - VisitForStackValue(value); - __ push(Immediate(isolate()->factory()->null_value())); - } else { - __ push(Immediate(isolate()->factory()->null_value())); - VisitForStackValue(value); - } - __ push(Immediate(Smi::FromInt(NONE))); - __ CallRuntime(Runtime::kDefineOrRedefineAccessorProperty, 5); + accessor_table.lookup(key)->second->getter = value; + break; + case ObjectLiteral::Property::SETTER: + accessor_table.lookup(key)->second->setter = value; break; - default: UNREACHABLE(); } } + // Emit code to define accessors, using only a single call to the runtime for + // each pair of corresponding getters and setters. + for (AccessorTable::Iterator it = accessor_table.begin(); + it != accessor_table.end(); + ++it) { + __ push(Operand(esp, 0)); // Duplicate receiver. + VisitForStackValue(it->first); + EmitAccessor(it->second->getter); + EmitAccessor(it->second->setter); + __ push(Immediate(Smi::FromInt(NONE))); + __ CallRuntime(Runtime::kDefineOrRedefineAccessorProperty, 5); + } + if (expr->has_function()) { ASSERT(result_saved); __ push(Operand(esp, 0)); |