| 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/hydrogen.h" | 5 #include "src/hydrogen.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include "src/v8.h" | 9 #include "src/v8.h" |
| 10 | 10 |
| (...skipping 6811 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6822 KeyedAccessStoreMode store_mode) { | 6822 KeyedAccessStoreMode store_mode) { |
| 6823 HCheckMaps* checked_object = Add<HCheckMaps>(object, map, dependency); | 6823 HCheckMaps* checked_object = Add<HCheckMaps>(object, map, dependency); |
| 6824 if (dependency) { | 6824 if (dependency) { |
| 6825 checked_object->ClearDependsOnFlag(kElementsKind); | 6825 checked_object->ClearDependsOnFlag(kElementsKind); |
| 6826 } | 6826 } |
| 6827 | 6827 |
| 6828 if (access_type == STORE && map->prototype()->IsJSObject()) { | 6828 if (access_type == STORE && map->prototype()->IsJSObject()) { |
| 6829 // monomorphic stores need a prototype chain check because shape | 6829 // monomorphic stores need a prototype chain check because shape |
| 6830 // changes could allow callbacks on elements in the chain that | 6830 // changes could allow callbacks on elements in the chain that |
| 6831 // aren't compatible with monomorphic keyed stores. | 6831 // aren't compatible with monomorphic keyed stores. |
| 6832 Handle<JSObject> prototype(JSObject::cast(map->prototype())); | 6832 PrototypeIterator iter(map); |
| 6833 JSObject* holder = JSObject::cast(map->prototype()); | 6833 JSObject* holder = NULL; |
| 6834 while (!holder->GetPrototype()->IsNull()) { | 6834 while (!iter.IsAtEnd()) { |
| 6835 holder = JSObject::cast(holder->GetPrototype()); | 6835 holder = JSObject::cast(*PrototypeIterator::GetCurrent(iter)); |
| 6836 iter.Advance(); |
| 6836 } | 6837 } |
| 6838 ASSERT(holder && holder->IsJSObject()); |
| 6837 | 6839 |
| 6838 BuildCheckPrototypeMaps(prototype, | 6840 BuildCheckPrototypeMaps(handle(JSObject::cast(map->prototype())), |
| 6839 Handle<JSObject>(JSObject::cast(holder))); | 6841 Handle<JSObject>(holder)); |
| 6840 } | 6842 } |
| 6841 | 6843 |
| 6842 LoadKeyedHoleMode load_mode = BuildKeyedHoleMode(map); | 6844 LoadKeyedHoleMode load_mode = BuildKeyedHoleMode(map); |
| 6843 return BuildUncheckedMonomorphicElementAccess( | 6845 return BuildUncheckedMonomorphicElementAccess( |
| 6844 checked_object, key, val, | 6846 checked_object, key, val, |
| 6845 map->instance_type() == JS_ARRAY_TYPE, | 6847 map->instance_type() == JS_ARRAY_TYPE, |
| 6846 map->elements_kind(), access_type, | 6848 map->elements_kind(), access_type, |
| 6847 load_mode, store_mode); | 6849 load_mode, store_mode); |
| 6848 } | 6850 } |
| 6849 | 6851 |
| (...skipping 451 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7301 HInstruction* HGraphBuilder::BuildConstantMapCheck(Handle<JSObject> constant) { | 7303 HInstruction* HGraphBuilder::BuildConstantMapCheck(Handle<JSObject> constant) { |
| 7302 HCheckMaps* check = Add<HCheckMaps>( | 7304 HCheckMaps* check = Add<HCheckMaps>( |
| 7303 Add<HConstant>(constant), handle(constant->map())); | 7305 Add<HConstant>(constant), handle(constant->map())); |
| 7304 check->ClearDependsOnFlag(kElementsKind); | 7306 check->ClearDependsOnFlag(kElementsKind); |
| 7305 return check; | 7307 return check; |
| 7306 } | 7308 } |
| 7307 | 7309 |
| 7308 | 7310 |
| 7309 HInstruction* HGraphBuilder::BuildCheckPrototypeMaps(Handle<JSObject> prototype, | 7311 HInstruction* HGraphBuilder::BuildCheckPrototypeMaps(Handle<JSObject> prototype, |
| 7310 Handle<JSObject> holder) { | 7312 Handle<JSObject> holder) { |
| 7311 while (holder.is_null() || !prototype.is_identical_to(holder)) { | 7313 PrototypeIterator iter(isolate(), prototype, |
| 7312 BuildConstantMapCheck(prototype); | 7314 PrototypeIterator::START_AT_RECEIVER); |
| 7313 Object* next_prototype = prototype->GetPrototype(); | 7315 while (holder.is_null() || |
| 7314 if (next_prototype->IsNull()) return NULL; | 7316 !PrototypeIterator::GetCurrent(iter).is_identical_to(holder)) { |
| 7315 CHECK(next_prototype->IsJSObject()); | 7317 BuildConstantMapCheck( |
| 7316 prototype = handle(JSObject::cast(next_prototype)); | 7318 Handle<JSObject>::cast(PrototypeIterator::GetCurrent(iter))); |
| 7319 iter.Advance(); |
| 7320 if (iter.IsAtEnd()) { |
| 7321 return NULL; |
| 7322 } |
| 7317 } | 7323 } |
| 7318 return BuildConstantMapCheck(prototype); | 7324 return BuildConstantMapCheck( |
| 7325 Handle<JSObject>::cast(PrototypeIterator::GetCurrent(iter))); |
| 7319 } | 7326 } |
| 7320 | 7327 |
| 7321 | 7328 |
| 7322 void HOptimizedGraphBuilder::AddCheckPrototypeMaps(Handle<JSObject> holder, | 7329 void HOptimizedGraphBuilder::AddCheckPrototypeMaps(Handle<JSObject> holder, |
| 7323 Handle<Map> receiver_map) { | 7330 Handle<Map> receiver_map) { |
| 7324 if (!holder.is_null()) { | 7331 if (!holder.is_null()) { |
| 7325 Handle<JSObject> prototype(JSObject::cast(receiver_map->prototype())); | 7332 Handle<JSObject> prototype(JSObject::cast(receiver_map->prototype())); |
| 7326 BuildCheckPrototypeMaps(prototype, holder); | 7333 BuildCheckPrototypeMaps(prototype, holder); |
| 7327 } | 7334 } |
| 7328 } | 7335 } |
| (...skipping 5095 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 12424 if (ShouldProduceTraceOutput()) { | 12431 if (ShouldProduceTraceOutput()) { |
| 12425 isolate()->GetHTracer()->TraceHydrogen(name(), graph_); | 12432 isolate()->GetHTracer()->TraceHydrogen(name(), graph_); |
| 12426 } | 12433 } |
| 12427 | 12434 |
| 12428 #ifdef DEBUG | 12435 #ifdef DEBUG |
| 12429 graph_->Verify(false); // No full verify. | 12436 graph_->Verify(false); // No full verify. |
| 12430 #endif | 12437 #endif |
| 12431 } | 12438 } |
| 12432 | 12439 |
| 12433 } } // namespace v8::internal | 12440 } } // namespace v8::internal |
| OLD | NEW |