| 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 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 92 TypeFeedbackId ast_id) { | 92 TypeFeedbackId ast_id) { |
| 93 int entry = dictionary_->FindEntry(IdToKey(ast_id)); | 93 int entry = dictionary_->FindEntry(IdToKey(ast_id)); |
| 94 if (entry != UnseededNumberDictionary::kNotFound) { | 94 if (entry != UnseededNumberDictionary::kNotFound) { |
| 95 Cell* cell = Cell::cast(dictionary_->ValueAt(entry)); | 95 Cell* cell = Cell::cast(dictionary_->ValueAt(entry)); |
| 96 return Handle<Cell>(cell, isolate_); | 96 return Handle<Cell>(cell, isolate_); |
| 97 } | 97 } |
| 98 return Handle<Cell>::null(); | 98 return Handle<Cell>::null(); |
| 99 } | 99 } |
| 100 | 100 |
| 101 | 101 |
| 102 bool TypeFeedbackOracle::LoadIsUninitialized(Property* expr) { | 102 bool TypeFeedbackOracle::LoadIsUninitialized(TypeFeedbackId id) { |
| 103 Handle<Object> map_or_code = GetInfo(expr->PropertyFeedbackId()); | 103 Handle<Object> map_or_code = GetInfo(id); |
| 104 if (map_or_code->IsMap()) return false; | 104 if (map_or_code->IsMap()) return false; |
| 105 if (map_or_code->IsCode()) { | 105 if (map_or_code->IsCode()) { |
| 106 Handle<Code> code = Handle<Code>::cast(map_or_code); | 106 Handle<Code> code = Handle<Code>::cast(map_or_code); |
| 107 return code->is_inline_cache_stub() && code->ic_state() == UNINITIALIZED; | 107 return code->is_inline_cache_stub() && code->ic_state() == UNINITIALIZED; |
| 108 } | 108 } |
| 109 return false; | 109 return false; |
| 110 } | 110 } |
| 111 | 111 |
| 112 | 112 |
| 113 bool TypeFeedbackOracle::LoadIsMonomorphicNormal(Property* expr) { | 113 bool TypeFeedbackOracle::LoadIsMonomorphicNormal(TypeFeedbackId id) { |
| 114 Handle<Object> map_or_code = GetInfo(expr->PropertyFeedbackId()); | 114 Handle<Object> map_or_code = GetInfo(id); |
| 115 if (map_or_code->IsMap()) return true; | 115 if (map_or_code->IsMap()) return true; |
| 116 if (map_or_code->IsCode()) { | 116 if (map_or_code->IsCode()) { |
| 117 Handle<Code> code = Handle<Code>::cast(map_or_code); | 117 Handle<Code> code = Handle<Code>::cast(map_or_code); |
| 118 bool preliminary_checks = code->is_keyed_load_stub() && | 118 bool preliminary_checks = code->is_keyed_load_stub() && |
| 119 code->ic_state() == MONOMORPHIC && | 119 code->ic_state() == MONOMORPHIC && |
| 120 Code::ExtractTypeFromFlags(code->flags()) == Code::NORMAL; | 120 Code::ExtractTypeFromFlags(code->flags()) == Code::NORMAL; |
| 121 if (!preliminary_checks) return false; | 121 if (!preliminary_checks) return false; |
| 122 Map* map = code->FindFirstMap(); | 122 Map* map = code->FindFirstMap(); |
| 123 if (map == NULL) return false; | 123 if (map == NULL) return false; |
| 124 map = map->CurrentMapForDeprecated(); | 124 map = map->CurrentMapForDeprecated(); |
| 125 return map != NULL && !CanRetainOtherContext(map, *native_context_); | 125 return map != NULL && !CanRetainOtherContext(map, *native_context_); |
| 126 } | 126 } |
| 127 return false; | 127 return false; |
| 128 } | 128 } |
| 129 | 129 |
| 130 | 130 |
| 131 bool TypeFeedbackOracle::LoadIsPreMonomorphic(Property* expr) { | 131 bool TypeFeedbackOracle::LoadIsPreMonomorphic(TypeFeedbackId id) { |
| 132 Handle<Object> map_or_code = GetInfo(expr->PropertyFeedbackId()); | 132 Handle<Object> map_or_code = GetInfo(id); |
| 133 if (map_or_code->IsCode()) { | 133 if (map_or_code->IsCode()) { |
| 134 Handle<Code> code = Handle<Code>::cast(map_or_code); | 134 Handle<Code> code = Handle<Code>::cast(map_or_code); |
| 135 return code->is_inline_cache_stub() && code->ic_state() == PREMONOMORPHIC; | 135 return code->is_inline_cache_stub() && code->ic_state() == PREMONOMORPHIC; |
| 136 } | 136 } |
| 137 return false; | 137 return false; |
| 138 } | 138 } |
| 139 | 139 |
| 140 | 140 |
| 141 bool TypeFeedbackOracle::LoadIsPolymorphic(Property* expr) { | 141 bool TypeFeedbackOracle::LoadIsPolymorphic(TypeFeedbackId id) { |
| 142 Handle<Object> map_or_code = GetInfo(expr->PropertyFeedbackId()); | 142 Handle<Object> map_or_code = GetInfo(id); |
| 143 if (map_or_code->IsCode()) { | 143 if (map_or_code->IsCode()) { |
| 144 Handle<Code> code = Handle<Code>::cast(map_or_code); | 144 Handle<Code> code = Handle<Code>::cast(map_or_code); |
| 145 return code->is_keyed_load_stub() && code->ic_state() == POLYMORPHIC; | 145 return code->is_keyed_load_stub() && code->ic_state() == POLYMORPHIC; |
| 146 } | 146 } |
| 147 return false; | 147 return false; |
| 148 } | 148 } |
| 149 | 149 |
| 150 | 150 |
| 151 bool TypeFeedbackOracle::StoreIsUninitialized(TypeFeedbackId ast_id) { | 151 bool TypeFeedbackOracle::StoreIsUninitialized(TypeFeedbackId ast_id) { |
| 152 Handle<Object> map_or_code = GetInfo(ast_id); | 152 Handle<Object> map_or_code = GetInfo(ast_id); |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 190 Handle<Object> map_or_code = GetInfo(ast_id); | 190 Handle<Object> map_or_code = GetInfo(ast_id); |
| 191 if (map_or_code->IsCode()) { | 191 if (map_or_code->IsCode()) { |
| 192 Handle<Code> code = Handle<Code>::cast(map_or_code); | 192 Handle<Code> code = Handle<Code>::cast(map_or_code); |
| 193 return code->is_keyed_store_stub() && | 193 return code->is_keyed_store_stub() && |
| 194 code->ic_state() == POLYMORPHIC; | 194 code->ic_state() == POLYMORPHIC; |
| 195 } | 195 } |
| 196 return false; | 196 return false; |
| 197 } | 197 } |
| 198 | 198 |
| 199 | 199 |
| 200 bool TypeFeedbackOracle::CallIsMonomorphic(Call* expr) { | 200 bool TypeFeedbackOracle::CallIsMonomorphic(TypeFeedbackId id) { |
| 201 Handle<Object> value = GetInfo(expr->CallFeedbackId()); | 201 Handle<Object> value = GetInfo(id); |
| 202 return value->IsMap() || value->IsAllocationSite() || value->IsJSFunction() || | 202 return value->IsMap() || value->IsAllocationSite() || value->IsJSFunction() || |
| 203 value->IsSmi() || | 203 value->IsSmi() || |
| 204 (value->IsCode() && Handle<Code>::cast(value)->ic_state() == MONOMORPHIC); | 204 (value->IsCode() && Handle<Code>::cast(value)->ic_state() == MONOMORPHIC); |
| 205 } | 205 } |
| 206 | 206 |
| 207 | 207 |
| 208 bool TypeFeedbackOracle::KeyedArrayCallIsHoley(Call* expr) { | 208 bool TypeFeedbackOracle::KeyedArrayCallIsHoley(TypeFeedbackId id) { |
| 209 Handle<Object> value = GetInfo(expr->CallFeedbackId()); | 209 Handle<Object> value = GetInfo(id); |
| 210 Handle<Code> code = Handle<Code>::cast(value); | 210 Handle<Code> code = Handle<Code>::cast(value); |
| 211 return KeyedArrayCallStub::IsHoley(code); | 211 return KeyedArrayCallStub::IsHoley(code); |
| 212 } | 212 } |
| 213 | 213 |
| 214 | 214 |
| 215 bool TypeFeedbackOracle::CallNewIsMonomorphic(CallNew* expr) { | 215 bool TypeFeedbackOracle::CallNewIsMonomorphic(TypeFeedbackId id) { |
| 216 Handle<Object> info = GetInfo(expr->CallNewFeedbackId()); | 216 Handle<Object> info = GetInfo(id); |
| 217 return info->IsAllocationSite() || info->IsJSFunction(); | 217 return info->IsAllocationSite() || info->IsJSFunction(); |
| 218 } | 218 } |
| 219 | 219 |
| 220 | 220 |
| 221 bool TypeFeedbackOracle::ObjectLiteralStoreIsMonomorphic( | 221 bool TypeFeedbackOracle::ObjectLiteralStoreIsMonomorphic(TypeFeedbackId id) { |
| 222 ObjectLiteral::Property* prop) { | 222 Handle<Object> map_or_code = GetInfo(id); |
| 223 Handle<Object> map_or_code = GetInfo(prop->key()->LiteralFeedbackId()); | |
| 224 return map_or_code->IsMap(); | 223 return map_or_code->IsMap(); |
| 225 } | 224 } |
| 226 | 225 |
| 227 | 226 |
| 228 byte TypeFeedbackOracle::ForInType(ForInStatement* stmt) { | 227 byte TypeFeedbackOracle::ForInType(TypeFeedbackId id) { |
| 229 Handle<Object> value = GetInfo(stmt->ForInFeedbackId()); | 228 Handle<Object> value = GetInfo(id); |
| 230 return value->IsSmi() && | 229 return value->IsSmi() && |
| 231 Smi::cast(*value)->value() == TypeFeedbackCells::kForInFastCaseMarker | 230 Smi::cast(*value)->value() == TypeFeedbackCells::kForInFastCaseMarker |
| 232 ? ForInStatement::FAST_FOR_IN : ForInStatement::SLOW_FOR_IN; | 231 ? ForInStatement::FAST_FOR_IN : ForInStatement::SLOW_FOR_IN; |
| 233 } | 232 } |
| 234 | 233 |
| 235 | 234 |
| 236 Handle<Map> TypeFeedbackOracle::LoadMonomorphicReceiverType(Property* expr) { | 235 Handle<Map> TypeFeedbackOracle::LoadMonomorphicReceiverType(TypeFeedbackId id) { |
| 237 ASSERT(LoadIsMonomorphicNormal(expr)); | 236 ASSERT(LoadIsMonomorphicNormal(id)); |
| 238 Handle<Object> map_or_code = GetInfo(expr->PropertyFeedbackId()); | 237 Handle<Object> map_or_code = GetInfo(id); |
| 239 if (map_or_code->IsCode()) { | 238 if (map_or_code->IsCode()) { |
| 240 Handle<Code> code = Handle<Code>::cast(map_or_code); | 239 Handle<Code> code = Handle<Code>::cast(map_or_code); |
| 241 Map* map = code->FindFirstMap()->CurrentMapForDeprecated(); | 240 Map* map = code->FindFirstMap()->CurrentMapForDeprecated(); |
| 242 return map == NULL || CanRetainOtherContext(map, *native_context_) | 241 return map == NULL || CanRetainOtherContext(map, *native_context_) |
| 243 ? Handle<Map>::null() | 242 ? Handle<Map>::null() |
| 244 : Handle<Map>(map); | 243 : Handle<Map>(map); |
| 245 } | 244 } |
| 246 return Handle<Map>::cast(map_or_code); | 245 return Handle<Map>::cast(map_or_code); |
| 247 } | 246 } |
| 248 | 247 |
| (...skipping 12 matching lines...) Expand all Loading... |
| 261 return Handle<Map>::cast(map_or_code); | 260 return Handle<Map>::cast(map_or_code); |
| 262 } | 261 } |
| 263 | 262 |
| 264 | 263 |
| 265 KeyedAccessStoreMode TypeFeedbackOracle::GetStoreMode( | 264 KeyedAccessStoreMode TypeFeedbackOracle::GetStoreMode( |
| 266 TypeFeedbackId ast_id) { | 265 TypeFeedbackId ast_id) { |
| 267 Handle<Object> map_or_code = GetInfo(ast_id); | 266 Handle<Object> map_or_code = GetInfo(ast_id); |
| 268 if (map_or_code->IsCode()) { | 267 if (map_or_code->IsCode()) { |
| 269 Handle<Code> code = Handle<Code>::cast(map_or_code); | 268 Handle<Code> code = Handle<Code>::cast(map_or_code); |
| 270 if (code->kind() == Code::KEYED_STORE_IC) { | 269 if (code->kind() == Code::KEYED_STORE_IC) { |
| 271 return Code::GetKeyedAccessStoreMode(code->extra_ic_state()); | 270 return KeyedStoreIC::GetKeyedAccessStoreMode(code->extra_ic_state()); |
| 272 } | 271 } |
| 273 } | 272 } |
| 274 return STANDARD_STORE; | 273 return STANDARD_STORE; |
| 275 } | 274 } |
| 276 | 275 |
| 277 | 276 |
| 278 void TypeFeedbackOracle::LoadReceiverTypes(Property* expr, | 277 void TypeFeedbackOracle::LoadReceiverTypes(TypeFeedbackId id, |
| 279 Handle<String> name, | 278 Handle<String> name, |
| 280 SmallMapList* types) { | 279 SmallMapList* types) { |
| 281 Code::Flags flags = Code::ComputeFlags( | 280 Code::Flags flags = Code::ComputeFlags( |
| 282 Code::HANDLER, MONOMORPHIC, Code::kNoExtraICState, | 281 Code::HANDLER, MONOMORPHIC, kNoExtraICState, |
| 283 Code::NORMAL, Code::LOAD_IC); | 282 Code::NORMAL, Code::LOAD_IC); |
| 284 CollectReceiverTypes(expr->PropertyFeedbackId(), name, flags, types); | 283 CollectReceiverTypes(id, name, flags, types); |
| 285 } | 284 } |
| 286 | 285 |
| 287 | 286 |
| 288 void TypeFeedbackOracle::StoreReceiverTypes(Assignment* expr, | 287 void TypeFeedbackOracle::StoreReceiverTypes(TypeFeedbackId id, |
| 289 Handle<String> name, | 288 Handle<String> name, |
| 290 SmallMapList* types) { | 289 SmallMapList* types) { |
| 291 Code::Flags flags = Code::ComputeFlags( | 290 Code::Flags flags = Code::ComputeFlags( |
| 292 Code::HANDLER, MONOMORPHIC, Code::kNoExtraICState, | 291 Code::HANDLER, MONOMORPHIC, kNoExtraICState, |
| 293 Code::NORMAL, Code::STORE_IC); | 292 Code::NORMAL, Code::STORE_IC); |
| 294 CollectReceiverTypes(expr->AssignmentFeedbackId(), name, flags, types); | 293 CollectReceiverTypes(id, name, flags, types); |
| 295 } | 294 } |
| 296 | 295 |
| 297 | 296 |
| 298 void TypeFeedbackOracle::CallReceiverTypes(Call* expr, | 297 void TypeFeedbackOracle::CallReceiverTypes(TypeFeedbackId id, |
| 299 Handle<String> name, | 298 Handle<String> name, |
| 299 int arity, |
| 300 CallKind call_kind, | 300 CallKind call_kind, |
| 301 SmallMapList* types) { | 301 SmallMapList* types) { |
| 302 int arity = expr->arguments()->length(); | |
| 303 | |
| 304 // Note: Currently we do not take string extra ic data into account | 302 // Note: Currently we do not take string extra ic data into account |
| 305 // here. | 303 // here. |
| 306 Code::ExtraICState extra_ic_state = | 304 ContextualMode contextual_mode = call_kind == CALL_AS_FUNCTION |
| 307 CallIC::Contextual::encode(call_kind == CALL_AS_FUNCTION); | 305 ? CONTEXTUAL |
| 306 : NOT_CONTEXTUAL; |
| 307 ExtraICState extra_ic_state = |
| 308 CallIC::Contextual::encode(contextual_mode); |
| 308 | 309 |
| 309 Code::Flags flags = Code::ComputeMonomorphicFlags( | 310 Code::Flags flags = Code::ComputeMonomorphicFlags( |
| 310 Code::CALL_IC, extra_ic_state, OWN_MAP, Code::NORMAL, arity); | 311 Code::CALL_IC, extra_ic_state, OWN_MAP, Code::NORMAL, arity); |
| 311 CollectReceiverTypes(expr->CallFeedbackId(), name, flags, types); | 312 CollectReceiverTypes(id, name, flags, types); |
| 312 } | 313 } |
| 313 | 314 |
| 314 | 315 |
| 315 CheckType TypeFeedbackOracle::GetCallCheckType(Call* expr) { | 316 CheckType TypeFeedbackOracle::GetCallCheckType(TypeFeedbackId id) { |
| 316 Handle<Object> value = GetInfo(expr->CallFeedbackId()); | 317 Handle<Object> value = GetInfo(id); |
| 317 if (!value->IsSmi()) return RECEIVER_MAP_CHECK; | 318 if (!value->IsSmi()) return RECEIVER_MAP_CHECK; |
| 318 CheckType check = static_cast<CheckType>(Smi::cast(*value)->value()); | 319 CheckType check = static_cast<CheckType>(Smi::cast(*value)->value()); |
| 319 ASSERT(check != RECEIVER_MAP_CHECK); | 320 ASSERT(check != RECEIVER_MAP_CHECK); |
| 320 return check; | 321 return check; |
| 321 } | 322 } |
| 322 | 323 |
| 323 | 324 |
| 324 Handle<JSFunction> TypeFeedbackOracle::GetCallTarget(Call* expr) { | 325 Handle<JSFunction> TypeFeedbackOracle::GetCallTarget(TypeFeedbackId id) { |
| 325 Handle<Object> info = GetInfo(expr->CallFeedbackId()); | 326 Handle<Object> info = GetInfo(id); |
| 326 if (info->IsAllocationSite()) { | 327 if (info->IsAllocationSite()) { |
| 327 return Handle<JSFunction>(isolate_->global_context()->array_function()); | 328 return Handle<JSFunction>(isolate_->global_context()->array_function()); |
| 328 } else { | 329 } else { |
| 329 return Handle<JSFunction>::cast(info); | 330 return Handle<JSFunction>::cast(info); |
| 330 } | 331 } |
| 331 } | 332 } |
| 332 | 333 |
| 333 | 334 |
| 334 Handle<JSFunction> TypeFeedbackOracle::GetCallNewTarget(CallNew* expr) { | 335 Handle<JSFunction> TypeFeedbackOracle::GetCallNewTarget(TypeFeedbackId id) { |
| 335 Handle<Object> info = GetInfo(expr->CallNewFeedbackId()); | 336 Handle<Object> info = GetInfo(id); |
| 336 if (info->IsAllocationSite()) { | 337 if (info->IsAllocationSite()) { |
| 337 return Handle<JSFunction>(isolate_->global_context()->array_function()); | 338 return Handle<JSFunction>(isolate_->global_context()->array_function()); |
| 338 } else { | 339 } else { |
| 339 return Handle<JSFunction>::cast(info); | 340 return Handle<JSFunction>::cast(info); |
| 340 } | 341 } |
| 341 } | 342 } |
| 342 | 343 |
| 343 | 344 |
| 344 Handle<Cell> TypeFeedbackOracle::GetCallNewAllocationInfoCell(CallNew* expr) { | 345 Handle<Cell> TypeFeedbackOracle::GetCallNewAllocationInfoCell( |
| 345 return GetInfoCell(expr->CallNewFeedbackId()); | 346 TypeFeedbackId id) { |
| 347 return GetInfoCell(id); |
| 346 } | 348 } |
| 347 | 349 |
| 348 | 350 |
| 349 Handle<Map> TypeFeedbackOracle::GetObjectLiteralStoreMap( | 351 Handle<Map> TypeFeedbackOracle::GetObjectLiteralStoreMap(TypeFeedbackId id) { |
| 350 ObjectLiteral::Property* prop) { | 352 ASSERT(ObjectLiteralStoreIsMonomorphic(id)); |
| 351 ASSERT(ObjectLiteralStoreIsMonomorphic(prop)); | 353 return Handle<Map>::cast(GetInfo(id)); |
| 352 return Handle<Map>::cast(GetInfo(prop->key()->LiteralFeedbackId())); | |
| 353 } | 354 } |
| 354 | 355 |
| 355 | 356 |
| 356 bool TypeFeedbackOracle::LoadIsBuiltin(Property* expr, Builtins::Name id) { | 357 bool TypeFeedbackOracle::LoadIsBuiltin( |
| 357 return *GetInfo(expr->PropertyFeedbackId()) == | 358 TypeFeedbackId id, Builtins::Name builtin) { |
| 358 isolate_->builtins()->builtin(id); | 359 return *GetInfo(id) == isolate_->builtins()->builtin(builtin); |
| 359 } | 360 } |
| 360 | 361 |
| 361 | 362 |
| 362 bool TypeFeedbackOracle::LoadIsStub(Property* expr, ICStub* stub) { | 363 bool TypeFeedbackOracle::LoadIsStub(TypeFeedbackId id, ICStub* stub) { |
| 363 Handle<Object> object = GetInfo(expr->PropertyFeedbackId()); | 364 Handle<Object> object = GetInfo(id); |
| 364 if (!object->IsCode()) return false; | 365 if (!object->IsCode()) return false; |
| 365 Handle<Code> code = Handle<Code>::cast(object); | 366 Handle<Code> code = Handle<Code>::cast(object); |
| 366 if (!code->is_load_stub()) return false; | 367 if (!code->is_load_stub()) return false; |
| 367 if (code->ic_state() != MONOMORPHIC) return false; | 368 if (code->ic_state() != MONOMORPHIC) return false; |
| 368 return stub->Describes(*code); | 369 return stub->Describes(*code); |
| 369 } | 370 } |
| 370 | 371 |
| 371 | 372 |
| 372 void TypeFeedbackOracle::CompareType(TypeFeedbackId id, | 373 void TypeFeedbackOracle::CompareType(TypeFeedbackId id, |
| 373 Handle<Type>* left_type, | 374 Handle<Type>* left_type, |
| (...skipping 26 matching lines...) Expand all Loading... |
| 400 *left_type = *right_type = stub.GetInputType(isolate_, map); | 401 *left_type = *right_type = stub.GetInputType(isolate_, map); |
| 401 } | 402 } |
| 402 } | 403 } |
| 403 | 404 |
| 404 | 405 |
| 405 void TypeFeedbackOracle::BinaryType(TypeFeedbackId id, | 406 void TypeFeedbackOracle::BinaryType(TypeFeedbackId id, |
| 406 Handle<Type>* left, | 407 Handle<Type>* left, |
| 407 Handle<Type>* right, | 408 Handle<Type>* right, |
| 408 Handle<Type>* result, | 409 Handle<Type>* result, |
| 409 Maybe<int>* fixed_right_arg, | 410 Maybe<int>* fixed_right_arg, |
| 410 Token::Value operation) { | 411 Token::Value op) { |
| 411 Handle<Object> object = GetInfo(id); | 412 Handle<Object> object = GetInfo(id); |
| 412 if (!object->IsCode()) { | 413 if (!object->IsCode()) { |
| 413 // For some binary ops we don't have ICs, e.g. Token::COMMA, but for the | 414 // For some binary ops we don't have ICs, e.g. Token::COMMA, but for the |
| 414 // operations covered by the BinaryOpStub we should always have them. | 415 // operations covered by the BinaryOpIC we should always have them. |
| 415 ASSERT(!(operation >= BinaryOpStub::FIRST_TOKEN && | 416 ASSERT(op < BinaryOpIC::State::FIRST_TOKEN || |
| 416 operation <= BinaryOpStub::LAST_TOKEN)); | 417 op > BinaryOpIC::State::LAST_TOKEN); |
| 417 *left = *right = *result = handle(Type::None(), isolate_); | 418 *left = *right = *result = handle(Type::None(), isolate_); |
| 419 *fixed_right_arg = Maybe<int>(); |
| 418 return; | 420 return; |
| 419 } | 421 } |
| 420 Handle<Code> code = Handle<Code>::cast(object); | 422 Handle<Code> code = Handle<Code>::cast(object); |
| 421 ASSERT(code->is_binary_op_stub()); | 423 ASSERT_EQ(Code::BINARY_OP_IC, code->kind()); |
| 424 BinaryOpIC::State state(code->extended_extra_ic_state()); |
| 425 ASSERT_EQ(op, state.op()); |
| 422 | 426 |
| 423 BinaryOpStub stub(code->extended_extra_ic_state()); | 427 *left = state.GetLeftType(isolate()); |
| 424 | 428 *right = state.GetRightType(isolate()); |
| 425 // Sanity check. | 429 *result = state.GetResultType(isolate()); |
| 426 ASSERT(stub.operation() == operation); | 430 *fixed_right_arg = state.fixed_right_arg(); |
| 427 | |
| 428 *left = stub.GetLeftType(isolate()); | |
| 429 *right = stub.GetRightType(isolate()); | |
| 430 *result = stub.GetResultType(isolate()); | |
| 431 *fixed_right_arg = stub.fixed_right_arg(); | |
| 432 } | 431 } |
| 433 | 432 |
| 434 | 433 |
| 435 Handle<Type> TypeFeedbackOracle::ClauseType(TypeFeedbackId id) { | 434 Handle<Type> TypeFeedbackOracle::ClauseType(TypeFeedbackId id) { |
| 436 Handle<Object> info = GetInfo(id); | 435 Handle<Object> info = GetInfo(id); |
| 437 Handle<Type> result(Type::None(), isolate_); | 436 Handle<Type> result(Type::None(), isolate_); |
| 438 if (info->IsCode() && Handle<Code>::cast(info)->is_compare_ic_stub()) { | 437 if (info->IsCode() && Handle<Code>::cast(info)->is_compare_ic_stub()) { |
| 439 Handle<Code> code = Handle<Code>::cast(info); | 438 Handle<Code> code = Handle<Code>::cast(info); |
| 440 CompareIC::State state = ICCompareStub::CompareState(code->stub_info()); | 439 CompareIC::State state = ICCompareStub::CompareState(code->stub_info()); |
| 441 result = CompareIC::StateToType(isolate_, state); | 440 result = CompareIC::StateToType(isolate_, state); |
| 442 } | 441 } |
| 443 return result; | 442 return result; |
| 444 } | 443 } |
| 445 | 444 |
| 446 | 445 |
| 447 Handle<Type> TypeFeedbackOracle::IncrementType(CountOperation* expr) { | 446 Handle<Type> TypeFeedbackOracle::CountType(TypeFeedbackId id) { |
| 448 Handle<Object> object = GetInfo(expr->CountBinOpFeedbackId()); | 447 Handle<Object> object = GetInfo(id); |
| 449 Handle<Type> unknown(Type::None(), isolate_); | 448 if (!object->IsCode()) return handle(Type::None(), isolate_); |
| 450 if (!object->IsCode()) return unknown; | |
| 451 Handle<Code> code = Handle<Code>::cast(object); | 449 Handle<Code> code = Handle<Code>::cast(object); |
| 452 if (!code->is_binary_op_stub()) return unknown; | 450 ASSERT_EQ(Code::BINARY_OP_IC, code->kind()); |
| 453 | 451 BinaryOpIC::State state(code->extended_extra_ic_state()); |
| 454 BinaryOpStub stub(code->extended_extra_ic_state()); | 452 return state.GetLeftType(isolate()); |
| 455 return stub.GetLeftType(isolate()); | |
| 456 } | 453 } |
| 457 | 454 |
| 458 | 455 |
| 456 void TypeFeedbackOracle::PropertyReceiverTypes( |
| 457 TypeFeedbackId id, Handle<String> name, |
| 458 SmallMapList* receiver_types, bool* is_prototype) { |
| 459 receiver_types->Clear(); |
| 460 FunctionPrototypeStub proto_stub(Code::LOAD_IC); |
| 461 *is_prototype = LoadIsStub(id, &proto_stub); |
| 462 if (!*is_prototype) { |
| 463 LoadReceiverTypes(id, name, receiver_types); |
| 464 } |
| 465 } |
| 466 |
| 467 |
| 468 void TypeFeedbackOracle::KeyedPropertyReceiverTypes( |
| 469 TypeFeedbackId id, SmallMapList* receiver_types, bool* is_string) { |
| 470 receiver_types->Clear(); |
| 471 *is_string = false; |
| 472 if (LoadIsBuiltin(id, Builtins::kKeyedLoadIC_String)) { |
| 473 *is_string = true; |
| 474 } else if (LoadIsMonomorphicNormal(id)) { |
| 475 receiver_types->Add(LoadMonomorphicReceiverType(id), zone()); |
| 476 } else if (LoadIsPolymorphic(id)) { |
| 477 receiver_types->Reserve(kMaxKeyedPolymorphism, zone()); |
| 478 CollectKeyedReceiverTypes(id, receiver_types); |
| 479 } |
| 480 } |
| 481 |
| 482 |
| 483 void TypeFeedbackOracle::AssignmentReceiverTypes( |
| 484 TypeFeedbackId id, Handle<String> name, SmallMapList* receiver_types) { |
| 485 receiver_types->Clear(); |
| 486 StoreReceiverTypes(id, name, receiver_types); |
| 487 } |
| 488 |
| 489 |
| 490 void TypeFeedbackOracle::KeyedAssignmentReceiverTypes( |
| 491 TypeFeedbackId id, SmallMapList* receiver_types, |
| 492 KeyedAccessStoreMode* store_mode) { |
| 493 receiver_types->Clear(); |
| 494 if (StoreIsMonomorphicNormal(id)) { |
| 495 // Record receiver type for monomorphic keyed stores. |
| 496 receiver_types->Add(StoreMonomorphicReceiverType(id), zone()); |
| 497 } else if (StoreIsKeyedPolymorphic(id)) { |
| 498 receiver_types->Reserve(kMaxKeyedPolymorphism, zone()); |
| 499 CollectKeyedReceiverTypes(id, receiver_types); |
| 500 } |
| 501 *store_mode = GetStoreMode(id); |
| 502 } |
| 503 |
| 504 |
| 505 void TypeFeedbackOracle::CountReceiverTypes( |
| 506 TypeFeedbackId id, SmallMapList* receiver_types) { |
| 507 receiver_types->Clear(); |
| 508 if (StoreIsMonomorphicNormal(id)) { |
| 509 // Record receiver type for monomorphic keyed stores. |
| 510 receiver_types->Add(StoreMonomorphicReceiverType(id), zone()); |
| 511 } else if (StoreIsKeyedPolymorphic(id)) { |
| 512 receiver_types->Reserve(kMaxKeyedPolymorphism, zone()); |
| 513 CollectKeyedReceiverTypes(id, receiver_types); |
| 514 } else { |
| 515 CollectPolymorphicStoreReceiverTypes(id, receiver_types); |
| 516 } |
| 517 } |
| 518 |
| 519 |
| 459 void TypeFeedbackOracle::CollectPolymorphicMaps(Handle<Code> code, | 520 void TypeFeedbackOracle::CollectPolymorphicMaps(Handle<Code> code, |
| 460 SmallMapList* types) { | 521 SmallMapList* types) { |
| 461 MapHandleList maps; | 522 MapHandleList maps; |
| 462 code->FindAllMaps(&maps); | 523 code->FindAllMaps(&maps); |
| 463 types->Reserve(maps.length(), zone()); | 524 types->Reserve(maps.length(), zone()); |
| 464 for (int i = 0; i < maps.length(); i++) { | 525 for (int i = 0; i < maps.length(); i++) { |
| 465 Handle<Map> map(maps.at(i)); | 526 Handle<Map> map(maps.at(i)); |
| 466 if (!CanRetainOtherContext(*map, *native_context_)) { | 527 if (!CanRetainOtherContext(*map, *native_context_)) { |
| 467 types->AddMapIfMissing(map, zone()); | 528 types->AddMapIfMissing(map, zone()); |
| 468 } | 529 } |
| 469 } | 530 } |
| 470 } | 531 } |
| 471 | 532 |
| 472 | 533 |
| 473 void TypeFeedbackOracle::CollectReceiverTypes(TypeFeedbackId ast_id, | 534 void TypeFeedbackOracle::CollectReceiverTypes(TypeFeedbackId ast_id, |
| 474 Handle<String> name, | 535 Handle<String> name, |
| 475 Code::Flags flags, | 536 Code::Flags flags, |
| 476 SmallMapList* types) { | 537 SmallMapList* types) { |
| 477 Handle<Object> object = GetInfo(ast_id); | 538 Handle<Object> object = GetInfo(ast_id); |
| 478 if (object->IsUndefined() || object->IsSmi()) return; | 539 if (object->IsUndefined() || object->IsSmi()) return; |
| 479 | 540 |
| 480 if (object.is_identical_to(isolate_->builtins()->StoreIC_GlobalProxy())) { | 541 if (object->IsMap()) { |
| 481 // TODO(fschneider): We could collect the maps and signal that | |
| 482 // we need a generic store (or load) here. | |
| 483 ASSERT(Handle<Code>::cast(object)->ic_state() == GENERIC); | |
| 484 } else if (object->IsMap()) { | |
| 485 types->AddMapIfMissing(Handle<Map>::cast(object), zone()); | 542 types->AddMapIfMissing(Handle<Map>::cast(object), zone()); |
| 486 } else if (Handle<Code>::cast(object)->ic_state() == POLYMORPHIC || | 543 } else if (Handle<Code>::cast(object)->ic_state() == POLYMORPHIC || |
| 487 Handle<Code>::cast(object)->ic_state() == MONOMORPHIC) { | 544 Handle<Code>::cast(object)->ic_state() == MONOMORPHIC) { |
| 488 CollectPolymorphicMaps(Handle<Code>::cast(object), types); | 545 CollectPolymorphicMaps(Handle<Code>::cast(object), types); |
| 489 } else if (FLAG_collect_megamorphic_maps_from_stub_cache && | 546 } else if (FLAG_collect_megamorphic_maps_from_stub_cache && |
| 490 Handle<Code>::cast(object)->ic_state() == MEGAMORPHIC) { | 547 Handle<Code>::cast(object)->ic_state() == MEGAMORPHIC) { |
| 491 types->Reserve(4, zone()); | 548 types->Reserve(4, zone()); |
| 492 ASSERT(object->IsCode()); | 549 ASSERT(object->IsCode()); |
| 493 isolate_->stub_cache()->CollectMatchingMaps(types, | 550 isolate_->stub_cache()->CollectMatchingMaps(types, |
| 494 name, | 551 name, |
| (...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 699 if (info.IsUninitialized()) return Representation::None(); | 756 if (info.IsUninitialized()) return Representation::None(); |
| 700 if (info.IsSmi()) return Representation::Smi(); | 757 if (info.IsSmi()) return Representation::Smi(); |
| 701 if (info.IsInteger32()) return Representation::Integer32(); | 758 if (info.IsInteger32()) return Representation::Integer32(); |
| 702 if (info.IsDouble()) return Representation::Double(); | 759 if (info.IsDouble()) return Representation::Double(); |
| 703 if (info.IsNumber()) return Representation::Double(); | 760 if (info.IsNumber()) return Representation::Double(); |
| 704 return Representation::Tagged(); | 761 return Representation::Tagged(); |
| 705 } | 762 } |
| 706 | 763 |
| 707 | 764 |
| 708 } } // namespace v8::internal | 765 } } // namespace v8::internal |
| OLD | NEW |