| OLD | NEW |
| 1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 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 3655 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3666 AddInstruction(new HCheckInstanceType(array, JS_ARRAY_TYPE, JS_ARRAY_TYPE)); | 3666 AddInstruction(new HCheckInstanceType(array, JS_ARRAY_TYPE, JS_ARRAY_TYPE)); |
| 3667 instr = new HJSArrayLength(array); | 3667 instr = new HJSArrayLength(array); |
| 3668 | 3668 |
| 3669 } else if (expr->IsStringLength()) { | 3669 } else if (expr->IsStringLength()) { |
| 3670 HValue* string = Pop(); | 3670 HValue* string = Pop(); |
| 3671 AddInstruction(new HCheckNonSmi(string)); | 3671 AddInstruction(new HCheckNonSmi(string)); |
| 3672 AddInstruction(new HCheckInstanceType(string, | 3672 AddInstruction(new HCheckInstanceType(string, |
| 3673 FIRST_STRING_TYPE, | 3673 FIRST_STRING_TYPE, |
| 3674 LAST_STRING_TYPE)); | 3674 LAST_STRING_TYPE)); |
| 3675 instr = new HStringLength(string); | 3675 instr = new HStringLength(string); |
| 3676 } else if (expr->IsStringAccess()) { |
| 3677 VISIT_FOR_VALUE(expr->key()); |
| 3678 HValue* index = Pop(); |
| 3679 HValue* string = Pop(); |
| 3680 HStringCharCodeAt* char_code = BuildStringCharCodeAt(string, index); |
| 3681 AddInstruction(char_code); |
| 3682 instr = new HStringCharFromCode(char_code); |
| 3676 | 3683 |
| 3677 } else if (expr->IsFunctionPrototype()) { | 3684 } else if (expr->IsFunctionPrototype()) { |
| 3678 HValue* function = Pop(); | 3685 HValue* function = Pop(); |
| 3679 AddInstruction(new HCheckNonSmi(function)); | 3686 AddInstruction(new HCheckNonSmi(function)); |
| 3680 instr = new HLoadFunctionPrototype(function); | 3687 instr = new HLoadFunctionPrototype(function); |
| 3681 | 3688 |
| 3682 } else if (expr->key()->IsPropertyName()) { | 3689 } else if (expr->key()->IsPropertyName()) { |
| 3683 Handle<String> name = expr->key()->AsLiteral()->AsPropertyName(); | 3690 Handle<String> name = expr->key()->AsLiteral()->AsPropertyName(); |
| 3684 ZoneMapList* types = expr->GetReceiverTypes(); | 3691 ZoneMapList* types = expr->GetReceiverTypes(); |
| 3685 | 3692 |
| (...skipping 360 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4046 HValue* receiver, | 4053 HValue* receiver, |
| 4047 Handle<Map> receiver_map, | 4054 Handle<Map> receiver_map, |
| 4048 CheckType check_type) { | 4055 CheckType check_type) { |
| 4049 ASSERT(check_type != RECEIVER_MAP_CHECK || !receiver_map.is_null()); | 4056 ASSERT(check_type != RECEIVER_MAP_CHECK || !receiver_map.is_null()); |
| 4050 // Try to inline calls like Math.* as operations in the calling function. | 4057 // Try to inline calls like Math.* as operations in the calling function. |
| 4051 if (!expr->target()->shared()->HasBuiltinFunctionId()) return false; | 4058 if (!expr->target()->shared()->HasBuiltinFunctionId()) return false; |
| 4052 BuiltinFunctionId id = expr->target()->shared()->builtin_function_id(); | 4059 BuiltinFunctionId id = expr->target()->shared()->builtin_function_id(); |
| 4053 int argument_count = expr->arguments()->length() + 1; // Plus receiver. | 4060 int argument_count = expr->arguments()->length() + 1; // Plus receiver. |
| 4054 switch (id) { | 4061 switch (id) { |
| 4055 case kStringCharCodeAt: | 4062 case kStringCharCodeAt: |
| 4063 case kStringCharAt: |
| 4056 if (argument_count == 2 && check_type == STRING_CHECK) { | 4064 if (argument_count == 2 && check_type == STRING_CHECK) { |
| 4057 HValue* index = Pop(); | 4065 HValue* index = Pop(); |
| 4058 HValue* string = Pop(); | 4066 HValue* string = Pop(); |
| 4059 ASSERT(!expr->holder().is_null()); | 4067 ASSERT(!expr->holder().is_null()); |
| 4060 AddInstruction(new HCheckPrototypeMaps( | 4068 AddInstruction(new HCheckPrototypeMaps( |
| 4061 oracle()->GetPrototypeForPrimitiveCheck(STRING_CHECK), | 4069 oracle()->GetPrototypeForPrimitiveCheck(STRING_CHECK), |
| 4062 expr->holder())); | 4070 expr->holder())); |
| 4063 HStringCharCodeAt* result = BuildStringCharCodeAt(string, index); | 4071 HStringCharCodeAt* char_code = BuildStringCharCodeAt(string, index); |
| 4072 if (id == kStringCharCodeAt) { |
| 4073 ast_context()->ReturnInstruction(char_code, expr->id()); |
| 4074 return true; |
| 4075 } |
| 4076 AddInstruction(char_code); |
| 4077 HStringCharFromCode* result = new HStringCharFromCode(char_code); |
| 4064 ast_context()->ReturnInstruction(result, expr->id()); | 4078 ast_context()->ReturnInstruction(result, expr->id()); |
| 4065 return true; | 4079 return true; |
| 4066 } | 4080 } |
| 4067 break; | 4081 break; |
| 4068 case kMathRound: | 4082 case kMathRound: |
| 4069 case kMathFloor: | 4083 case kMathFloor: |
| 4070 case kMathAbs: | 4084 case kMathAbs: |
| 4071 case kMathSqrt: | 4085 case kMathSqrt: |
| 4072 case kMathLog: | 4086 case kMathLog: |
| 4073 case kMathSin: | 4087 case kMathSin: |
| (...skipping 1067 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5141 VISIT_FOR_VALUE(call->arguments()->at(1)); | 5155 VISIT_FOR_VALUE(call->arguments()->at(1)); |
| 5142 HValue* index = Pop(); | 5156 HValue* index = Pop(); |
| 5143 HValue* string = Pop(); | 5157 HValue* string = Pop(); |
| 5144 HStringCharCodeAt* result = BuildStringCharCodeAt(string, index); | 5158 HStringCharCodeAt* result = BuildStringCharCodeAt(string, index); |
| 5145 ast_context()->ReturnInstruction(result, call->id()); | 5159 ast_context()->ReturnInstruction(result, call->id()); |
| 5146 } | 5160 } |
| 5147 | 5161 |
| 5148 | 5162 |
| 5149 // Fast support for string.charAt(n) and string[n]. | 5163 // Fast support for string.charAt(n) and string[n]. |
| 5150 void HGraphBuilder::GenerateStringCharFromCode(CallRuntime* call) { | 5164 void HGraphBuilder::GenerateStringCharFromCode(CallRuntime* call) { |
| 5151 BAILOUT("inlined runtime function: StringCharFromCode"); | 5165 ASSERT(call->arguments()->length() == 1); |
| 5166 VISIT_FOR_VALUE(call->arguments()->at(0)); |
| 5167 HValue* char_code = Pop(); |
| 5168 HStringCharFromCode* result = new HStringCharFromCode(char_code); |
| 5169 ast_context()->ReturnInstruction(result, call->id()); |
| 5152 } | 5170 } |
| 5153 | 5171 |
| 5154 | 5172 |
| 5155 // Fast support for string.charAt(n) and string[n]. | 5173 // Fast support for string.charAt(n) and string[n]. |
| 5156 void HGraphBuilder::GenerateStringCharAt(CallRuntime* call) { | 5174 void HGraphBuilder::GenerateStringCharAt(CallRuntime* call) { |
| 5157 ASSERT_EQ(2, call->arguments()->length()); | 5175 ASSERT(call->arguments()->length() == 2); |
| 5158 VisitArgumentList(call->arguments()); | 5176 VISIT_FOR_VALUE(call->arguments()->at(0)); |
| 5159 CHECK_BAILOUT; | 5177 VISIT_FOR_VALUE(call->arguments()->at(1)); |
| 5160 HContext* context = new HContext; | 5178 HValue* index = Pop(); |
| 5161 AddInstruction(context); | 5179 HValue* string = Pop(); |
| 5162 HCallStub* result = new HCallStub(context, CodeStub::StringCharAt, 2); | 5180 HStringCharCodeAt* char_code = BuildStringCharCodeAt(string, index); |
| 5163 Drop(2); | 5181 AddInstruction(char_code); |
| 5182 HStringCharFromCode* result = new HStringCharFromCode(char_code); |
| 5164 ast_context()->ReturnInstruction(result, call->id()); | 5183 ast_context()->ReturnInstruction(result, call->id()); |
| 5165 } | 5184 } |
| 5166 | 5185 |
| 5167 | 5186 |
| 5168 // Fast support for object equality testing. | 5187 // Fast support for object equality testing. |
| 5169 void HGraphBuilder::GenerateObjectEquals(CallRuntime* call) { | 5188 void HGraphBuilder::GenerateObjectEquals(CallRuntime* call) { |
| 5170 ASSERT(call->arguments()->length() == 2); | 5189 ASSERT(call->arguments()->length() == 2); |
| 5171 VISIT_FOR_VALUE(call->arguments()->at(0)); | 5190 VISIT_FOR_VALUE(call->arguments()->at(0)); |
| 5172 VISIT_FOR_VALUE(call->arguments()->at(1)); | 5191 VISIT_FOR_VALUE(call->arguments()->at(1)); |
| 5173 HValue* right = Pop(); | 5192 HValue* right = Pop(); |
| (...skipping 702 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5876 } | 5895 } |
| 5877 } | 5896 } |
| 5878 | 5897 |
| 5879 #ifdef DEBUG | 5898 #ifdef DEBUG |
| 5880 if (graph_ != NULL) graph_->Verify(); | 5899 if (graph_ != NULL) graph_->Verify(); |
| 5881 if (allocator_ != NULL) allocator_->Verify(); | 5900 if (allocator_ != NULL) allocator_->Verify(); |
| 5882 #endif | 5901 #endif |
| 5883 } | 5902 } |
| 5884 | 5903 |
| 5885 } } // namespace v8::internal | 5904 } } // namespace v8::internal |
| OLD | NEW |