| 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 8209 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 8220 ast_context()->ReturnInstruction(result, expr->id()); | 8220 ast_context()->ReturnInstruction(result, expr->id()); |
| 8221 return true; | 8221 return true; |
| 8222 } | 8222 } |
| 8223 break; | 8223 break; |
| 8224 case kArrayPop: { | 8224 case kArrayPop: { |
| 8225 if (receiver_map.is_null()) return false; | 8225 if (receiver_map.is_null()) return false; |
| 8226 if (receiver_map->instance_type() != JS_ARRAY_TYPE) return false; | 8226 if (receiver_map->instance_type() != JS_ARRAY_TYPE) return false; |
| 8227 ElementsKind elements_kind = receiver_map->elements_kind(); | 8227 ElementsKind elements_kind = receiver_map->elements_kind(); |
| 8228 if (!IsFastElementsKind(elements_kind)) return false; | 8228 if (!IsFastElementsKind(elements_kind)) return false; |
| 8229 if (receiver_map->is_observed()) return false; | 8229 if (receiver_map->is_observed()) return false; |
| 8230 DCHECK(receiver_map->is_extensible()); | 8230 if (!receiver_map->is_extensible()) return false; |
| 8231 | 8231 |
| 8232 Drop(expr->arguments()->length()); | 8232 Drop(expr->arguments()->length()); |
| 8233 HValue* result; | 8233 HValue* result; |
| 8234 HValue* reduced_length; | 8234 HValue* reduced_length; |
| 8235 HValue* receiver = Pop(); | 8235 HValue* receiver = Pop(); |
| 8236 | 8236 |
| 8237 HValue* checked_object = AddCheckMap(receiver, receiver_map); | 8237 HValue* checked_object = AddCheckMap(receiver, receiver_map); |
| 8238 HValue* length = Add<HLoadNamedField>( | 8238 HValue* length = Add<HLoadNamedField>( |
| 8239 checked_object, static_cast<HValue*>(NULL), | 8239 checked_object, static_cast<HValue*>(NULL), |
| 8240 HObjectAccess::ForArrayLength(elements_kind)); | 8240 HObjectAccess::ForArrayLength(elements_kind)); |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 8285 ast_context()->ReturnValue(result); | 8285 ast_context()->ReturnValue(result); |
| 8286 return true; | 8286 return true; |
| 8287 } | 8287 } |
| 8288 case kArrayPush: { | 8288 case kArrayPush: { |
| 8289 if (receiver_map.is_null()) return false; | 8289 if (receiver_map.is_null()) return false; |
| 8290 if (receiver_map->instance_type() != JS_ARRAY_TYPE) return false; | 8290 if (receiver_map->instance_type() != JS_ARRAY_TYPE) return false; |
| 8291 ElementsKind elements_kind = receiver_map->elements_kind(); | 8291 ElementsKind elements_kind = receiver_map->elements_kind(); |
| 8292 if (!IsFastElementsKind(elements_kind)) return false; | 8292 if (!IsFastElementsKind(elements_kind)) return false; |
| 8293 if (receiver_map->is_observed()) return false; | 8293 if (receiver_map->is_observed()) return false; |
| 8294 if (JSArray::IsReadOnlyLengthDescriptor(receiver_map)) return false; | 8294 if (JSArray::IsReadOnlyLengthDescriptor(receiver_map)) return false; |
| 8295 DCHECK(receiver_map->is_extensible()); | 8295 if (!receiver_map->is_extensible()) return false; |
| 8296 | 8296 |
| 8297 // If there may be elements accessors in the prototype chain, the fast | 8297 // If there may be elements accessors in the prototype chain, the fast |
| 8298 // inlined version can't be used. | 8298 // inlined version can't be used. |
| 8299 if (receiver_map->DictionaryElementsInPrototypeChainOnly()) return false; | 8299 if (receiver_map->DictionaryElementsInPrototypeChainOnly()) return false; |
| 8300 // If there currently can be no elements accessors on the prototype chain, | 8300 // If there currently can be no elements accessors on the prototype chain, |
| 8301 // it doesn't mean that there won't be any later. Install a full prototype | 8301 // it doesn't mean that there won't be any later. Install a full prototype |
| 8302 // chain check to trap element accessors being installed on the prototype | 8302 // chain check to trap element accessors being installed on the prototype |
| 8303 // chain, which would cause elements to go to dictionary mode and result | 8303 // chain, which would cause elements to go to dictionary mode and result |
| 8304 // in a map change. | 8304 // in a map change. |
| 8305 Handle<JSObject> prototype(JSObject::cast(receiver_map->prototype())); | 8305 Handle<JSObject> prototype(JSObject::cast(receiver_map->prototype())); |
| (...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 8452 return true; | 8452 return true; |
| 8453 } | 8453 } |
| 8454 case kArrayIndexOf: | 8454 case kArrayIndexOf: |
| 8455 case kArrayLastIndexOf: { | 8455 case kArrayLastIndexOf: { |
| 8456 if (receiver_map.is_null()) return false; | 8456 if (receiver_map.is_null()) return false; |
| 8457 if (receiver_map->instance_type() != JS_ARRAY_TYPE) return false; | 8457 if (receiver_map->instance_type() != JS_ARRAY_TYPE) return false; |
| 8458 ElementsKind kind = receiver_map->elements_kind(); | 8458 ElementsKind kind = receiver_map->elements_kind(); |
| 8459 if (!IsFastElementsKind(kind)) return false; | 8459 if (!IsFastElementsKind(kind)) return false; |
| 8460 if (receiver_map->is_observed()) return false; | 8460 if (receiver_map->is_observed()) return false; |
| 8461 if (argument_count != 2) return false; | 8461 if (argument_count != 2) return false; |
| 8462 DCHECK(receiver_map->is_extensible()); | 8462 if (!receiver_map->is_extensible()) return false; |
| 8463 | 8463 |
| 8464 // If there may be elements accessors in the prototype chain, the fast | 8464 // If there may be elements accessors in the prototype chain, the fast |
| 8465 // inlined version can't be used. | 8465 // inlined version can't be used. |
| 8466 if (receiver_map->DictionaryElementsInPrototypeChainOnly()) return false; | 8466 if (receiver_map->DictionaryElementsInPrototypeChainOnly()) return false; |
| 8467 | 8467 |
| 8468 // If there currently can be no elements accessors on the prototype chain, | 8468 // If there currently can be no elements accessors on the prototype chain, |
| 8469 // it doesn't mean that there won't be any later. Install a full prototype | 8469 // it doesn't mean that there won't be any later. Install a full prototype |
| 8470 // chain check to trap element accessors being installed on the prototype | 8470 // chain check to trap element accessors being installed on the prototype |
| 8471 // chain, which would cause elements to go to dictionary mode and result | 8471 // chain, which would cause elements to go to dictionary mode and result |
| 8472 // in a map change. | 8472 // in a map change. |
| (...skipping 4020 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 12493 if (ShouldProduceTraceOutput()) { | 12493 if (ShouldProduceTraceOutput()) { |
| 12494 isolate()->GetHTracer()->TraceHydrogen(name(), graph_); | 12494 isolate()->GetHTracer()->TraceHydrogen(name(), graph_); |
| 12495 } | 12495 } |
| 12496 | 12496 |
| 12497 #ifdef DEBUG | 12497 #ifdef DEBUG |
| 12498 graph_->Verify(false); // No full verify. | 12498 graph_->Verify(false); // No full verify. |
| 12499 #endif | 12499 #endif |
| 12500 } | 12500 } |
| 12501 | 12501 |
| 12502 } } // namespace v8::internal | 12502 } } // namespace v8::internal |
| OLD | NEW |