OLD | NEW |
1 // Copyright 2013 the V8 project authors. All rights reserved. | 1 // Copyright 2013 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "src/crankshaft/hydrogen-load-elimination.h" | 5 #include "src/crankshaft/hydrogen-load-elimination.h" |
6 | 6 |
7 #include "src/crankshaft/hydrogen-alias-analysis.h" | 7 #include "src/crankshaft/hydrogen-alias-analysis.h" |
8 #include "src/crankshaft/hydrogen-flow-engine.h" | 8 #include "src/crankshaft/hydrogen-flow-engine.h" |
9 #include "src/crankshaft/hydrogen-instructions.h" | 9 #include "src/crankshaft/hydrogen-instructions.h" |
10 | 10 |
(...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
236 | 236 |
237 int field = FieldOf(instr->access()); | 237 int field = FieldOf(instr->access()); |
238 if (field < 0) return KillIfMisaligned(instr); | 238 if (field < 0) return KillIfMisaligned(instr); |
239 | 239 |
240 HValue* object = instr->object()->ActualValue(); | 240 HValue* object = instr->object()->ActualValue(); |
241 HValue* value = instr->value(); | 241 HValue* value = instr->value(); |
242 | 242 |
243 if (instr->has_transition()) { | 243 if (instr->has_transition()) { |
244 // A transition introduces a new field and alters the map of the object. | 244 // A transition introduces a new field and alters the map of the object. |
245 // Since the field in the object is new, it cannot alias existing entries. | 245 // Since the field in the object is new, it cannot alias existing entries. |
246 // TODO(titzer): introduce a constant for the new map and remember it. | |
247 KillFieldInternal(object, FieldOf(JSObject::kMapOffset), NULL); | 246 KillFieldInternal(object, FieldOf(JSObject::kMapOffset), NULL); |
248 } else { | 247 } else { |
249 // Kill non-equivalent may-alias entries. | 248 // Kill non-equivalent may-alias entries. |
250 KillFieldInternal(object, field, value); | 249 KillFieldInternal(object, field, value); |
251 } | 250 } |
252 HFieldApproximation* approx = FindOrCreate(object, field); | 251 HFieldApproximation* approx = FindOrCreate(object, field); |
253 | 252 |
254 if (Equal(approx->last_value_, value)) { | 253 if (Equal(approx->last_value_, value)) { |
255 // The store is redundant because the field already has this value. | 254 // The store is redundant because the field already has this value. |
256 return NULL; | 255 return NULL; |
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
395 } | 394 } |
396 | 395 |
397 // Compute the field index for the given object access; -1 if not tracked. | 396 // Compute the field index for the given object access; -1 if not tracked. |
398 int FieldOf(HObjectAccess access) { | 397 int FieldOf(HObjectAccess access) { |
399 return access.IsInobject() ? FieldOf(access.offset()) : -1; | 398 return access.IsInobject() ? FieldOf(access.offset()) : -1; |
400 } | 399 } |
401 | 400 |
402 // Compute the field index for the given in-object offset; -1 if not tracked. | 401 // Compute the field index for the given in-object offset; -1 if not tracked. |
403 int FieldOf(int offset) { | 402 int FieldOf(int offset) { |
404 if (offset >= kMaxTrackedFields * kPointerSize) return -1; | 403 if (offset >= kMaxTrackedFields * kPointerSize) return -1; |
405 // TODO(titzer): track misaligned loads in a separate list? | |
406 if ((offset % kPointerSize) != 0) return -1; // Ignore misaligned accesses. | 404 if ((offset % kPointerSize) != 0) return -1; // Ignore misaligned accesses. |
407 return offset / kPointerSize; | 405 return offset / kPointerSize; |
408 } | 406 } |
409 | 407 |
410 // Ensure internal storage for the given number of fields. | 408 // Ensure internal storage for the given number of fields. |
411 void EnsureFields(int num_fields) { | 409 void EnsureFields(int num_fields) { |
412 if (fields_.length() < num_fields) { | 410 if (fields_.length() < num_fields) { |
413 fields_.AddBlock(NULL, num_fields - fields_.length(), zone_); | 411 fields_.AddBlock(NULL, num_fields - fields_.length(), zone_); |
414 } | 412 } |
415 } | 413 } |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
504 // Perform only local analysis. | 502 // Perform only local analysis. |
505 for (int i = 0; i < graph()->blocks()->length(); i++) { | 503 for (int i = 0; i < graph()->blocks()->length(); i++) { |
506 table->Kill(); | 504 table->Kill(); |
507 engine.AnalyzeOneBlock(graph()->blocks()->at(i), table); | 505 engine.AnalyzeOneBlock(graph()->blocks()->at(i), table); |
508 } | 506 } |
509 } | 507 } |
510 } | 508 } |
511 | 509 |
512 } // namespace internal | 510 } // namespace internal |
513 } // namespace v8 | 511 } // namespace v8 |
OLD | NEW |