Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(20)

Side by Side Diff: src/type-info.cc

Issue 6691054: [Arguments] Merge (7442,7496] from bleeding_edge. (Closed) Base URL: https://v8.googlecode.com/svn/branches/experimental/arguments
Patch Set: Created 9 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/type-info.h ('k') | src/v8.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2010 the V8 project authors. All rights reserved. 1 // Copyright 2010 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 337 matching lines...) Expand 10 before | Expand all | Expand 10 after
348 ZoneMapList* types = new ZoneMapList(4); 348 ZoneMapList* types = new ZoneMapList(4);
349 ASSERT(object->IsCode()); 349 ASSERT(object->IsCode());
350 isolate->stub_cache()->CollectMatchingMaps(types, *name, flags); 350 isolate->stub_cache()->CollectMatchingMaps(types, *name, flags);
351 return types->length() > 0 ? types : NULL; 351 return types->length() > 0 ? types : NULL;
352 } else { 352 } else {
353 return NULL; 353 return NULL;
354 } 354 }
355 } 355 }
356 356
357 357
358 void TypeFeedbackOracle::SetInfo(int position, Object* target) {
359 MaybeObject* maybe_result = dictionary_->AtNumberPut(position, target);
360 USE(maybe_result);
361 #ifdef DEBUG
362 Object* result;
363 // Dictionary has been allocated with sufficient size for all elements.
364 ASSERT(maybe_result->ToObject(&result));
365 ASSERT(*dictionary_ == result);
366 #endif
367 }
368
369
358 void TypeFeedbackOracle::PopulateMap(Handle<Code> code) { 370 void TypeFeedbackOracle::PopulateMap(Handle<Code> code) {
359 Isolate* isolate = Isolate::Current(); 371 Isolate* isolate = Isolate::Current();
360 HandleScope scope(isolate); 372 HandleScope scope(isolate);
361 373
362 const int kInitialCapacity = 16; 374 const int kInitialCapacity = 16;
363 List<int> code_positions(kInitialCapacity); 375 List<int> code_positions(kInitialCapacity);
364 List<int> source_positions(kInitialCapacity); 376 List<int> source_positions(kInitialCapacity);
365 CollectPositions(*code, &code_positions, &source_positions); 377 CollectPositions(*code, &code_positions, &source_positions);
366 378
367 ASSERT(dictionary_.is_null()); // Only initialize once. 379 ASSERT(dictionary_.is_null()); // Only initialize once.
368 dictionary_ = isolate->factory()->NewNumberDictionary( 380 dictionary_ = isolate->factory()->NewNumberDictionary(
369 code_positions.length()); 381 code_positions.length());
370 382
371 int length = code_positions.length(); 383 int length = code_positions.length();
372 ASSERT(source_positions.length() == length); 384 ASSERT(source_positions.length() == length);
373 for (int i = 0; i < length; i++) { 385 for (int i = 0; i < length; i++) {
374 HandleScope loop_scope(isolate); 386 AssertNoAllocation no_allocation;
375 RelocInfo info(code->instruction_start() + code_positions[i], 387 RelocInfo info(code->instruction_start() + code_positions[i],
376 RelocInfo::CODE_TARGET, 0); 388 RelocInfo::CODE_TARGET, 0);
377 Handle<Code> target(Code::GetCodeFromTargetAddress(info.target_address())); 389 Code* target = Code::GetCodeFromTargetAddress(info.target_address());
378 int position = source_positions[i]; 390 int position = source_positions[i];
379 InlineCacheState state = target->ic_state(); 391 InlineCacheState state = target->ic_state();
380 Code::Kind kind = target->kind(); 392 Code::Kind kind = target->kind();
381 Handle<Object> value; 393
382 if (kind == Code::BINARY_OP_IC || 394 if (kind == Code::BINARY_OP_IC ||
383 kind == Code::TYPE_RECORDING_BINARY_OP_IC || 395 kind == Code::TYPE_RECORDING_BINARY_OP_IC ||
384 kind == Code::COMPARE_IC) { 396 kind == Code::COMPARE_IC) {
385 // TODO(kasperl): Avoid having multiple ICs with the same 397 // TODO(kasperl): Avoid having multiple ICs with the same
386 // position by making sure that we have position information 398 // position by making sure that we have position information
387 // recorded for all binary ICs. 399 // recorded for all binary ICs.
388 int entry = dictionary_->FindEntry(position); 400 int entry = dictionary_->FindEntry(position);
389 if (entry == NumberDictionary::kNotFound) { 401 if (entry == NumberDictionary::kNotFound) {
390 value = target; 402 SetInfo(position, target);
391 } 403 }
392 } else if (state == MONOMORPHIC) { 404 } else if (state == MONOMORPHIC) {
393 if (kind == Code::KEYED_EXTERNAL_ARRAY_LOAD_IC || 405 if (kind == Code::KEYED_EXTERNAL_ARRAY_LOAD_IC ||
394 kind == Code::KEYED_EXTERNAL_ARRAY_STORE_IC) { 406 kind == Code::KEYED_EXTERNAL_ARRAY_STORE_IC) {
395 value = target; 407 SetInfo(position, target);
396 } else if (target->kind() != Code::CALL_IC || 408 } else if (target->kind() != Code::CALL_IC ||
397 target->check_type() == RECEIVER_MAP_CHECK) { 409 target->check_type() == RECEIVER_MAP_CHECK) {
398 Map* map = target->FindFirstMap(); 410 Map* map = target->FindFirstMap();
399 if (map == NULL) { 411 if (map == NULL) {
400 value = target; 412 SetInfo(position, target);
401 } else { 413 } else {
402 value = Handle<Map>(map); 414 SetInfo(position, map);
403 } 415 }
404 } else { 416 } else {
405 ASSERT(target->kind() == Code::CALL_IC); 417 ASSERT(target->kind() == Code::CALL_IC);
406 CheckType check = target->check_type(); 418 CheckType check = target->check_type();
407 ASSERT(check != RECEIVER_MAP_CHECK); 419 ASSERT(check != RECEIVER_MAP_CHECK);
408 value = Handle<Object>(Smi::FromInt(check)); 420 SetInfo(position, Smi::FromInt(check));
409 } 421 }
410 } else if (state == MEGAMORPHIC) { 422 } else if (state == MEGAMORPHIC) {
411 value = target; 423 SetInfo(position, target);
412 }
413
414 if (!value.is_null()) {
415 Handle<NumberDictionary> new_dict =
416 isolate->factory()->DictionaryAtNumberPut(
417 dictionary_, position, value);
418 dictionary_ = loop_scope.CloseAndEscape(new_dict);
419 } 424 }
420 } 425 }
421 // Allocate handle in the parent scope. 426 // Allocate handle in the parent scope.
422 dictionary_ = scope.CloseAndEscape(dictionary_); 427 dictionary_ = scope.CloseAndEscape(dictionary_);
423 } 428 }
424 429
425 430
426 void TypeFeedbackOracle::CollectPositions(Code* code, 431 void TypeFeedbackOracle::CollectPositions(Code* code,
427 List<int>* code_positions, 432 List<int>* code_positions,
428 List<int>* source_positions) { 433 List<int>* source_positions) {
(...skipping 29 matching lines...) Expand all
458 source_positions->Add(position); 463 source_positions->Add(position);
459 } 464 }
460 } else { 465 } else {
461 ASSERT(RelocInfo::IsPosition(mode)); 466 ASSERT(RelocInfo::IsPosition(mode));
462 position = static_cast<int>(info->data()); 467 position = static_cast<int>(info->data());
463 } 468 }
464 } 469 }
465 } 470 }
466 471
467 } } // namespace v8::internal 472 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/type-info.h ('k') | src/v8.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698