| 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 240 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 251 CompareIC::State state = static_cast<CompareIC::State>(code->compare_state()); | 251 CompareIC::State state = static_cast<CompareIC::State>(code->compare_state()); |
| 252 return state == CompareIC::SYMBOLS; | 252 return state == CompareIC::SYMBOLS; |
| 253 } | 253 } |
| 254 | 254 |
| 255 | 255 |
| 256 TypeInfo TypeFeedbackOracle::UnaryType(UnaryOperation* expr) { | 256 TypeInfo TypeFeedbackOracle::UnaryType(UnaryOperation* expr) { |
| 257 Handle<Object> object = GetInfo(expr->id()); | 257 Handle<Object> object = GetInfo(expr->id()); |
| 258 TypeInfo unknown = TypeInfo::Unknown(); | 258 TypeInfo unknown = TypeInfo::Unknown(); |
| 259 if (!object->IsCode()) return unknown; | 259 if (!object->IsCode()) return unknown; |
| 260 Handle<Code> code = Handle<Code>::cast(object); | 260 Handle<Code> code = Handle<Code>::cast(object); |
| 261 ASSERT(code->is_type_recording_unary_op_stub()); | 261 ASSERT(code->is_unary_op_stub()); |
| 262 TRUnaryOpIC::TypeInfo type = static_cast<TRUnaryOpIC::TypeInfo>( | 262 UnaryOpIC::TypeInfo type = static_cast<UnaryOpIC::TypeInfo>( |
| 263 code->type_recording_unary_op_type()); | 263 code->unary_op_type()); |
| 264 switch (type) { | 264 switch (type) { |
| 265 case TRUnaryOpIC::SMI: | 265 case UnaryOpIC::SMI: |
| 266 return TypeInfo::Smi(); | 266 return TypeInfo::Smi(); |
| 267 case TRUnaryOpIC::HEAP_NUMBER: | 267 case UnaryOpIC::HEAP_NUMBER: |
| 268 return TypeInfo::Double(); | 268 return TypeInfo::Double(); |
| 269 default: | 269 default: |
| 270 return unknown; | 270 return unknown; |
| 271 } | 271 } |
| 272 } | 272 } |
| 273 | 273 |
| 274 | 274 |
| 275 TypeInfo TypeFeedbackOracle::BinaryType(BinaryOperation* expr) { | 275 TypeInfo TypeFeedbackOracle::BinaryType(BinaryOperation* expr) { |
| 276 Handle<Object> object = GetInfo(expr->id()); | 276 Handle<Object> object = GetInfo(expr->id()); |
| 277 TypeInfo unknown = TypeInfo::Unknown(); | 277 TypeInfo unknown = TypeInfo::Unknown(); |
| 278 if (!object->IsCode()) return unknown; | 278 if (!object->IsCode()) return unknown; |
| 279 Handle<Code> code = Handle<Code>::cast(object); | 279 Handle<Code> code = Handle<Code>::cast(object); |
| 280 if (code->is_type_recording_binary_op_stub()) { | 280 if (code->is_binary_op_stub()) { |
| 281 TRBinaryOpIC::TypeInfo type = static_cast<TRBinaryOpIC::TypeInfo>( | 281 BinaryOpIC::TypeInfo type = static_cast<BinaryOpIC::TypeInfo>( |
| 282 code->type_recording_binary_op_type()); | 282 code->binary_op_type()); |
| 283 TRBinaryOpIC::TypeInfo result_type = static_cast<TRBinaryOpIC::TypeInfo>( | 283 BinaryOpIC::TypeInfo result_type = static_cast<BinaryOpIC::TypeInfo>( |
| 284 code->type_recording_binary_op_result_type()); | 284 code->binary_op_result_type()); |
| 285 | 285 |
| 286 switch (type) { | 286 switch (type) { |
| 287 case TRBinaryOpIC::UNINITIALIZED: | 287 case BinaryOpIC::UNINITIALIZED: |
| 288 // Uninitialized means never executed. | 288 // Uninitialized means never executed. |
| 289 // TODO(fschneider): Introduce a separate value for never-executed ICs | 289 // TODO(fschneider): Introduce a separate value for never-executed ICs |
| 290 return unknown; | 290 return unknown; |
| 291 case TRBinaryOpIC::SMI: | 291 case BinaryOpIC::SMI: |
| 292 switch (result_type) { | 292 switch (result_type) { |
| 293 case TRBinaryOpIC::UNINITIALIZED: | 293 case BinaryOpIC::UNINITIALIZED: |
| 294 case TRBinaryOpIC::SMI: | 294 case BinaryOpIC::SMI: |
| 295 return TypeInfo::Smi(); | 295 return TypeInfo::Smi(); |
| 296 case TRBinaryOpIC::INT32: | 296 case BinaryOpIC::INT32: |
| 297 return TypeInfo::Integer32(); | 297 return TypeInfo::Integer32(); |
| 298 case TRBinaryOpIC::HEAP_NUMBER: | 298 case BinaryOpIC::HEAP_NUMBER: |
| 299 return TypeInfo::Double(); | 299 return TypeInfo::Double(); |
| 300 default: | 300 default: |
| 301 return unknown; | 301 return unknown; |
| 302 } | 302 } |
| 303 case TRBinaryOpIC::INT32: | 303 case BinaryOpIC::INT32: |
| 304 if (expr->op() == Token::DIV || | 304 if (expr->op() == Token::DIV || |
| 305 result_type == TRBinaryOpIC::HEAP_NUMBER) { | 305 result_type == BinaryOpIC::HEAP_NUMBER) { |
| 306 return TypeInfo::Double(); | 306 return TypeInfo::Double(); |
| 307 } | 307 } |
| 308 return TypeInfo::Integer32(); | 308 return TypeInfo::Integer32(); |
| 309 case TRBinaryOpIC::HEAP_NUMBER: | 309 case BinaryOpIC::HEAP_NUMBER: |
| 310 return TypeInfo::Double(); | 310 return TypeInfo::Double(); |
| 311 case TRBinaryOpIC::BOTH_STRING: | 311 case BinaryOpIC::BOTH_STRING: |
| 312 return TypeInfo::String(); | 312 return TypeInfo::String(); |
| 313 case TRBinaryOpIC::STRING: | 313 case BinaryOpIC::STRING: |
| 314 case TRBinaryOpIC::GENERIC: | 314 case BinaryOpIC::GENERIC: |
| 315 return unknown; | 315 return unknown; |
| 316 default: | 316 default: |
| 317 return unknown; | 317 return unknown; |
| 318 } | 318 } |
| 319 } | 319 } |
| 320 return unknown; | 320 return unknown; |
| 321 } | 321 } |
| 322 | 322 |
| 323 | 323 |
| 324 TypeInfo TypeFeedbackOracle::SwitchType(CaseClause* clause) { | 324 TypeInfo TypeFeedbackOracle::SwitchType(CaseClause* clause) { |
| (...skipping 21 matching lines...) Expand all Loading... |
| 346 return unknown; | 346 return unknown; |
| 347 } | 347 } |
| 348 } | 348 } |
| 349 | 349 |
| 350 | 350 |
| 351 TypeInfo TypeFeedbackOracle::IncrementType(CountOperation* expr) { | 351 TypeInfo TypeFeedbackOracle::IncrementType(CountOperation* expr) { |
| 352 Handle<Object> object = GetInfo(expr->CountId()); | 352 Handle<Object> object = GetInfo(expr->CountId()); |
| 353 TypeInfo unknown = TypeInfo::Unknown(); | 353 TypeInfo unknown = TypeInfo::Unknown(); |
| 354 if (!object->IsCode()) return unknown; | 354 if (!object->IsCode()) return unknown; |
| 355 Handle<Code> code = Handle<Code>::cast(object); | 355 Handle<Code> code = Handle<Code>::cast(object); |
| 356 if (!code->is_type_recording_binary_op_stub()) return unknown; | 356 if (!code->is_binary_op_stub()) return unknown; |
| 357 | 357 |
| 358 TRBinaryOpIC::TypeInfo type = static_cast<TRBinaryOpIC::TypeInfo>( | 358 BinaryOpIC::TypeInfo type = static_cast<BinaryOpIC::TypeInfo>( |
| 359 code->type_recording_binary_op_type()); | 359 code->binary_op_type()); |
| 360 switch (type) { | 360 switch (type) { |
| 361 case TRBinaryOpIC::UNINITIALIZED: | 361 case BinaryOpIC::UNINITIALIZED: |
| 362 case TRBinaryOpIC::SMI: | 362 case BinaryOpIC::SMI: |
| 363 return TypeInfo::Smi(); | 363 return TypeInfo::Smi(); |
| 364 case TRBinaryOpIC::INT32: | 364 case BinaryOpIC::INT32: |
| 365 return TypeInfo::Integer32(); | 365 return TypeInfo::Integer32(); |
| 366 case TRBinaryOpIC::HEAP_NUMBER: | 366 case BinaryOpIC::HEAP_NUMBER: |
| 367 return TypeInfo::Double(); | 367 return TypeInfo::Double(); |
| 368 case TRBinaryOpIC::BOTH_STRING: | 368 case BinaryOpIC::BOTH_STRING: |
| 369 case TRBinaryOpIC::STRING: | 369 case BinaryOpIC::STRING: |
| 370 case TRBinaryOpIC::GENERIC: | 370 case BinaryOpIC::GENERIC: |
| 371 return unknown; | 371 return unknown; |
| 372 default: | 372 default: |
| 373 return unknown; | 373 return unknown; |
| 374 } | 374 } |
| 375 UNREACHABLE(); | 375 UNREACHABLE(); |
| 376 return unknown; | 376 return unknown; |
| 377 } | 377 } |
| 378 | 378 |
| 379 | 379 |
| 380 ZoneMapList* TypeFeedbackOracle::CollectReceiverTypes(unsigned ast_id, | 380 ZoneMapList* TypeFeedbackOracle::CollectReceiverTypes(unsigned ast_id, |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 434 ASSERT(ast_ids.length() == length); | 434 ASSERT(ast_ids.length() == length); |
| 435 for (int i = 0; i < length; i++) { | 435 for (int i = 0; i < length; i++) { |
| 436 AssertNoAllocation no_allocation; | 436 AssertNoAllocation no_allocation; |
| 437 RelocInfo info(code->instruction_start() + code_positions[i], | 437 RelocInfo info(code->instruction_start() + code_positions[i], |
| 438 RelocInfo::CODE_TARGET, 0); | 438 RelocInfo::CODE_TARGET, 0); |
| 439 Code* target = Code::GetCodeFromTargetAddress(info.target_address()); | 439 Code* target = Code::GetCodeFromTargetAddress(info.target_address()); |
| 440 unsigned id = ast_ids[i]; | 440 unsigned id = ast_ids[i]; |
| 441 InlineCacheState state = target->ic_state(); | 441 InlineCacheState state = target->ic_state(); |
| 442 Code::Kind kind = target->kind(); | 442 Code::Kind kind = target->kind(); |
| 443 | 443 |
| 444 if (kind == Code::TYPE_RECORDING_BINARY_OP_IC || | 444 if (kind == Code::BINARY_OP_IC || |
| 445 kind == Code::TYPE_RECORDING_UNARY_OP_IC || | 445 kind == Code::UNARY_OP_IC || |
| 446 kind == Code::COMPARE_IC) { | 446 kind == Code::COMPARE_IC) { |
| 447 SetInfo(id, target); | 447 SetInfo(id, target); |
| 448 } else if (state == MONOMORPHIC) { | 448 } else if (state == MONOMORPHIC) { |
| 449 if (kind == Code::KEYED_LOAD_IC || | 449 if (kind == Code::KEYED_LOAD_IC || |
| 450 kind == Code::KEYED_STORE_IC) { | 450 kind == Code::KEYED_STORE_IC) { |
| 451 SetInfo(id, target); | 451 SetInfo(id, target); |
| 452 } else if (kind != Code::CALL_IC || | 452 } else if (kind != Code::CALL_IC || |
| 453 target->check_type() == RECEIVER_MAP_CHECK) { | 453 target->check_type() == RECEIVER_MAP_CHECK) { |
| 454 Map* map = target->FindFirstMap(); | 454 Map* map = target->FindFirstMap(); |
| 455 if (map == NULL) { | 455 if (map == NULL) { |
| (...skipping 21 matching lines...) Expand all Loading... |
| 477 List<unsigned>* ast_ids) { | 477 List<unsigned>* ast_ids) { |
| 478 AssertNoAllocation no_allocation; | 478 AssertNoAllocation no_allocation; |
| 479 int mask = RelocInfo::ModeMask(RelocInfo::CODE_TARGET_WITH_ID); | 479 int mask = RelocInfo::ModeMask(RelocInfo::CODE_TARGET_WITH_ID); |
| 480 for (RelocIterator it(code, mask); !it.done(); it.next()) { | 480 for (RelocIterator it(code, mask); !it.done(); it.next()) { |
| 481 RelocInfo* info = it.rinfo(); | 481 RelocInfo* info = it.rinfo(); |
| 482 ASSERT(RelocInfo::IsCodeTarget(info->rmode())); | 482 ASSERT(RelocInfo::IsCodeTarget(info->rmode())); |
| 483 Code* target = Code::GetCodeFromTargetAddress(info->target_address()); | 483 Code* target = Code::GetCodeFromTargetAddress(info->target_address()); |
| 484 if (target->is_inline_cache_stub()) { | 484 if (target->is_inline_cache_stub()) { |
| 485 InlineCacheState state = target->ic_state(); | 485 InlineCacheState state = target->ic_state(); |
| 486 Code::Kind kind = target->kind(); | 486 Code::Kind kind = target->kind(); |
| 487 if (kind == Code::TYPE_RECORDING_BINARY_OP_IC) { | 487 if (kind == Code::BINARY_OP_IC) { |
| 488 if (target->type_recording_binary_op_type() == | 488 if (target->binary_op_type() == |
| 489 TRBinaryOpIC::GENERIC) { | 489 BinaryOpIC::GENERIC) { |
| 490 continue; | 490 continue; |
| 491 } | 491 } |
| 492 } else if (kind == Code::COMPARE_IC) { | 492 } else if (kind == Code::COMPARE_IC) { |
| 493 if (target->compare_state() == CompareIC::GENERIC) continue; | 493 if (target->compare_state() == CompareIC::GENERIC) continue; |
| 494 } else { | 494 } else { |
| 495 if (state != MONOMORPHIC && state != MEGAMORPHIC) continue; | 495 if (state != MONOMORPHIC && state != MEGAMORPHIC) continue; |
| 496 } | 496 } |
| 497 code_positions->Add( | 497 code_positions->Add( |
| 498 static_cast<int>(info->pc() - code->instruction_start())); | 498 static_cast<int>(info->pc() - code->instruction_start())); |
| 499 ASSERT(ast_ids->length() == 0 || | 499 ASSERT(ast_ids->length() == 0 || |
| 500 (*ast_ids)[ast_ids->length()-1] != | 500 (*ast_ids)[ast_ids->length()-1] != |
| 501 static_cast<unsigned>(info->data())); | 501 static_cast<unsigned>(info->data())); |
| 502 ast_ids->Add(static_cast<unsigned>(info->data())); | 502 ast_ids->Add(static_cast<unsigned>(info->data())); |
| 503 } | 503 } |
| 504 } | 504 } |
| 505 } | 505 } |
| 506 | 506 |
| 507 } } // namespace v8::internal | 507 } } // namespace v8::internal |
| OLD | NEW |