| 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 3685 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3696 AddInstruction(new HCheckInstanceType(array, JS_ARRAY_TYPE, JS_ARRAY_TYPE)); | 3696 AddInstruction(new HCheckInstanceType(array, JS_ARRAY_TYPE, JS_ARRAY_TYPE)); |
| 3697 instr = new HJSArrayLength(array); | 3697 instr = new HJSArrayLength(array); |
| 3698 | 3698 |
| 3699 } else if (expr->IsStringLength()) { | 3699 } else if (expr->IsStringLength()) { |
| 3700 HValue* string = Pop(); | 3700 HValue* string = Pop(); |
| 3701 AddInstruction(new HCheckNonSmi(string)); | 3701 AddInstruction(new HCheckNonSmi(string)); |
| 3702 AddInstruction(new HCheckInstanceType(string, | 3702 AddInstruction(new HCheckInstanceType(string, |
| 3703 FIRST_STRING_TYPE, | 3703 FIRST_STRING_TYPE, |
| 3704 LAST_STRING_TYPE)); | 3704 LAST_STRING_TYPE)); |
| 3705 instr = new HStringLength(string); | 3705 instr = new HStringLength(string); |
| 3706 } else if (expr->IsStringAccess()) { |
| 3707 VISIT_FOR_VALUE(expr->key()); |
| 3708 HValue* index = Pop(); |
| 3709 HValue* string = Pop(); |
| 3710 HStringCharCodeAt* char_code = BuildStringCharCodeAt(string, index); |
| 3711 AddInstruction(char_code); |
| 3712 instr = new HStringCharFromCode(char_code); |
| 3706 | 3713 |
| 3707 } else if (expr->IsFunctionPrototype()) { | 3714 } else if (expr->IsFunctionPrototype()) { |
| 3708 HValue* function = Pop(); | 3715 HValue* function = Pop(); |
| 3709 AddInstruction(new HCheckNonSmi(function)); | 3716 AddInstruction(new HCheckNonSmi(function)); |
| 3710 instr = new HLoadFunctionPrototype(function); | 3717 instr = new HLoadFunctionPrototype(function); |
| 3711 | 3718 |
| 3712 } else if (expr->key()->IsPropertyName()) { | 3719 } else if (expr->key()->IsPropertyName()) { |
| 3713 Handle<String> name = expr->key()->AsLiteral()->AsPropertyName(); | 3720 Handle<String> name = expr->key()->AsLiteral()->AsPropertyName(); |
| 3714 ZoneMapList* types = expr->GetReceiverTypes(); | 3721 ZoneMapList* types = expr->GetReceiverTypes(); |
| 3715 | 3722 |
| (...skipping 360 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4076 HValue* receiver, | 4083 HValue* receiver, |
| 4077 Handle<Map> receiver_map, | 4084 Handle<Map> receiver_map, |
| 4078 CheckType check_type) { | 4085 CheckType check_type) { |
| 4079 ASSERT(check_type != RECEIVER_MAP_CHECK || !receiver_map.is_null()); | 4086 ASSERT(check_type != RECEIVER_MAP_CHECK || !receiver_map.is_null()); |
| 4080 // Try to inline calls like Math.* as operations in the calling function. | 4087 // Try to inline calls like Math.* as operations in the calling function. |
| 4081 if (!expr->target()->shared()->HasBuiltinFunctionId()) return false; | 4088 if (!expr->target()->shared()->HasBuiltinFunctionId()) return false; |
| 4082 BuiltinFunctionId id = expr->target()->shared()->builtin_function_id(); | 4089 BuiltinFunctionId id = expr->target()->shared()->builtin_function_id(); |
| 4083 int argument_count = expr->arguments()->length() + 1; // Plus receiver. | 4090 int argument_count = expr->arguments()->length() + 1; // Plus receiver. |
| 4084 switch (id) { | 4091 switch (id) { |
| 4085 case kStringCharCodeAt: | 4092 case kStringCharCodeAt: |
| 4093 case kStringCharAt: |
| 4086 if (argument_count == 2 && check_type == STRING_CHECK) { | 4094 if (argument_count == 2 && check_type == STRING_CHECK) { |
| 4087 HValue* index = Pop(); | 4095 HValue* index = Pop(); |
| 4088 HValue* string = Pop(); | 4096 HValue* string = Pop(); |
| 4089 ASSERT(!expr->holder().is_null()); | 4097 ASSERT(!expr->holder().is_null()); |
| 4090 AddInstruction(new HCheckPrototypeMaps( | 4098 AddInstruction(new HCheckPrototypeMaps( |
| 4091 oracle()->GetPrototypeForPrimitiveCheck(STRING_CHECK), | 4099 oracle()->GetPrototypeForPrimitiveCheck(STRING_CHECK), |
| 4092 expr->holder())); | 4100 expr->holder())); |
| 4093 HStringCharCodeAt* result = BuildStringCharCodeAt(string, index); | 4101 HStringCharCodeAt* char_code = BuildStringCharCodeAt(string, index); |
| 4102 if (id == kStringCharCodeAt) { |
| 4103 ast_context()->ReturnInstruction(char_code, expr->id()); |
| 4104 return true; |
| 4105 } |
| 4106 AddInstruction(char_code); |
| 4107 HStringCharFromCode* result = new HStringCharFromCode(char_code); |
| 4094 ast_context()->ReturnInstruction(result, expr->id()); | 4108 ast_context()->ReturnInstruction(result, expr->id()); |
| 4095 return true; | 4109 return true; |
| 4096 } | 4110 } |
| 4097 break; | 4111 break; |
| 4098 case kMathRound: | 4112 case kMathRound: |
| 4099 case kMathFloor: | 4113 case kMathFloor: |
| 4100 case kMathAbs: | 4114 case kMathAbs: |
| 4101 case kMathSqrt: | 4115 case kMathSqrt: |
| 4102 case kMathLog: | 4116 case kMathLog: |
| 4103 case kMathSin: | 4117 case kMathSin: |
| (...skipping 1067 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5171 VISIT_FOR_VALUE(call->arguments()->at(1)); | 5185 VISIT_FOR_VALUE(call->arguments()->at(1)); |
| 5172 HValue* index = Pop(); | 5186 HValue* index = Pop(); |
| 5173 HValue* string = Pop(); | 5187 HValue* string = Pop(); |
| 5174 HStringCharCodeAt* result = BuildStringCharCodeAt(string, index); | 5188 HStringCharCodeAt* result = BuildStringCharCodeAt(string, index); |
| 5175 ast_context()->ReturnInstruction(result, call->id()); | 5189 ast_context()->ReturnInstruction(result, call->id()); |
| 5176 } | 5190 } |
| 5177 | 5191 |
| 5178 | 5192 |
| 5179 // Fast support for string.charAt(n) and string[n]. | 5193 // Fast support for string.charAt(n) and string[n]. |
| 5180 void HGraphBuilder::GenerateStringCharFromCode(CallRuntime* call) { | 5194 void HGraphBuilder::GenerateStringCharFromCode(CallRuntime* call) { |
| 5181 BAILOUT("inlined runtime function: StringCharFromCode"); | 5195 ASSERT(call->arguments()->length() == 1); |
| 5196 VISIT_FOR_VALUE(call->arguments()->at(0)); |
| 5197 HValue* char_code = Pop(); |
| 5198 HStringCharFromCode* result = new HStringCharFromCode(char_code); |
| 5199 ast_context()->ReturnInstruction(result, call->id()); |
| 5182 } | 5200 } |
| 5183 | 5201 |
| 5184 | 5202 |
| 5185 // Fast support for string.charAt(n) and string[n]. | 5203 // Fast support for string.charAt(n) and string[n]. |
| 5186 void HGraphBuilder::GenerateStringCharAt(CallRuntime* call) { | 5204 void HGraphBuilder::GenerateStringCharAt(CallRuntime* call) { |
| 5187 ASSERT_EQ(2, call->arguments()->length()); | 5205 ASSERT(call->arguments()->length() == 2); |
| 5188 VisitArgumentList(call->arguments()); | 5206 VISIT_FOR_VALUE(call->arguments()->at(0)); |
| 5189 CHECK_BAILOUT; | 5207 VISIT_FOR_VALUE(call->arguments()->at(1)); |
| 5190 HContext* context = new HContext; | 5208 HValue* index = Pop(); |
| 5191 AddInstruction(context); | 5209 HValue* string = Pop(); |
| 5192 HCallStub* result = new HCallStub(context, CodeStub::StringCharAt, 2); | 5210 HStringCharCodeAt* char_code = BuildStringCharCodeAt(string, index); |
| 5193 Drop(2); | 5211 AddInstruction(char_code); |
| 5212 HStringCharFromCode* result = new HStringCharFromCode(char_code); |
| 5194 ast_context()->ReturnInstruction(result, call->id()); | 5213 ast_context()->ReturnInstruction(result, call->id()); |
| 5195 } | 5214 } |
| 5196 | 5215 |
| 5197 | 5216 |
| 5198 // Fast support for object equality testing. | 5217 // Fast support for object equality testing. |
| 5199 void HGraphBuilder::GenerateObjectEquals(CallRuntime* call) { | 5218 void HGraphBuilder::GenerateObjectEquals(CallRuntime* call) { |
| 5200 ASSERT(call->arguments()->length() == 2); | 5219 ASSERT(call->arguments()->length() == 2); |
| 5201 VISIT_FOR_VALUE(call->arguments()->at(0)); | 5220 VISIT_FOR_VALUE(call->arguments()->at(0)); |
| 5202 VISIT_FOR_VALUE(call->arguments()->at(1)); | 5221 VISIT_FOR_VALUE(call->arguments()->at(1)); |
| 5203 HValue* right = Pop(); | 5222 HValue* right = Pop(); |
| (...skipping 702 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5906 } | 5925 } |
| 5907 } | 5926 } |
| 5908 | 5927 |
| 5909 #ifdef DEBUG | 5928 #ifdef DEBUG |
| 5910 if (graph_ != NULL) graph_->Verify(); | 5929 if (graph_ != NULL) graph_->Verify(); |
| 5911 if (allocator_ != NULL) allocator_->Verify(); | 5930 if (allocator_ != NULL) allocator_->Verify(); |
| 5912 #endif | 5931 #endif |
| 5913 } | 5932 } |
| 5914 | 5933 |
| 5915 } } // namespace v8::internal | 5934 } } // namespace v8::internal |
| OLD | NEW |