| OLD | NEW |
| 1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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 213 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 224 if (proto->IsNull()) { | 224 if (proto->IsNull()) { |
| 225 ASSERT(!lookup->IsFound()); | 225 ASSERT(!lookup->IsFound()); |
| 226 return; | 226 return; |
| 227 } | 227 } |
| 228 | 228 |
| 229 object = proto; | 229 object = proto; |
| 230 } | 230 } |
| 231 } | 231 } |
| 232 | 232 |
| 233 | 233 |
| 234 bool CallIC::TryUpdateExtraICState(LookupResult* lookup, | |
| 235 Handle<Object> object) { | |
| 236 if (!lookup->IsConstantFunction()) return false; | |
| 237 JSFunction* function = lookup->GetConstantFunction(); | |
| 238 if (!function->shared()->HasBuiltinFunctionId()) return false; | |
| 239 | |
| 240 // Fetch the arguments passed to the called function. | |
| 241 const int argc = target()->arguments_count(); | |
| 242 Address entry = isolate()->c_entry_fp(isolate()->thread_local_top()); | |
| 243 Address fp = Memory::Address_at(entry + ExitFrameConstants::kCallerFPOffset); | |
| 244 Arguments args(argc + 1, | |
| 245 &Memory::Object_at(fp + | |
| 246 StandardFrameConstants::kCallerSPOffset + | |
| 247 argc * kPointerSize)); | |
| 248 switch (function->shared()->builtin_function_id()) { | |
| 249 case kStringCharCodeAt: | |
| 250 case kStringCharAt: | |
| 251 if (object->IsString()) { | |
| 252 String* string = String::cast(*object); | |
| 253 // Check there's the right string value or wrapper in the receiver slot. | |
| 254 ASSERT(string == args[0] || string == JSValue::cast(args[0])->value()); | |
| 255 // If we're in the default (fastest) state and the index is | |
| 256 // out of bounds, update the state to record this fact. | |
| 257 if (StringStubState::decode(extra_ic_state()) == DEFAULT_STRING_STUB && | |
| 258 argc >= 1 && args[1]->IsNumber()) { | |
| 259 double index = DoubleToInteger(args.number_at(1)); | |
| 260 if (index < 0 || index >= string->length()) { | |
| 261 set_extra_ic_state(StringStubState::update(extra_ic_state(), | |
| 262 STRING_INDEX_OUT_OF_BOUNDS)); | |
| 263 return true; | |
| 264 } | |
| 265 } | |
| 266 } | |
| 267 break; | |
| 268 default: | |
| 269 return false; | |
| 270 } | |
| 271 return false; | |
| 272 } | |
| 273 | |
| 274 | |
| 275 bool IC::TryRemoveInvalidPrototypeDependentStub(Handle<Object> receiver, | 234 bool IC::TryRemoveInvalidPrototypeDependentStub(Handle<Object> receiver, |
| 276 Handle<String> name) { | 235 Handle<String> name) { |
| 277 if (target()->is_call_stub()) { | |
| 278 LookupResult lookup(isolate()); | |
| 279 LookupForRead(receiver, name, &lookup); | |
| 280 if (static_cast<CallIC*>(this)->TryUpdateExtraICState(&lookup, receiver)) { | |
| 281 return true; | |
| 282 } | |
| 283 } | |
| 284 | |
| 285 if (target()->is_keyed_stub()) { | 236 if (target()->is_keyed_stub()) { |
| 286 // Determine whether the failure is due to a name failure. | 237 // Determine whether the failure is due to a name failure. |
| 287 if (!name->IsName()) return false; | 238 if (!name->IsName()) return false; |
| 288 Name* stub_name = target()->FindFirstName(); | 239 Name* stub_name = target()->FindFirstName(); |
| 289 if (*name != stub_name) return false; | 240 if (*name != stub_name) return false; |
| 290 } | 241 } |
| 291 | 242 |
| 292 InlineCacheHolderFlag cache_holder = | 243 InlineCacheHolderFlag cache_holder = |
| 293 Code::ExtractCacheHolderFromFlags(target()->flags()); | 244 Code::ExtractCacheHolderFromFlags(target()->flags()); |
| 294 | 245 |
| (...skipping 2923 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3218 #undef ADDR | 3169 #undef ADDR |
| 3219 }; | 3170 }; |
| 3220 | 3171 |
| 3221 | 3172 |
| 3222 Address IC::AddressFromUtilityId(IC::UtilityId id) { | 3173 Address IC::AddressFromUtilityId(IC::UtilityId id) { |
| 3223 return IC_utilities[id]; | 3174 return IC_utilities[id]; |
| 3224 } | 3175 } |
| 3225 | 3176 |
| 3226 | 3177 |
| 3227 } } // namespace v8::internal | 3178 } } // namespace v8::internal |
| OLD | NEW |