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

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

Issue 6685088: Merge isolates to bleeding_edge. (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: '' Created 9 years, 9 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/top.cc ('k') | src/unicode.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 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
66 global_context_ = global_context; 66 global_context_ = global_context;
67 PopulateMap(code); 67 PopulateMap(code);
68 ASSERT(reinterpret_cast<Address>(*dictionary_.location()) != kHandleZapValue); 68 ASSERT(reinterpret_cast<Address>(*dictionary_.location()) != kHandleZapValue);
69 } 69 }
70 70
71 71
72 Handle<Object> TypeFeedbackOracle::GetInfo(int pos) { 72 Handle<Object> TypeFeedbackOracle::GetInfo(int pos) {
73 int entry = dictionary_->FindEntry(pos); 73 int entry = dictionary_->FindEntry(pos);
74 return entry != NumberDictionary::kNotFound 74 return entry != NumberDictionary::kNotFound
75 ? Handle<Object>(dictionary_->ValueAt(entry)) 75 ? Handle<Object>(dictionary_->ValueAt(entry))
76 : Factory::undefined_value(); 76 : Isolate::Current()->factory()->undefined_value();
77 } 77 }
78 78
79 79
80 bool TypeFeedbackOracle::LoadIsMonomorphic(Property* expr) { 80 bool TypeFeedbackOracle::LoadIsMonomorphic(Property* expr) {
81 Handle<Object> map_or_code(GetInfo(expr->position())); 81 Handle<Object> map_or_code(GetInfo(expr->position()));
82 if (map_or_code->IsMap()) return true; 82 if (map_or_code->IsMap()) return true;
83 if (map_or_code->IsCode()) { 83 if (map_or_code->IsCode()) {
84 Handle<Code> code(Code::cast(*map_or_code)); 84 Handle<Code> code(Code::cast(*map_or_code));
85 return code->kind() == Code::KEYED_EXTERNAL_ARRAY_LOAD_IC && 85 return code->kind() == Code::KEYED_EXTERNAL_ARRAY_LOAD_IC &&
86 code->FindFirstMap() != NULL; 86 code->FindFirstMap() != NULL;
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
200 case BOOLEAN_CHECK: 200 case BOOLEAN_CHECK:
201 function = global_context_->boolean_function(); 201 function = global_context_->boolean_function();
202 break; 202 break;
203 } 203 }
204 ASSERT(function != NULL); 204 ASSERT(function != NULL);
205 return Handle<JSObject>(JSObject::cast(function->instance_prototype())); 205 return Handle<JSObject>(JSObject::cast(function->instance_prototype()));
206 } 206 }
207 207
208 208
209 bool TypeFeedbackOracle::LoadIsBuiltin(Property* expr, Builtins::Name id) { 209 bool TypeFeedbackOracle::LoadIsBuiltin(Property* expr, Builtins::Name id) {
210 return *GetInfo(expr->position()) == Builtins::builtin(id); 210 return *GetInfo(expr->position()) ==
211 Isolate::Current()->builtins()->builtin(id);
211 } 212 }
212 213
213 214
214 TypeInfo TypeFeedbackOracle::CompareType(CompareOperation* expr) { 215 TypeInfo TypeFeedbackOracle::CompareType(CompareOperation* expr) {
215 Handle<Object> object = GetInfo(expr->position()); 216 Handle<Object> object = GetInfo(expr->position());
216 TypeInfo unknown = TypeInfo::Unknown(); 217 TypeInfo unknown = TypeInfo::Unknown();
217 if (!object->IsCode()) return unknown; 218 if (!object->IsCode()) return unknown;
218 Handle<Code> code = Handle<Code>::cast(object); 219 Handle<Code> code = Handle<Code>::cast(object);
219 if (!code->is_compare_ic_stub()) return unknown; 220 if (!code->is_compare_ic_stub()) return unknown;
220 221
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
323 case CompareIC::GENERIC: 324 case CompareIC::GENERIC:
324 default: 325 default:
325 return unknown; 326 return unknown;
326 } 327 }
327 } 328 }
328 329
329 330
330 ZoneMapList* TypeFeedbackOracle::CollectReceiverTypes(int position, 331 ZoneMapList* TypeFeedbackOracle::CollectReceiverTypes(int position,
331 Handle<String> name, 332 Handle<String> name,
332 Code::Flags flags) { 333 Code::Flags flags) {
334 Isolate* isolate = Isolate::Current();
333 Handle<Object> object = GetInfo(position); 335 Handle<Object> object = GetInfo(position);
334 if (object->IsUndefined() || object->IsSmi()) return NULL; 336 if (object->IsUndefined() || object->IsSmi()) return NULL;
335 337
336 if (*object == Builtins::builtin(Builtins::StoreIC_GlobalProxy)) { 338 if (*object == isolate->builtins()->builtin(Builtins::StoreIC_GlobalProxy)) {
337 // TODO(fschneider): We could collect the maps and signal that 339 // TODO(fschneider): We could collect the maps and signal that
338 // we need a generic store (or load) here. 340 // we need a generic store (or load) here.
339 ASSERT(Handle<Code>::cast(object)->ic_state() == MEGAMORPHIC); 341 ASSERT(Handle<Code>::cast(object)->ic_state() == MEGAMORPHIC);
340 return NULL; 342 return NULL;
341 } else if (object->IsMap()) { 343 } else if (object->IsMap()) {
342 ZoneMapList* types = new ZoneMapList(1); 344 ZoneMapList* types = new ZoneMapList(1);
343 types->Add(Handle<Map>::cast(object)); 345 types->Add(Handle<Map>::cast(object));
344 return types; 346 return types;
345 } else if (Handle<Code>::cast(object)->ic_state() == MEGAMORPHIC) { 347 } else if (Handle<Code>::cast(object)->ic_state() == MEGAMORPHIC) {
346 ZoneMapList* types = new ZoneMapList(4); 348 ZoneMapList* types = new ZoneMapList(4);
347 ASSERT(object->IsCode()); 349 ASSERT(object->IsCode());
348 StubCache::CollectMatchingMaps(types, *name, flags); 350 isolate->stub_cache()->CollectMatchingMaps(types, *name, flags);
349 return types->length() > 0 ? types : NULL; 351 return types->length() > 0 ? types : NULL;
350 } else { 352 } else {
351 return NULL; 353 return NULL;
352 } 354 }
353 } 355 }
354 356
355 357
356 void TypeFeedbackOracle::PopulateMap(Handle<Code> code) { 358 void TypeFeedbackOracle::PopulateMap(Handle<Code> code) {
357 HandleScope scope; 359 Isolate* isolate = Isolate::Current();
360 HandleScope scope(isolate);
358 361
359 const int kInitialCapacity = 16; 362 const int kInitialCapacity = 16;
360 List<int> code_positions(kInitialCapacity); 363 List<int> code_positions(kInitialCapacity);
361 List<int> source_positions(kInitialCapacity); 364 List<int> source_positions(kInitialCapacity);
362 CollectPositions(*code, &code_positions, &source_positions); 365 CollectPositions(*code, &code_positions, &source_positions);
363 366
364 ASSERT(dictionary_.is_null()); // Only initialize once. 367 ASSERT(dictionary_.is_null()); // Only initialize once.
365 dictionary_ = Factory::NewNumberDictionary(code_positions.length()); 368 dictionary_ = isolate->factory()->NewNumberDictionary(
369 code_positions.length());
366 370
367 int length = code_positions.length(); 371 int length = code_positions.length();
368 ASSERT(source_positions.length() == length); 372 ASSERT(source_positions.length() == length);
369 for (int i = 0; i < length; i++) { 373 for (int i = 0; i < length; i++) {
370 HandleScope loop_scope; 374 HandleScope loop_scope(isolate);
371 RelocInfo info(code->instruction_start() + code_positions[i], 375 RelocInfo info(code->instruction_start() + code_positions[i],
372 RelocInfo::CODE_TARGET, 0); 376 RelocInfo::CODE_TARGET, 0);
373 Handle<Code> target(Code::GetCodeFromTargetAddress(info.target_address())); 377 Handle<Code> target(Code::GetCodeFromTargetAddress(info.target_address()));
374 int position = source_positions[i]; 378 int position = source_positions[i];
375 InlineCacheState state = target->ic_state(); 379 InlineCacheState state = target->ic_state();
376 Code::Kind kind = target->kind(); 380 Code::Kind kind = target->kind();
377 Handle<Object> value; 381 Handle<Object> value;
378 if (kind == Code::BINARY_OP_IC || 382 if (kind == Code::BINARY_OP_IC ||
379 kind == Code::TYPE_RECORDING_BINARY_OP_IC || 383 kind == Code::TYPE_RECORDING_BINARY_OP_IC ||
380 kind == Code::COMPARE_IC) { 384 kind == Code::COMPARE_IC) {
381 // TODO(kasperl): Avoid having multiple ICs with the same 385 // TODO(kasperl): Avoid having multiple ICs with the same
382 // position by making sure that we have position information 386 // position by making sure that we have position information
383 // recorded for all binary ICs. 387 // recorded for all binary ICs.
384 int entry = dictionary_->FindEntry(position); 388 int entry = dictionary_->FindEntry(position);
385 if (entry == NumberDictionary::kNotFound) { 389 if (entry == NumberDictionary::kNotFound) {
386 value = target; 390 value = target;
387 } 391 }
388 } else if (state == MONOMORPHIC) { 392 } else if (state == MONOMORPHIC) {
389 if (kind == Code::KEYED_EXTERNAL_ARRAY_LOAD_IC || 393 if (kind == Code::KEYED_EXTERNAL_ARRAY_LOAD_IC ||
390 kind == Code::KEYED_EXTERNAL_ARRAY_STORE_IC) { 394 kind == Code::KEYED_EXTERNAL_ARRAY_STORE_IC) {
391 value = target; 395 value = target;
392 } else if (kind != Code::CALL_IC || 396 } else if (target->kind() != Code::CALL_IC ||
393 target->check_type() == RECEIVER_MAP_CHECK) { 397 target->check_type() == RECEIVER_MAP_CHECK) {
394 Handle<Map> map = Handle<Map>(target->FindFirstMap()); 398 Map* map = target->FindFirstMap();
395 if (*map == NULL) { 399 if (map == NULL) {
396 value = target; 400 value = target;
397 } else { 401 } else {
398 value = map; 402 value = Handle<Map>(map);
399 } 403 }
400 } else { 404 } else {
401 ASSERT(target->kind() == Code::CALL_IC); 405 ASSERT(target->kind() == Code::CALL_IC);
402 CheckType check = target->check_type(); 406 CheckType check = target->check_type();
403 ASSERT(check != RECEIVER_MAP_CHECK); 407 ASSERT(check != RECEIVER_MAP_CHECK);
404 value = Handle<Object>(Smi::FromInt(check)); 408 value = Handle<Object>(Smi::FromInt(check));
405 } 409 }
406 } else if (state == MEGAMORPHIC) { 410 } else if (state == MEGAMORPHIC) {
407 value = target; 411 value = target;
408 } 412 }
409 413
410 if (!value.is_null()) { 414 if (!value.is_null()) {
411 Handle<NumberDictionary> new_dict = 415 Handle<NumberDictionary> new_dict =
412 Factory::DictionaryAtNumberPut(dictionary_, position, value); 416 isolate->factory()->DictionaryAtNumberPut(
417 dictionary_, position, value);
413 dictionary_ = loop_scope.CloseAndEscape(new_dict); 418 dictionary_ = loop_scope.CloseAndEscape(new_dict);
414 } 419 }
415 } 420 }
416 // Allocate handle in the parent scope. 421 // Allocate handle in the parent scope.
417 dictionary_ = scope.CloseAndEscape(dictionary_); 422 dictionary_ = scope.CloseAndEscape(dictionary_);
418 } 423 }
419 424
420 425
421 void TypeFeedbackOracle::CollectPositions(Code* code, 426 void TypeFeedbackOracle::CollectPositions(Code* code,
422 List<int>* code_positions, 427 List<int>* code_positions,
(...skipping 30 matching lines...) Expand all
453 source_positions->Add(position); 458 source_positions->Add(position);
454 } 459 }
455 } else { 460 } else {
456 ASSERT(RelocInfo::IsPosition(mode)); 461 ASSERT(RelocInfo::IsPosition(mode));
457 position = static_cast<int>(info->data()); 462 position = static_cast<int>(info->data());
458 } 463 }
459 } 464 }
460 } 465 }
461 466
462 } } // namespace v8::internal 467 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/top.cc ('k') | src/unicode.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698