Refactor deferred_objects_double_values_ a little in the deoptimization

R=mstarzinger@chromium.org

Review URL: https://codereview.chromium.org/25583004

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@17226 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
This commit is contained in:
haitao.feng@intel.com 2013-10-16 03:30:06 +00:00
parent f5abb8e52a
commit d3849b23d4
2 changed files with 34 additions and 25 deletions

View File

@ -1694,29 +1694,35 @@ void Deoptimizer::MaterializeHeapObjects(JavaScriptFrameIterator* it) {
// output frames are used to materialize arguments objects later on they need
// to already contain valid heap numbers.
for (int i = 0; i < deferred_heap_numbers_.length(); i++) {
HeapNumberMaterializationDescriptor d = deferred_heap_numbers_[i];
HeapNumberMaterializationDescriptor<Address> d = deferred_heap_numbers_[i];
Handle<Object> num = isolate_->factory()->NewNumber(d.value());
if (trace_) {
PrintF("Materialized a new heap number %p [%e] in slot %p\n",
reinterpret_cast<void*>(*num),
d.value(),
d.slot_address());
d.destination());
}
Memory::Object_at(d.slot_address()) = *num;
Memory::Object_at(d.destination()) = *num;
}
// Materialize all heap numbers required for arguments/captured objects.
for (int i = 0; i < values.length(); i++) {
if (!values.at(i)->IsTheHole()) continue;
double double_value = deferred_objects_double_values_[i];
Handle<Object> num = isolate_->factory()->NewNumber(double_value);
for (int i = 0; i < deferred_objects_double_values_.length(); i++) {
HeapNumberMaterializationDescriptor<int> d =
deferred_objects_double_values_[i];
Handle<Object> num = isolate_->factory()->NewNumber(d.value());
if (trace_) {
PrintF("Materialized a new heap number %p [%e] for object\n",
reinterpret_cast<void*>(*num), double_value);
PrintF("Materialized a new heap number %p [%e] for object at %d\n",
reinterpret_cast<void*>(*num),
d.value(),
d.destination());
}
values.Set(i, num);
ASSERT(values.at(d.destination())->IsTheHole());
values.Set(d.destination(), num);
}
// Play it safe and clear all object double values before we continue.
deferred_objects_double_values_.Clear();
// Materialize arguments/captured objects.
if (!deferred_objects_.is_empty()) {
List<Handle<Object> > materialized_objects(deferred_objects_.length());
@ -1766,11 +1772,11 @@ void Deoptimizer::MaterializeHeapNumbersForDebuggerInspectableFrame(
Address parameters_bottom = parameters_top + parameters_size;
Address expressions_bottom = expressions_top + expressions_size;
for (int i = 0; i < deferred_heap_numbers_.length(); i++) {
HeapNumberMaterializationDescriptor d = deferred_heap_numbers_[i];
HeapNumberMaterializationDescriptor<Address> d = deferred_heap_numbers_[i];
// Check of the heap number to materialize actually belong to the frame
// being extracted.
Address slot = d.slot_address();
Address slot = d.destination();
if (parameters_top <= slot && slot < parameters_bottom) {
Handle<Object> num = isolate_->factory()->NewNumber(d.value());
@ -1782,7 +1788,7 @@ void Deoptimizer::MaterializeHeapNumbersForDebuggerInspectableFrame(
"for parameter slot #%d\n",
reinterpret_cast<void*>(*num),
d.value(),
d.slot_address(),
d.destination(),
index);
}
@ -1798,7 +1804,7 @@ void Deoptimizer::MaterializeHeapNumbersForDebuggerInspectableFrame(
"for expression slot #%d\n",
reinterpret_cast<void*>(*num),
d.value(),
d.slot_address(),
d.destination(),
index);
}
@ -2406,18 +2412,19 @@ void Deoptimizer::AddObjectDuplication(intptr_t slot, int object_index) {
void Deoptimizer::AddObjectTaggedValue(intptr_t value) {
deferred_objects_tagged_values_.Add(reinterpret_cast<Object*>(value));
deferred_objects_double_values_.Add(isolate()->heap()->nan_value()->value());
}
void Deoptimizer::AddObjectDoubleValue(double value) {
deferred_objects_tagged_values_.Add(isolate()->heap()->the_hole_value());
deferred_objects_double_values_.Add(value);
HeapNumberMaterializationDescriptor<int> value_desc(
deferred_objects_tagged_values_.length() - 1, value);
deferred_objects_double_values_.Add(value_desc);
}
void Deoptimizer::AddDoubleValue(intptr_t slot_address, double value) {
HeapNumberMaterializationDescriptor value_desc(
HeapNumberMaterializationDescriptor<Address> value_desc(
reinterpret_cast<Address>(slot_address), value);
deferred_heap_numbers_.Add(value_desc);
}

View File

@ -60,17 +60,18 @@ class FrameDescription;
class TranslationIterator;
class DeoptimizedFrameInfo;
template<typename T>
class HeapNumberMaterializationDescriptor BASE_EMBEDDED {
public:
HeapNumberMaterializationDescriptor(Address slot_address, double val)
: slot_address_(slot_address), val_(val) { }
HeapNumberMaterializationDescriptor(T destination, double value)
: destination_(destination), value_(value) { }
Address slot_address() const { return slot_address_; }
double value() const { return val_; }
T destination() const { return destination_; }
double value() const { return value_; }
private:
Address slot_address_;
double val_;
T destination_;
double value_;
};
@ -431,9 +432,10 @@ class Deoptimizer : public Malloced {
// Deferred values to be materialized.
List<Object*> deferred_objects_tagged_values_;
List<double> deferred_objects_double_values_;
List<HeapNumberMaterializationDescriptor<int> >
deferred_objects_double_values_;
List<ObjectMaterializationDescriptor> deferred_objects_;
List<HeapNumberMaterializationDescriptor> deferred_heap_numbers_;
List<HeapNumberMaterializationDescriptor<Address> > deferred_heap_numbers_;
// Output frame information. Only used during heap object materialization.
List<Handle<JSFunction> > jsframe_functions_;