| OLD | NEW | 
|---|
| 1 // Copyright 2010 the V8 project authors. All rights reserved. | 1 // Copyright 2010 the V8 project authors. All rights reserved. | 
| 2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without | 
| 3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are | 
| 4 // met: | 4 // met: | 
| 5 // | 5 // | 
| 6 //     * Redistributions of source code must retain the above copyright | 6 //     * Redistributions of source code must retain the above copyright | 
| 7 //       notice, this list of conditions and the following disclaimer. | 7 //       notice, this list of conditions and the following disclaimer. | 
| 8 //     * Redistributions in binary form must reproduce the above | 8 //     * Redistributions in binary form must reproduce the above | 
| 9 //       copyright notice, this list of conditions and the following | 9 //       copyright notice, this list of conditions and the following | 
| 10 //       disclaimer in the documentation and/or other materials provided | 10 //       disclaimer in the documentation and/or other materials provided | 
| (...skipping 3625 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 3636 | 3636 | 
| 3637 | 3637 | 
| 3638 HInstruction* HGraphBuilder::BuildLoadKeyedFastElement(HValue* object, | 3638 HInstruction* HGraphBuilder::BuildLoadKeyedFastElement(HValue* object, | 
| 3639                                                        HValue* key, | 3639                                                        HValue* key, | 
| 3640                                                        Property* expr) { | 3640                                                        Property* expr) { | 
| 3641   ASSERT(!expr->key()->IsPropertyName() && expr->IsMonomorphic()); | 3641   ASSERT(!expr->key()->IsPropertyName() && expr->IsMonomorphic()); | 
| 3642   AddInstruction(new HCheckNonSmi(object)); | 3642   AddInstruction(new HCheckNonSmi(object)); | 
| 3643   Handle<Map> map = expr->GetMonomorphicReceiverType(); | 3643   Handle<Map> map = expr->GetMonomorphicReceiverType(); | 
| 3644   ASSERT(map->has_fast_elements()); | 3644   ASSERT(map->has_fast_elements()); | 
| 3645   AddInstruction(new HCheckMap(object, map)); | 3645   AddInstruction(new HCheckMap(object, map)); | 
| 3646   HInstruction* elements = AddInstruction(new HLoadElements(object)); | 3646   bool is_array = (map->instance_type() == JS_ARRAY_TYPE); | 
| 3647   HInstruction* length = AddInstruction(new HArrayLength(elements)); | 3647   HLoadElements* elements = new HLoadElements(object); | 
| 3648   AddInstruction(new HBoundsCheck(key, length)); | 3648   HInstruction* length = NULL; | 
|  | 3649   if (is_array) { | 
|  | 3650     length = AddInstruction(new HJSArrayLength(object)); | 
|  | 3651     AddInstruction(new HBoundsCheck(key, length)); | 
|  | 3652     AddInstruction(elements); | 
|  | 3653   } else { | 
|  | 3654     AddInstruction(elements); | 
|  | 3655     length = AddInstruction(new HFixedArrayLength(elements)); | 
|  | 3656     AddInstruction(new HBoundsCheck(key, length)); | 
|  | 3657   } | 
| 3649   return new HLoadKeyedFastElement(elements, key); | 3658   return new HLoadKeyedFastElement(elements, key); | 
| 3650 } | 3659 } | 
| 3651 | 3660 | 
| 3652 | 3661 | 
| 3653 HInstruction* HGraphBuilder::BuildStoreKeyedGeneric(HValue* object, | 3662 HInstruction* HGraphBuilder::BuildStoreKeyedGeneric(HValue* object, | 
| 3654                                                     HValue* key, | 3663                                                     HValue* key, | 
| 3655                                                     HValue* value) { | 3664                                                     HValue* value) { | 
| 3656   return new HStoreKeyedGeneric(object, key, value); | 3665   return new HStoreKeyedGeneric(object, key, value); | 
| 3657 } | 3666 } | 
| 3658 | 3667 | 
| 3659 | 3668 | 
| 3660 HInstruction* HGraphBuilder::BuildStoreKeyedFastElement(HValue* object, | 3669 HInstruction* HGraphBuilder::BuildStoreKeyedFastElement(HValue* object, | 
| 3661                                                         HValue* key, | 3670                                                         HValue* key, | 
| 3662                                                         HValue* val, | 3671                                                         HValue* val, | 
| 3663                                                         Expression* expr) { | 3672                                                         Expression* expr) { | 
| 3664   ASSERT(expr->IsMonomorphic()); | 3673   ASSERT(expr->IsMonomorphic()); | 
| 3665   AddInstruction(new HCheckNonSmi(object)); | 3674   AddInstruction(new HCheckNonSmi(object)); | 
| 3666   Handle<Map> map = expr->GetMonomorphicReceiverType(); | 3675   Handle<Map> map = expr->GetMonomorphicReceiverType(); | 
| 3667   ASSERT(map->has_fast_elements()); | 3676   ASSERT(map->has_fast_elements()); | 
| 3668   AddInstruction(new HCheckMap(object, map)); | 3677   AddInstruction(new HCheckMap(object, map)); | 
| 3669   HInstruction* elements = AddInstruction(new HLoadElements(object)); | 3678   HInstruction* elements = AddInstruction(new HLoadElements(object)); | 
| 3670   AddInstruction(new HCheckMap(elements, Factory::fixed_array_map())); | 3679   AddInstruction(new HCheckMap(elements, Factory::fixed_array_map())); | 
| 3671   bool is_array = (map->instance_type() == JS_ARRAY_TYPE); | 3680   bool is_array = (map->instance_type() == JS_ARRAY_TYPE); | 
| 3672   HInstruction* length = NULL; | 3681   HInstruction* length = NULL; | 
| 3673   if (is_array) { | 3682   if (is_array) { | 
| 3674     length = AddInstruction(new HArrayLength(object)); | 3683     length = AddInstruction(new HJSArrayLength(object)); | 
| 3675   } else { | 3684   } else { | 
| 3676     length = AddInstruction(new HArrayLength(elements)); | 3685     length = AddInstruction(new HFixedArrayLength(elements)); | 
| 3677   } | 3686   } | 
| 3678   AddInstruction(new HBoundsCheck(key, length)); | 3687   AddInstruction(new HBoundsCheck(key, length)); | 
| 3679   return new HStoreKeyedFastElement(elements, key, val); | 3688   return new HStoreKeyedFastElement(elements, key, val); | 
| 3680 } | 3689 } | 
| 3681 | 3690 | 
| 3682 | 3691 | 
| 3683 bool HGraphBuilder::TryArgumentsAccess(Property* expr) { | 3692 bool HGraphBuilder::TryArgumentsAccess(Property* expr) { | 
| 3684   VariableProxy* proxy = expr->obj()->AsVariableProxy(); | 3693   VariableProxy* proxy = expr->obj()->AsVariableProxy(); | 
| 3685   if (proxy == NULL) return false; | 3694   if (proxy == NULL) return false; | 
| 3686   if (!proxy->var()->IsStackAllocated()) return false; | 3695   if (!proxy->var()->IsStackAllocated()) return false; | 
| (...skipping 26 matching lines...) Expand all  Loading... | 
| 3713 | 3722 | 
| 3714   if (TryArgumentsAccess(expr)) return; | 3723   if (TryArgumentsAccess(expr)) return; | 
| 3715   CHECK_BAILOUT; | 3724   CHECK_BAILOUT; | 
| 3716 | 3725 | 
| 3717   VISIT_FOR_VALUE(expr->obj()); | 3726   VISIT_FOR_VALUE(expr->obj()); | 
| 3718 | 3727 | 
| 3719   HInstruction* instr = NULL; | 3728   HInstruction* instr = NULL; | 
| 3720   if (expr->IsArrayLength()) { | 3729   if (expr->IsArrayLength()) { | 
| 3721     HValue* array = Pop(); | 3730     HValue* array = Pop(); | 
| 3722     AddInstruction(new HCheckNonSmi(array)); | 3731     AddInstruction(new HCheckNonSmi(array)); | 
| 3723     instr = new HArrayLength(array); | 3732     AddInstruction(new HCheckInstanceType(array, JS_ARRAY_TYPE, JS_ARRAY_TYPE)); | 
|  | 3733     instr = new HJSArrayLength(array); | 
| 3724 | 3734 | 
| 3725   } else if (expr->IsFunctionPrototype()) { | 3735   } else if (expr->IsFunctionPrototype()) { | 
| 3726     HValue* function = Pop(); | 3736     HValue* function = Pop(); | 
| 3727     AddInstruction(new HCheckNonSmi(function)); | 3737     AddInstruction(new HCheckNonSmi(function)); | 
| 3728     instr = new HLoadFunctionPrototype(function); | 3738     instr = new HLoadFunctionPrototype(function); | 
| 3729 | 3739 | 
| 3730   } else if (expr->key()->IsPropertyName()) { | 3740   } else if (expr->key()->IsPropertyName()) { | 
| 3731     Handle<String> name = expr->key()->AsLiteral()->AsPropertyName(); | 3741     Handle<String> name = expr->key()->AsLiteral()->AsPropertyName(); | 
| 3732     ZoneMapList* types = expr->GetReceiverTypes(); | 3742     ZoneMapList* types = expr->GetReceiverTypes(); | 
| 3733 | 3743 | 
| (...skipping 1118 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 4852   TypeInfo info = oracle()->CompareType(expr, TypeFeedbackOracle::RESULT); | 4862   TypeInfo info = oracle()->CompareType(expr, TypeFeedbackOracle::RESULT); | 
| 4853   HInstruction* instr = NULL; | 4863   HInstruction* instr = NULL; | 
| 4854   if (op == Token::INSTANCEOF) { | 4864   if (op == Token::INSTANCEOF) { | 
| 4855     instr = new HInstanceOf(left, right); | 4865     instr = new HInstanceOf(left, right); | 
| 4856   } else if (op == Token::IN) { | 4866   } else if (op == Token::IN) { | 
| 4857     BAILOUT("Unsupported comparison: in"); | 4867     BAILOUT("Unsupported comparison: in"); | 
| 4858   } else if (info.IsNonPrimitive()) { | 4868   } else if (info.IsNonPrimitive()) { | 
| 4859     switch (op) { | 4869     switch (op) { | 
| 4860       case Token::EQ: | 4870       case Token::EQ: | 
| 4861       case Token::EQ_STRICT: { | 4871       case Token::EQ_STRICT: { | 
|  | 4872         AddInstruction(new HCheckNonSmi(left)); | 
| 4862         AddInstruction(HCheckInstanceType::NewIsJSObjectOrJSFunction(left)); | 4873         AddInstruction(HCheckInstanceType::NewIsJSObjectOrJSFunction(left)); | 
|  | 4874         AddInstruction(new HCheckNonSmi(right)); | 
| 4863         AddInstruction(HCheckInstanceType::NewIsJSObjectOrJSFunction(right)); | 4875         AddInstruction(HCheckInstanceType::NewIsJSObjectOrJSFunction(right)); | 
| 4864         instr = new HCompareJSObjectEq(left, right); | 4876         instr = new HCompareJSObjectEq(left, right); | 
| 4865         break; | 4877         break; | 
| 4866       } | 4878       } | 
| 4867       default: | 4879       default: | 
| 4868         BAILOUT("Unsupported non-primitive compare"); | 4880         BAILOUT("Unsupported non-primitive compare"); | 
| 4869         break; | 4881         break; | 
| 4870     } | 4882     } | 
| 4871   } else { | 4883   } else { | 
| 4872     HCompare* compare = new HCompare(left, right, op); | 4884     HCompare* compare = new HCompare(left, right, op); | 
| (...skipping 809 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 5682   } | 5694   } | 
| 5683 | 5695 | 
| 5684 #ifdef DEBUG | 5696 #ifdef DEBUG | 
| 5685   if (graph_ != NULL) graph_->Verify(); | 5697   if (graph_ != NULL) graph_->Verify(); | 
| 5686   if (chunk_ != NULL) chunk_->Verify(); | 5698   if (chunk_ != NULL) chunk_->Verify(); | 
| 5687   if (allocator_ != NULL) allocator_->Verify(); | 5699   if (allocator_ != NULL) allocator_->Verify(); | 
| 5688 #endif | 5700 #endif | 
| 5689 } | 5701 } | 
| 5690 | 5702 | 
| 5691 } }  // namespace v8::internal | 5703 } }  // namespace v8::internal | 
| OLD | NEW | 
|---|