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 2758 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2769 set_termination_exception(obj); | 2769 set_termination_exception(obj); |
2770 | 2770 |
2771 // Allocate the empty string. | 2771 // Allocate the empty string. |
2772 { MaybeObject* maybe_obj = AllocateRawOneByteString(0, TENURED); | 2772 { MaybeObject* maybe_obj = AllocateRawOneByteString(0, TENURED); |
2773 if (!maybe_obj->ToObject(&obj)) return false; | 2773 if (!maybe_obj->ToObject(&obj)) return false; |
2774 } | 2774 } |
2775 set_empty_string(String::cast(obj)); | 2775 set_empty_string(String::cast(obj)); |
2776 | 2776 |
2777 for (unsigned i = 0; i < ARRAY_SIZE(constant_symbol_table); i++) { | 2777 for (unsigned i = 0; i < ARRAY_SIZE(constant_symbol_table); i++) { |
2778 { MaybeObject* maybe_obj = | 2778 { MaybeObject* maybe_obj = |
2779 LookupAsciiSymbol(constant_symbol_table[i].contents); | 2779 LookupUtf8Symbol(constant_symbol_table[i].contents); |
2780 if (!maybe_obj->ToObject(&obj)) return false; | 2780 if (!maybe_obj->ToObject(&obj)) return false; |
2781 } | 2781 } |
2782 roots_[constant_symbol_table[i].index] = String::cast(obj); | 2782 roots_[constant_symbol_table[i].index] = String::cast(obj); |
2783 } | 2783 } |
2784 | 2784 |
2785 // Allocate the hidden symbol which is used to identify the hidden properties | 2785 // Allocate the hidden symbol which is used to identify the hidden properties |
2786 // in JSObjects. The hash code has a special value so that it will not match | 2786 // in JSObjects. The hash code has a special value so that it will not match |
2787 // the empty string when searching for the property. It cannot be part of the | 2787 // the empty string when searching for the property. It cannot be part of the |
2788 // loop above because it needs to be allocated manually with the special | 2788 // loop above because it needs to be allocated manually with the special |
2789 // hash code in place. The hash code for the hidden_symbol is zero to ensure | 2789 // hash code in place. The hash code for the hidden_symbol is zero to ensure |
(...skipping 813 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3603 | 3603 |
3604 | 3604 |
3605 MaybeObject* Heap::LookupSingleCharacterStringFromCode(uint16_t code) { | 3605 MaybeObject* Heap::LookupSingleCharacterStringFromCode(uint16_t code) { |
3606 if (code <= String::kMaxAsciiCharCode) { | 3606 if (code <= String::kMaxAsciiCharCode) { |
3607 Object* value = single_character_string_cache()->get(code); | 3607 Object* value = single_character_string_cache()->get(code); |
3608 if (value != undefined_value()) return value; | 3608 if (value != undefined_value()) return value; |
3609 | 3609 |
3610 char buffer[1]; | 3610 char buffer[1]; |
3611 buffer[0] = static_cast<char>(code); | 3611 buffer[0] = static_cast<char>(code); |
3612 Object* result; | 3612 Object* result; |
3613 MaybeObject* maybe_result = LookupSymbol(Vector<const char>(buffer, 1)); | 3613 MaybeObject* maybe_result = |
| 3614 LookupOneByteSymbol(Vector<const char>(buffer, 1)); |
3614 | 3615 |
3615 if (!maybe_result->ToObject(&result)) return maybe_result; | 3616 if (!maybe_result->ToObject(&result)) return maybe_result; |
3616 single_character_string_cache()->set(code, result); | 3617 single_character_string_cache()->set(code, result); |
3617 return result; | 3618 return result; |
3618 } | 3619 } |
3619 | 3620 |
3620 Object* result; | 3621 Object* result; |
3621 { MaybeObject* maybe_result = AllocateRawTwoByteString(1); | 3622 { MaybeObject* maybe_result = AllocateRawTwoByteString(1); |
3622 if (!maybe_result->ToObject(&result)) return maybe_result; | 3623 if (!maybe_result->ToObject(&result)) return maybe_result; |
3623 } | 3624 } |
(...skipping 830 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4454 // Allocate the backing storage for the properties. | 4455 // Allocate the backing storage for the properties. |
4455 int prop_size = map->unused_property_fields() - map->inobject_properties(); | 4456 int prop_size = map->unused_property_fields() - map->inobject_properties(); |
4456 Object* properties; | 4457 Object* properties; |
4457 maybe = AllocateFixedArray(prop_size, TENURED); | 4458 maybe = AllocateFixedArray(prop_size, TENURED); |
4458 if (!maybe->ToObject(&properties)) return maybe; | 4459 if (!maybe->ToObject(&properties)) return maybe; |
4459 | 4460 |
4460 // Functions require some allocation, which might fail here. | 4461 // Functions require some allocation, which might fail here. |
4461 SharedFunctionInfo* shared = NULL; | 4462 SharedFunctionInfo* shared = NULL; |
4462 if (type == JS_FUNCTION_TYPE) { | 4463 if (type == JS_FUNCTION_TYPE) { |
4463 String* name; | 4464 String* name; |
4464 maybe = LookupAsciiSymbol("<freezing call trap>"); | 4465 maybe = LookupOneByteSymbol(STATIC_ASCII_VECTOR("<freezing call trap>")); |
4465 if (!maybe->To<String>(&name)) return maybe; | 4466 if (!maybe->To<String>(&name)) return maybe; |
4466 maybe = AllocateSharedFunctionInfo(name); | 4467 maybe = AllocateSharedFunctionInfo(name); |
4467 if (!maybe->To<SharedFunctionInfo>(&shared)) return maybe; | 4468 if (!maybe->To<SharedFunctionInfo>(&shared)) return maybe; |
4468 } | 4469 } |
4469 | 4470 |
4470 // Because of possible retries of this function after failure, | 4471 // Because of possible retries of this function after failure, |
4471 // we must NOT fail after this point, where we have changed the type! | 4472 // we must NOT fail after this point, where we have changed the type! |
4472 | 4473 |
4473 // Reset the map for the object. | 4474 // Reset the map for the object. |
4474 object->set_map(map); | 4475 object->set_map(map); |
(...skipping 1072 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5547 VerifyPointersVisitor no_dirty_regions_visitor; | 5548 VerifyPointersVisitor no_dirty_regions_visitor; |
5548 old_data_space_->Verify(&no_dirty_regions_visitor); | 5549 old_data_space_->Verify(&no_dirty_regions_visitor); |
5549 code_space_->Verify(&no_dirty_regions_visitor); | 5550 code_space_->Verify(&no_dirty_regions_visitor); |
5550 cell_space_->Verify(&no_dirty_regions_visitor); | 5551 cell_space_->Verify(&no_dirty_regions_visitor); |
5551 | 5552 |
5552 lo_space_->Verify(); | 5553 lo_space_->Verify(); |
5553 } | 5554 } |
5554 #endif | 5555 #endif |
5555 | 5556 |
5556 | 5557 |
5557 MaybeObject* Heap::LookupSymbol(Vector<const char> string) { | 5558 MaybeObject* Heap::LookupUtf8Symbol(Vector<const char> string) { |
5558 Object* symbol = NULL; | 5559 Object* symbol = NULL; |
5559 Object* new_table; | 5560 Object* new_table; |
5560 { MaybeObject* maybe_new_table = | 5561 { MaybeObject* maybe_new_table = |
5561 symbol_table()->LookupSymbol(string, &symbol); | 5562 symbol_table()->LookupUtf8Symbol(string, &symbol); |
5562 if (!maybe_new_table->ToObject(&new_table)) return maybe_new_table; | 5563 if (!maybe_new_table->ToObject(&new_table)) return maybe_new_table; |
5563 } | 5564 } |
5564 // Can't use set_symbol_table because SymbolTable::cast knows that | 5565 // Can't use set_symbol_table because SymbolTable::cast knows that |
5565 // SymbolTable is a singleton and checks for identity. | 5566 // SymbolTable is a singleton and checks for identity. |
5566 roots_[kSymbolTableRootIndex] = new_table; | 5567 roots_[kSymbolTableRootIndex] = new_table; |
5567 ASSERT(symbol != NULL); | 5568 ASSERT(symbol != NULL); |
5568 return symbol; | 5569 return symbol; |
5569 } | 5570 } |
5570 | 5571 |
5571 | 5572 |
5572 MaybeObject* Heap::LookupAsciiSymbol(Vector<const char> string) { | 5573 MaybeObject* Heap::LookupOneByteSymbol(Vector<const char> string) { |
5573 Object* symbol = NULL; | 5574 Object* symbol = NULL; |
5574 Object* new_table; | 5575 Object* new_table; |
5575 { MaybeObject* maybe_new_table = | 5576 { MaybeObject* maybe_new_table = |
5576 symbol_table()->LookupAsciiSymbol(string, &symbol); | 5577 symbol_table()->LookupOneByteSymbol(string, &symbol); |
5577 if (!maybe_new_table->ToObject(&new_table)) return maybe_new_table; | 5578 if (!maybe_new_table->ToObject(&new_table)) return maybe_new_table; |
5578 } | 5579 } |
5579 // Can't use set_symbol_table because SymbolTable::cast knows that | 5580 // Can't use set_symbol_table because SymbolTable::cast knows that |
5580 // SymbolTable is a singleton and checks for identity. | 5581 // SymbolTable is a singleton and checks for identity. |
5581 roots_[kSymbolTableRootIndex] = new_table; | 5582 roots_[kSymbolTableRootIndex] = new_table; |
5582 ASSERT(symbol != NULL); | 5583 ASSERT(symbol != NULL); |
5583 return symbol; | 5584 return symbol; |
5584 } | 5585 } |
5585 | 5586 |
5586 | 5587 |
5587 MaybeObject* Heap::LookupAsciiSymbol(Handle<SeqOneByteString> string, | 5588 MaybeObject* Heap::LookupOneByteSymbol(Handle<SeqOneByteString> string, |
5588 int from, | 5589 int from, |
5589 int length) { | 5590 int length) { |
5590 Object* symbol = NULL; | 5591 Object* symbol = NULL; |
5591 Object* new_table; | 5592 Object* new_table; |
5592 { MaybeObject* maybe_new_table = | 5593 { MaybeObject* maybe_new_table = |
5593 symbol_table()->LookupSubStringAsciiSymbol(string, | 5594 symbol_table()->LookupSubStringOneByteSymbol(string, |
5594 from, | 5595 from, |
5595 length, | 5596 length, |
5596 &symbol); | 5597 &symbol); |
5597 if (!maybe_new_table->ToObject(&new_table)) return maybe_new_table; | 5598 if (!maybe_new_table->ToObject(&new_table)) return maybe_new_table; |
5598 } | 5599 } |
5599 // Can't use set_symbol_table because SymbolTable::cast knows that | 5600 // Can't use set_symbol_table because SymbolTable::cast knows that |
5600 // SymbolTable is a singleton and checks for identity. | 5601 // SymbolTable is a singleton and checks for identity. |
5601 roots_[kSymbolTableRootIndex] = new_table; | 5602 roots_[kSymbolTableRootIndex] = new_table; |
5602 ASSERT(symbol != NULL); | 5603 ASSERT(symbol != NULL); |
5603 return symbol; | 5604 return symbol; |
(...skipping 1802 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7406 static_cast<int>(object_sizes_last_time_[index])); | 7407 static_cast<int>(object_sizes_last_time_[index])); |
7407 FIXED_ARRAY_SUB_INSTANCE_TYPE_LIST(ADJUST_LAST_TIME_OBJECT_COUNT) | 7408 FIXED_ARRAY_SUB_INSTANCE_TYPE_LIST(ADJUST_LAST_TIME_OBJECT_COUNT) |
7408 #undef ADJUST_LAST_TIME_OBJECT_COUNT | 7409 #undef ADJUST_LAST_TIME_OBJECT_COUNT |
7409 | 7410 |
7410 memcpy(object_counts_last_time_, object_counts_, sizeof(object_counts_)); | 7411 memcpy(object_counts_last_time_, object_counts_, sizeof(object_counts_)); |
7411 memcpy(object_sizes_last_time_, object_sizes_, sizeof(object_sizes_)); | 7412 memcpy(object_sizes_last_time_, object_sizes_, sizeof(object_sizes_)); |
7412 ClearObjectStats(); | 7413 ClearObjectStats(); |
7413 } | 7414 } |
7414 | 7415 |
7415 } } // namespace v8::internal | 7416 } } // namespace v8::internal |
OLD | NEW |