| 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 560 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 571     case kStringCharCodeAt: | 571     case kStringCharCodeAt: | 
| 572     case kStringCharAt: | 572     case kStringCharAt: | 
| 573       if (object->IsString()) { | 573       if (object->IsString()) { | 
| 574         String* string = String::cast(*object); | 574         String* string = String::cast(*object); | 
| 575         // Check there's the right string value or wrapper in the receiver slot. | 575         // Check there's the right string value or wrapper in the receiver slot. | 
| 576         ASSERT(string == args[0] || string == JSValue::cast(args[0])->value()); | 576         ASSERT(string == args[0] || string == JSValue::cast(args[0])->value()); | 
| 577         // If we're in the default (fastest) state and the index is | 577         // If we're in the default (fastest) state and the index is | 
| 578         // out of bounds, update the state to record this fact. | 578         // out of bounds, update the state to record this fact. | 
| 579         if (StringStubState::decode(*extra_ic_state) == DEFAULT_STRING_STUB && | 579         if (StringStubState::decode(*extra_ic_state) == DEFAULT_STRING_STUB && | 
| 580             argc >= 1 && args[1]->IsNumber()) { | 580             argc >= 1 && args[1]->IsNumber()) { | 
| 581           double index; | 581           double index = DoubleToInteger(args.number_at(1)); | 
| 582           if (args[1]->IsSmi()) { |  | 
| 583             index = Smi::cast(args[1])->value(); |  | 
| 584           } else { |  | 
| 585             ASSERT(args[1]->IsHeapNumber()); |  | 
| 586             index = DoubleToInteger(HeapNumber::cast(args[1])->value()); |  | 
| 587           } |  | 
| 588           if (index < 0 || index >= string->length()) { | 582           if (index < 0 || index >= string->length()) { | 
| 589             *extra_ic_state = | 583             *extra_ic_state = | 
| 590                 StringStubState::update(*extra_ic_state, | 584                 StringStubState::update(*extra_ic_state, | 
| 591                                         STRING_INDEX_OUT_OF_BOUNDS); | 585                                         STRING_INDEX_OUT_OF_BOUNDS); | 
| 592             return true; | 586             return true; | 
| 593           } | 587           } | 
| 594         } | 588         } | 
| 595       } | 589       } | 
| 596       break; | 590       break; | 
| 597     default: | 591     default: | 
| (...skipping 1689 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 2287 | 2281 | 
| 2288   return GENERIC; | 2282   return GENERIC; | 
| 2289 } | 2283 } | 
| 2290 | 2284 | 
| 2291 | 2285 | 
| 2292 RUNTIME_FUNCTION(MaybeObject*, UnaryOp_Patch) { | 2286 RUNTIME_FUNCTION(MaybeObject*, UnaryOp_Patch) { | 
| 2293   ASSERT(args.length() == 4); | 2287   ASSERT(args.length() == 4); | 
| 2294 | 2288 | 
| 2295   HandleScope scope(isolate); | 2289   HandleScope scope(isolate); | 
| 2296   Handle<Object> operand = args.at<Object>(0); | 2290   Handle<Object> operand = args.at<Object>(0); | 
| 2297   int key = Smi::cast(args[1])->value(); | 2291   int key = args.smi_at(1); | 
| 2298   Token::Value op = static_cast<Token::Value>(Smi::cast(args[2])->value()); | 2292   Token::Value op = static_cast<Token::Value>(args.smi_at(2)); | 
| 2299   UnaryOpIC::TypeInfo previous_type = | 2293   UnaryOpIC::TypeInfo previous_type = | 
| 2300       static_cast<UnaryOpIC::TypeInfo>(Smi::cast(args[3])->value()); | 2294       static_cast<UnaryOpIC::TypeInfo>(args.smi_at(3)); | 
| 2301 | 2295 | 
| 2302   UnaryOpIC::TypeInfo type = UnaryOpIC::GetTypeInfo(operand); | 2296   UnaryOpIC::TypeInfo type = UnaryOpIC::GetTypeInfo(operand); | 
| 2303   type = UnaryOpIC::ComputeNewType(type, previous_type); | 2297   type = UnaryOpIC::ComputeNewType(type, previous_type); | 
| 2304 | 2298 | 
| 2305   UnaryOpStub stub(key, type); | 2299   UnaryOpStub stub(key, type); | 
| 2306   Handle<Code> code = stub.GetCode(); | 2300   Handle<Code> code = stub.GetCode(); | 
| 2307   if (!code.is_null()) { | 2301   if (!code.is_null()) { | 
| 2308     if (FLAG_trace_ic) { | 2302     if (FLAG_trace_ic) { | 
| 2309       PrintF("[UnaryOpIC (%s->%s)#%s]\n", | 2303       PrintF("[UnaryOpIC (%s->%s)#%s]\n", | 
| 2310              UnaryOpIC::GetName(previous_type), | 2304              UnaryOpIC::GetName(previous_type), | 
| (...skipping 28 matching lines...) Expand all  Loading... | 
| 2339   } | 2333   } | 
| 2340   return *result; | 2334   return *result; | 
| 2341 } | 2335 } | 
| 2342 | 2336 | 
| 2343 RUNTIME_FUNCTION(MaybeObject*, BinaryOp_Patch) { | 2337 RUNTIME_FUNCTION(MaybeObject*, BinaryOp_Patch) { | 
| 2344   ASSERT(args.length() == 5); | 2338   ASSERT(args.length() == 5); | 
| 2345 | 2339 | 
| 2346   HandleScope scope(isolate); | 2340   HandleScope scope(isolate); | 
| 2347   Handle<Object> left = args.at<Object>(0); | 2341   Handle<Object> left = args.at<Object>(0); | 
| 2348   Handle<Object> right = args.at<Object>(1); | 2342   Handle<Object> right = args.at<Object>(1); | 
| 2349   int key = Smi::cast(args[2])->value(); | 2343   int key = args.smi_at(2); | 
| 2350   Token::Value op = static_cast<Token::Value>(Smi::cast(args[3])->value()); | 2344   Token::Value op = static_cast<Token::Value>(args.smi_at(3)); | 
| 2351   BinaryOpIC::TypeInfo previous_type = | 2345   BinaryOpIC::TypeInfo previous_type = | 
| 2352       static_cast<BinaryOpIC::TypeInfo>(Smi::cast(args[4])->value()); | 2346       static_cast<BinaryOpIC::TypeInfo>(args.smi_at(4)); | 
| 2353 | 2347 | 
| 2354   BinaryOpIC::TypeInfo type = BinaryOpIC::GetTypeInfo(left, right); | 2348   BinaryOpIC::TypeInfo type = BinaryOpIC::GetTypeInfo(left, right); | 
| 2355   type = BinaryOpIC::JoinTypes(type, previous_type); | 2349   type = BinaryOpIC::JoinTypes(type, previous_type); | 
| 2356   BinaryOpIC::TypeInfo result_type = BinaryOpIC::UNINITIALIZED; | 2350   BinaryOpIC::TypeInfo result_type = BinaryOpIC::UNINITIALIZED; | 
| 2357   if ((type == BinaryOpIC::STRING || type == BinaryOpIC::BOTH_STRING) && | 2351   if ((type == BinaryOpIC::STRING || type == BinaryOpIC::BOTH_STRING) && | 
| 2358       op != Token::ADD) { | 2352       op != Token::ADD) { | 
| 2359     type = BinaryOpIC::GENERIC; | 2353     type = BinaryOpIC::GENERIC; | 
| 2360   } | 2354   } | 
| 2361   if (type == BinaryOpIC::SMI && previous_type == BinaryOpIC::SMI) { | 2355   if (type == BinaryOpIC::SMI && previous_type == BinaryOpIC::SMI) { | 
| 2362     if (op == Token::DIV || | 2356     if (op == Token::DIV || | 
| (...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 2502   if (state == UNINITIALIZED && | 2496   if (state == UNINITIALIZED && | 
| 2503       x->IsJSObject() && y->IsJSObject()) return OBJECTS; | 2497       x->IsJSObject() && y->IsJSObject()) return OBJECTS; | 
| 2504   return GENERIC; | 2498   return GENERIC; | 
| 2505 } | 2499 } | 
| 2506 | 2500 | 
| 2507 | 2501 | 
| 2508 // Used from ic_<arch>.cc. | 2502 // Used from ic_<arch>.cc. | 
| 2509 RUNTIME_FUNCTION(Code*, CompareIC_Miss) { | 2503 RUNTIME_FUNCTION(Code*, CompareIC_Miss) { | 
| 2510   NoHandleAllocation na; | 2504   NoHandleAllocation na; | 
| 2511   ASSERT(args.length() == 3); | 2505   ASSERT(args.length() == 3); | 
| 2512   CompareIC ic(isolate, static_cast<Token::Value>(Smi::cast(args[2])->value())); | 2506   CompareIC ic(isolate, static_cast<Token::Value>(args.smi_at(2))); | 
| 2513   ic.UpdateCaches(args.at<Object>(0), args.at<Object>(1)); | 2507   ic.UpdateCaches(args.at<Object>(0), args.at<Object>(1)); | 
| 2514   return ic.target(); | 2508   return ic.target(); | 
| 2515 } | 2509 } | 
| 2516 | 2510 | 
| 2517 | 2511 | 
| 2518 static const Address IC_utilities[] = { | 2512 static const Address IC_utilities[] = { | 
| 2519 #define ADDR(name) FUNCTION_ADDR(name), | 2513 #define ADDR(name) FUNCTION_ADDR(name), | 
| 2520     IC_UTIL_LIST(ADDR) | 2514     IC_UTIL_LIST(ADDR) | 
| 2521     NULL | 2515     NULL | 
| 2522 #undef ADDR | 2516 #undef ADDR | 
| 2523 }; | 2517 }; | 
| 2524 | 2518 | 
| 2525 | 2519 | 
| 2526 Address IC::AddressFromUtilityId(IC::UtilityId id) { | 2520 Address IC::AddressFromUtilityId(IC::UtilityId id) { | 
| 2527   return IC_utilities[id]; | 2521   return IC_utilities[id]; | 
| 2528 } | 2522 } | 
| 2529 | 2523 | 
| 2530 | 2524 | 
| 2531 } }  // namespace v8::internal | 2525 } }  // namespace v8::internal | 
| OLD | NEW | 
|---|