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 400 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
411 &r, | 411 &r, |
412 name, | 412 name, |
413 continue_search); | 413 continue_search); |
414 } | 414 } |
415 break; | 415 break; |
416 } | 416 } |
417 | 417 |
418 case HANDLER: | 418 case HANDLER: |
419 case MAP_TRANSITION: | 419 case MAP_TRANSITION: |
420 case CONSTANT_TRANSITION: | 420 case CONSTANT_TRANSITION: |
421 case NONEXISTENT: | 421 case NULL_DESCRIPTOR: |
422 UNREACHABLE(); | 422 UNREACHABLE(); |
423 } | 423 } |
424 } | 424 } |
425 | 425 |
426 GetIsolate()->ReportFailedAccessCheck(this, v8::ACCESS_HAS); | 426 GetIsolate()->ReportFailedAccessCheck(this, v8::ACCESS_HAS); |
427 return ABSENT; | 427 return ABSENT; |
428 } | 428 } |
429 | 429 |
430 | 430 |
431 Object* JSObject::GetNormalizedProperty(LookupResult* result) { | 431 Object* JSObject::GetNormalizedProperty(LookupResult* result) { |
(...skipping 4835 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5267 current = parent; | 5267 current = parent; |
5268 } | 5268 } |
5269 } | 5269 } |
5270 } | 5270 } |
5271 | 5271 |
5272 | 5272 |
5273 MaybeObject* CodeCache::Update(String* name, Code* code) { | 5273 MaybeObject* CodeCache::Update(String* name, Code* code) { |
5274 // The number of monomorphic stubs for normal load/store/call IC's can grow to | 5274 // The number of monomorphic stubs for normal load/store/call IC's can grow to |
5275 // a large number and therefore they need to go into a hash table. They are | 5275 // a large number and therefore they need to go into a hash table. They are |
5276 // used to load global properties from cells. | 5276 // used to load global properties from cells. |
5277 if (code->type() == NORMAL) { | 5277 if (code->type() == Code::NORMAL) { |
5278 // Make sure that a hash table is allocated for the normal load code cache. | 5278 // Make sure that a hash table is allocated for the normal load code cache. |
5279 if (normal_type_cache()->IsUndefined()) { | 5279 if (normal_type_cache()->IsUndefined()) { |
5280 Object* result; | 5280 Object* result; |
5281 { MaybeObject* maybe_result = | 5281 { MaybeObject* maybe_result = |
5282 CodeCacheHashTable::Allocate(CodeCacheHashTable::kInitialSize); | 5282 CodeCacheHashTable::Allocate(CodeCacheHashTable::kInitialSize); |
5283 if (!maybe_result->ToObject(&result)) return maybe_result; | 5283 if (!maybe_result->ToObject(&result)) return maybe_result; |
5284 } | 5284 } |
5285 set_normal_type_cache(result); | 5285 set_normal_type_cache(result); |
5286 } | 5286 } |
5287 return UpdateNormalTypeCache(name, code); | 5287 return UpdateNormalTypeCache(name, code); |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5358 Object* new_cache; | 5358 Object* new_cache; |
5359 { MaybeObject* maybe_new_cache = cache->Put(name, code); | 5359 { MaybeObject* maybe_new_cache = cache->Put(name, code); |
5360 if (!maybe_new_cache->ToObject(&new_cache)) return maybe_new_cache; | 5360 if (!maybe_new_cache->ToObject(&new_cache)) return maybe_new_cache; |
5361 } | 5361 } |
5362 set_normal_type_cache(new_cache); | 5362 set_normal_type_cache(new_cache); |
5363 return this; | 5363 return this; |
5364 } | 5364 } |
5365 | 5365 |
5366 | 5366 |
5367 Object* CodeCache::Lookup(String* name, Code::Flags flags) { | 5367 Object* CodeCache::Lookup(String* name, Code::Flags flags) { |
5368 if (Code::ExtractTypeFromFlags(flags) == NORMAL) { | 5368 if (Code::ExtractTypeFromFlags(flags) == Code::NORMAL) { |
5369 return LookupNormalTypeCache(name, flags); | 5369 return LookupNormalTypeCache(name, flags); |
5370 } else { | 5370 } else { |
5371 return LookupDefaultCache(name, flags); | 5371 return LookupDefaultCache(name, flags); |
5372 } | 5372 } |
5373 } | 5373 } |
5374 | 5374 |
5375 | 5375 |
5376 Object* CodeCache::LookupDefaultCache(String* name, Code::Flags flags) { | 5376 Object* CodeCache::LookupDefaultCache(String* name, Code::Flags flags) { |
5377 FixedArray* cache = default_cache(); | 5377 FixedArray* cache = default_cache(); |
5378 int length = cache->length(); | 5378 int length = cache->length(); |
(...skipping 17 matching lines...) Expand all Loading... |
5396 if (!normal_type_cache()->IsUndefined()) { | 5396 if (!normal_type_cache()->IsUndefined()) { |
5397 CodeCacheHashTable* cache = CodeCacheHashTable::cast(normal_type_cache()); | 5397 CodeCacheHashTable* cache = CodeCacheHashTable::cast(normal_type_cache()); |
5398 return cache->Lookup(name, flags); | 5398 return cache->Lookup(name, flags); |
5399 } else { | 5399 } else { |
5400 return GetHeap()->undefined_value(); | 5400 return GetHeap()->undefined_value(); |
5401 } | 5401 } |
5402 } | 5402 } |
5403 | 5403 |
5404 | 5404 |
5405 int CodeCache::GetIndex(Object* name, Code* code) { | 5405 int CodeCache::GetIndex(Object* name, Code* code) { |
5406 if (code->type() == NORMAL) { | 5406 if (code->type() == Code::NORMAL) { |
5407 if (normal_type_cache()->IsUndefined()) return -1; | 5407 if (normal_type_cache()->IsUndefined()) return -1; |
5408 CodeCacheHashTable* cache = CodeCacheHashTable::cast(normal_type_cache()); | 5408 CodeCacheHashTable* cache = CodeCacheHashTable::cast(normal_type_cache()); |
5409 return cache->GetIndex(String::cast(name), code->flags()); | 5409 return cache->GetIndex(String::cast(name), code->flags()); |
5410 } | 5410 } |
5411 | 5411 |
5412 FixedArray* array = default_cache(); | 5412 FixedArray* array = default_cache(); |
5413 int len = array->length(); | 5413 int len = array->length(); |
5414 for (int i = 0; i < len; i += kCodeCacheEntrySize) { | 5414 for (int i = 0; i < len; i += kCodeCacheEntrySize) { |
5415 if (array->get(i + kCodeCacheEntryCodeOffset) == code) return i + 1; | 5415 if (array->get(i + kCodeCacheEntryCodeOffset) == code) return i + 1; |
5416 } | 5416 } |
5417 return -1; | 5417 return -1; |
5418 } | 5418 } |
5419 | 5419 |
5420 | 5420 |
5421 void CodeCache::RemoveByIndex(Object* name, Code* code, int index) { | 5421 void CodeCache::RemoveByIndex(Object* name, Code* code, int index) { |
5422 if (code->type() == NORMAL) { | 5422 if (code->type() == Code::NORMAL) { |
5423 ASSERT(!normal_type_cache()->IsUndefined()); | 5423 ASSERT(!normal_type_cache()->IsUndefined()); |
5424 CodeCacheHashTable* cache = CodeCacheHashTable::cast(normal_type_cache()); | 5424 CodeCacheHashTable* cache = CodeCacheHashTable::cast(normal_type_cache()); |
5425 ASSERT(cache->GetIndex(String::cast(name), code->flags()) == index); | 5425 ASSERT(cache->GetIndex(String::cast(name), code->flags()) == index); |
5426 cache->RemoveByIndex(index); | 5426 cache->RemoveByIndex(index); |
5427 } else { | 5427 } else { |
5428 FixedArray* array = default_cache(); | 5428 FixedArray* array = default_cache(); |
5429 ASSERT(array->length() >= index && array->get(index)->IsCode()); | 5429 ASSERT(array->length() >= index && array->get(index)->IsCode()); |
5430 // Use null instead of undefined for deleted elements to distinguish | 5430 // Use null instead of undefined for deleted elements to distinguish |
5431 // deleted elements from unused elements. This distinction is used | 5431 // deleted elements from unused elements. This distinction is used |
5432 // when looking up in the cache and when updating the cache. | 5432 // when looking up in the cache and when updating the cache. |
(...skipping 3114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8547 case MONOMORPHIC_PROTOTYPE_FAILURE: return "MONOMORPHIC_PROTOTYPE_FAILURE"; | 8547 case MONOMORPHIC_PROTOTYPE_FAILURE: return "MONOMORPHIC_PROTOTYPE_FAILURE"; |
8548 case MEGAMORPHIC: return "MEGAMORPHIC"; | 8548 case MEGAMORPHIC: return "MEGAMORPHIC"; |
8549 case DEBUG_BREAK: return "DEBUG_BREAK"; | 8549 case DEBUG_BREAK: return "DEBUG_BREAK"; |
8550 case DEBUG_PREPARE_STEP_IN: return "DEBUG_PREPARE_STEP_IN"; | 8550 case DEBUG_PREPARE_STEP_IN: return "DEBUG_PREPARE_STEP_IN"; |
8551 } | 8551 } |
8552 UNREACHABLE(); | 8552 UNREACHABLE(); |
8553 return NULL; | 8553 return NULL; |
8554 } | 8554 } |
8555 | 8555 |
8556 | 8556 |
8557 const char* Code::PropertyType2String(PropertyType type) { | 8557 const char* Code::StubType2String(StubType type) { |
8558 switch (type) { | 8558 switch (type) { |
8559 case NORMAL: return "NORMAL"; | 8559 case NORMAL: return "NORMAL"; |
8560 case FIELD: return "FIELD"; | 8560 case FIELD: return "FIELD"; |
8561 case CONSTANT_FUNCTION: return "CONSTANT_FUNCTION"; | 8561 case CONSTANT_FUNCTION: return "CONSTANT_FUNCTION"; |
8562 case CALLBACKS: return "CALLBACKS"; | 8562 case CALLBACKS: return "CALLBACKS"; |
8563 case HANDLER: return "HANDLER"; | |
8564 case INTERCEPTOR: return "INTERCEPTOR"; | 8563 case INTERCEPTOR: return "INTERCEPTOR"; |
8565 case MAP_TRANSITION: return "MAP_TRANSITION"; | 8564 case MAP_TRANSITION: return "MAP_TRANSITION"; |
8566 case CONSTANT_TRANSITION: return "CONSTANT_TRANSITION"; | 8565 case NONEXISTENT: return "NONEXISTENT"; |
8567 case NULL_DESCRIPTOR: return "NULL_DESCRIPTOR"; | |
8568 } | 8566 } |
8569 UNREACHABLE(); // keep the compiler happy | 8567 UNREACHABLE(); // keep the compiler happy |
8570 return NULL; | 8568 return NULL; |
8571 } | 8569 } |
8572 | 8570 |
8573 | 8571 |
8574 void Code::PrintExtraICState(FILE* out, Kind kind, ExtraICState extra) { | 8572 void Code::PrintExtraICState(FILE* out, Kind kind, ExtraICState extra) { |
8575 const char* name = NULL; | 8573 const char* name = NULL; |
8576 switch (kind) { | 8574 switch (kind) { |
8577 case CALL_IC: | 8575 case CALL_IC: |
(...skipping 17 matching lines...) Expand all Loading... |
8595 } | 8593 } |
8596 } | 8594 } |
8597 | 8595 |
8598 | 8596 |
8599 void Code::Disassemble(const char* name, FILE* out) { | 8597 void Code::Disassemble(const char* name, FILE* out) { |
8600 PrintF(out, "kind = %s\n", Kind2String(kind())); | 8598 PrintF(out, "kind = %s\n", Kind2String(kind())); |
8601 if (is_inline_cache_stub()) { | 8599 if (is_inline_cache_stub()) { |
8602 PrintF(out, "ic_state = %s\n", ICState2String(ic_state())); | 8600 PrintF(out, "ic_state = %s\n", ICState2String(ic_state())); |
8603 PrintExtraICState(out, kind(), extra_ic_state()); | 8601 PrintExtraICState(out, kind(), extra_ic_state()); |
8604 if (ic_state() == MONOMORPHIC) { | 8602 if (ic_state() == MONOMORPHIC) { |
8605 PrintF(out, "type = %s\n", PropertyType2String(type())); | 8603 PrintF(out, "type = %s\n", StubType2String(type())); |
8606 } | 8604 } |
8607 if (is_call_stub() || is_keyed_call_stub()) { | 8605 if (is_call_stub() || is_keyed_call_stub()) { |
8608 PrintF(out, "argc = %d\n", arguments_count()); | 8606 PrintF(out, "argc = %d\n", arguments_count()); |
8609 } | 8607 } |
8610 if (is_compare_ic_stub()) { | 8608 if (is_compare_ic_stub()) { |
8611 CompareIC::State state = CompareIC::ComputeState(this); | 8609 CompareIC::State state = CompareIC::ComputeState(this); |
8612 PrintF(out, "compare_state = %s\n", CompareIC::GetStateName(state)); | 8610 PrintF(out, "compare_state = %s\n", CompareIC::GetStateName(state)); |
8613 } | 8611 } |
8614 if (is_compare_ic_stub() && major_key() == CodeStub::CompareIC) { | 8612 if (is_compare_ic_stub() && major_key() == CodeStub::CompareIC) { |
8615 Token::Value op = CompareIC::ComputeOperation(this); | 8613 Token::Value op = CompareIC::ComputeOperation(this); |
(...skipping 4682 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
13298 set_year(Smi::FromInt(year), SKIP_WRITE_BARRIER); | 13296 set_year(Smi::FromInt(year), SKIP_WRITE_BARRIER); |
13299 set_month(Smi::FromInt(month), SKIP_WRITE_BARRIER); | 13297 set_month(Smi::FromInt(month), SKIP_WRITE_BARRIER); |
13300 set_day(Smi::FromInt(day), SKIP_WRITE_BARRIER); | 13298 set_day(Smi::FromInt(day), SKIP_WRITE_BARRIER); |
13301 set_weekday(Smi::FromInt(weekday), SKIP_WRITE_BARRIER); | 13299 set_weekday(Smi::FromInt(weekday), SKIP_WRITE_BARRIER); |
13302 set_hour(Smi::FromInt(hour), SKIP_WRITE_BARRIER); | 13300 set_hour(Smi::FromInt(hour), SKIP_WRITE_BARRIER); |
13303 set_min(Smi::FromInt(min), SKIP_WRITE_BARRIER); | 13301 set_min(Smi::FromInt(min), SKIP_WRITE_BARRIER); |
13304 set_sec(Smi::FromInt(sec), SKIP_WRITE_BARRIER); | 13302 set_sec(Smi::FromInt(sec), SKIP_WRITE_BARRIER); |
13305 } | 13303 } |
13306 | 13304 |
13307 } } // namespace v8::internal | 13305 } } // namespace v8::internal |
OLD | NEW |