Commit d3849b23 authored by haitao.feng@intel.com's avatar haitao.feng@intel.com

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
parent f5abb8e5
...@@ -1694,29 +1694,35 @@ void Deoptimizer::MaterializeHeapObjects(JavaScriptFrameIterator* it) { ...@@ -1694,29 +1694,35 @@ void Deoptimizer::MaterializeHeapObjects(JavaScriptFrameIterator* it) {
// output frames are used to materialize arguments objects later on they need // output frames are used to materialize arguments objects later on they need
// to already contain valid heap numbers. // to already contain valid heap numbers.
for (int i = 0; i < deferred_heap_numbers_.length(); i++) { 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()); Handle<Object> num = isolate_->factory()->NewNumber(d.value());
if (trace_) { if (trace_) {
PrintF("Materialized a new heap number %p [%e] in slot %p\n", PrintF("Materialized a new heap number %p [%e] in slot %p\n",
reinterpret_cast<void*>(*num), reinterpret_cast<void*>(*num),
d.value(), 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. // Materialize all heap numbers required for arguments/captured objects.
for (int i = 0; i < values.length(); i++) { for (int i = 0; i < deferred_objects_double_values_.length(); i++) {
if (!values.at(i)->IsTheHole()) continue; HeapNumberMaterializationDescriptor<int> d =
double double_value = deferred_objects_double_values_[i]; deferred_objects_double_values_[i];
Handle<Object> num = isolate_->factory()->NewNumber(double_value); Handle<Object> num = isolate_->factory()->NewNumber(d.value());
if (trace_) { if (trace_) {
PrintF("Materialized a new heap number %p [%e] for object\n", PrintF("Materialized a new heap number %p [%e] for object at %d\n",
reinterpret_cast<void*>(*num), double_value); 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. // Materialize arguments/captured objects.
if (!deferred_objects_.is_empty()) { if (!deferred_objects_.is_empty()) {
List<Handle<Object> > materialized_objects(deferred_objects_.length()); List<Handle<Object> > materialized_objects(deferred_objects_.length());
...@@ -1766,11 +1772,11 @@ void Deoptimizer::MaterializeHeapNumbersForDebuggerInspectableFrame( ...@@ -1766,11 +1772,11 @@ void Deoptimizer::MaterializeHeapNumbersForDebuggerInspectableFrame(
Address parameters_bottom = parameters_top + parameters_size; Address parameters_bottom = parameters_top + parameters_size;
Address expressions_bottom = expressions_top + expressions_size; Address expressions_bottom = expressions_top + expressions_size;
for (int i = 0; i < deferred_heap_numbers_.length(); i++) { 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 // Check of the heap number to materialize actually belong to the frame
// being extracted. // being extracted.
Address slot = d.slot_address(); Address slot = d.destination();
if (parameters_top <= slot && slot < parameters_bottom) { if (parameters_top <= slot && slot < parameters_bottom) {
Handle<Object> num = isolate_->factory()->NewNumber(d.value()); Handle<Object> num = isolate_->factory()->NewNumber(d.value());
...@@ -1782,7 +1788,7 @@ void Deoptimizer::MaterializeHeapNumbersForDebuggerInspectableFrame( ...@@ -1782,7 +1788,7 @@ void Deoptimizer::MaterializeHeapNumbersForDebuggerInspectableFrame(
"for parameter slot #%d\n", "for parameter slot #%d\n",
reinterpret_cast<void*>(*num), reinterpret_cast<void*>(*num),
d.value(), d.value(),
d.slot_address(), d.destination(),
index); index);
} }
...@@ -1798,7 +1804,7 @@ void Deoptimizer::MaterializeHeapNumbersForDebuggerInspectableFrame( ...@@ -1798,7 +1804,7 @@ void Deoptimizer::MaterializeHeapNumbersForDebuggerInspectableFrame(
"for expression slot #%d\n", "for expression slot #%d\n",
reinterpret_cast<void*>(*num), reinterpret_cast<void*>(*num),
d.value(), d.value(),
d.slot_address(), d.destination(),
index); index);
} }
...@@ -2406,18 +2412,19 @@ void Deoptimizer::AddObjectDuplication(intptr_t slot, int object_index) { ...@@ -2406,18 +2412,19 @@ void Deoptimizer::AddObjectDuplication(intptr_t slot, int object_index) {
void Deoptimizer::AddObjectTaggedValue(intptr_t value) { void Deoptimizer::AddObjectTaggedValue(intptr_t value) {
deferred_objects_tagged_values_.Add(reinterpret_cast<Object*>(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) { void Deoptimizer::AddObjectDoubleValue(double value) {
deferred_objects_tagged_values_.Add(isolate()->heap()->the_hole_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) { void Deoptimizer::AddDoubleValue(intptr_t slot_address, double value) {
HeapNumberMaterializationDescriptor value_desc( HeapNumberMaterializationDescriptor<Address> value_desc(
reinterpret_cast<Address>(slot_address), value); reinterpret_cast<Address>(slot_address), value);
deferred_heap_numbers_.Add(value_desc); deferred_heap_numbers_.Add(value_desc);
} }
......
...@@ -60,17 +60,18 @@ class FrameDescription; ...@@ -60,17 +60,18 @@ class FrameDescription;
class TranslationIterator; class TranslationIterator;
class DeoptimizedFrameInfo; class DeoptimizedFrameInfo;
template<typename T>
class HeapNumberMaterializationDescriptor BASE_EMBEDDED { class HeapNumberMaterializationDescriptor BASE_EMBEDDED {
public: public:
HeapNumberMaterializationDescriptor(Address slot_address, double val) HeapNumberMaterializationDescriptor(T destination, double value)
: slot_address_(slot_address), val_(val) { } : destination_(destination), value_(value) { }
Address slot_address() const { return slot_address_; } T destination() const { return destination_; }
double value() const { return val_; } double value() const { return value_; }
private: private:
Address slot_address_; T destination_;
double val_; double value_;
}; };
...@@ -431,9 +432,10 @@ class Deoptimizer : public Malloced { ...@@ -431,9 +432,10 @@ class Deoptimizer : public Malloced {
// Deferred values to be materialized. // Deferred values to be materialized.
List<Object*> deferred_objects_tagged_values_; List<Object*> deferred_objects_tagged_values_;
List<double> deferred_objects_double_values_; List<HeapNumberMaterializationDescriptor<int> >
deferred_objects_double_values_;
List<ObjectMaterializationDescriptor> deferred_objects_; List<ObjectMaterializationDescriptor> deferred_objects_;
List<HeapNumberMaterializationDescriptor> deferred_heap_numbers_; List<HeapNumberMaterializationDescriptor<Address> > deferred_heap_numbers_;
// Output frame information. Only used during heap object materialization. // Output frame information. Only used during heap object materialization.
List<Handle<JSFunction> > jsframe_functions_; List<Handle<JSFunction> > jsframe_functions_;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment