Chromium Code Reviews| 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 1764 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1775 JSFunction::cast(constructor)->initial_map() == map) { | 1775 JSFunction::cast(constructor)->initial_map() == map) { |
| 1776 // If we still have the original map, set in-object properties directly. | 1776 // If we still have the original map, set in-object properties directly. |
| 1777 regexp->InObjectPropertyAtPut(JSRegExp::kSourceFieldIndex, source); | 1777 regexp->InObjectPropertyAtPut(JSRegExp::kSourceFieldIndex, source); |
| 1778 // TODO(lrn): Consider skipping write barrier on booleans as well. | 1778 // TODO(lrn): Consider skipping write barrier on booleans as well. |
| 1779 // Both true and false should be in oldspace at all times. | 1779 // Both true and false should be in oldspace at all times. |
| 1780 regexp->InObjectPropertyAtPut(JSRegExp::kGlobalFieldIndex, global); | 1780 regexp->InObjectPropertyAtPut(JSRegExp::kGlobalFieldIndex, global); |
| 1781 regexp->InObjectPropertyAtPut(JSRegExp::kIgnoreCaseFieldIndex, ignoreCase); | 1781 regexp->InObjectPropertyAtPut(JSRegExp::kIgnoreCaseFieldIndex, ignoreCase); |
| 1782 regexp->InObjectPropertyAtPut(JSRegExp::kMultilineFieldIndex, multiline); | 1782 regexp->InObjectPropertyAtPut(JSRegExp::kMultilineFieldIndex, multiline); |
| 1783 regexp->InObjectPropertyAtPut(JSRegExp::kLastIndexFieldIndex, | 1783 regexp->InObjectPropertyAtPut(JSRegExp::kLastIndexFieldIndex, |
| 1784 Smi::FromInt(0), | 1784 Smi::FromInt(0), |
| 1785 SKIP_WRITE_BARRIER); | 1785 SKIP_WRITE_BARRIER); // It's a Smi. |
| 1786 return regexp; | 1786 return regexp; |
| 1787 } | 1787 } |
| 1788 | 1788 |
| 1789 // Map has changed, so use generic, but slower, method. | 1789 // Map has changed, so use generic, but slower, method. |
| 1790 PropertyAttributes final = | 1790 PropertyAttributes final = |
| 1791 static_cast<PropertyAttributes>(READ_ONLY | DONT_ENUM | DONT_DELETE); | 1791 static_cast<PropertyAttributes>(READ_ONLY | DONT_ENUM | DONT_DELETE); |
| 1792 PropertyAttributes writable = | 1792 PropertyAttributes writable = |
| 1793 static_cast<PropertyAttributes>(DONT_ENUM | DONT_DELETE); | 1793 static_cast<PropertyAttributes>(DONT_ENUM | DONT_DELETE); |
| 1794 Heap* heap = isolate->heap(); | 1794 Heap* heap = isolate->heap(); |
| 1795 MaybeObject* result; | 1795 MaybeObject* result; |
| (...skipping 384 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2180 int number_of_literals = fun->NumberOfLiterals(); | 2180 int number_of_literals = fun->NumberOfLiterals(); |
| 2181 Handle<FixedArray> literals = | 2181 Handle<FixedArray> literals = |
| 2182 isolate->factory()->NewFixedArray(number_of_literals, TENURED); | 2182 isolate->factory()->NewFixedArray(number_of_literals, TENURED); |
| 2183 if (number_of_literals > 0) { | 2183 if (number_of_literals > 0) { |
| 2184 // Insert the object, regexp and array functions in the literals | 2184 // Insert the object, regexp and array functions in the literals |
| 2185 // array prefix. These are the functions that will be used when | 2185 // array prefix. These are the functions that will be used when |
| 2186 // creating object, regexp and array literals. | 2186 // creating object, regexp and array literals. |
| 2187 literals->set(JSFunction::kLiteralGlobalContextIndex, | 2187 literals->set(JSFunction::kLiteralGlobalContextIndex, |
| 2188 context->global_context()); | 2188 context->global_context()); |
| 2189 } | 2189 } |
| 2190 // It's okay to skip the write barrier here because the literals | 2190 target->set_literals(*literals); |
| 2191 // are guaranteed to be in old space. | |
| 2192 target->set_literals(*literals, SKIP_WRITE_BARRIER); | |
| 2193 target->set_next_function_link(isolate->heap()->undefined_value()); | 2191 target->set_next_function_link(isolate->heap()->undefined_value()); |
| 2194 } | 2192 } |
| 2195 | 2193 |
| 2196 target->set_context(*context); | 2194 target->set_context(*context); |
| 2197 return *target; | 2195 return *target; |
| 2198 } | 2196 } |
| 2199 | 2197 |
| 2200 | 2198 |
| 2201 RUNTIME_FUNCTION(MaybeObject*, Runtime_SetExpectedNumberOfProperties) { | 2199 RUNTIME_FUNCTION(MaybeObject*, Runtime_SetExpectedNumberOfProperties) { |
| 2202 HandleScope scope(isolate); | 2200 HandleScope scope(isolate); |
| (...skipping 3867 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 6070 // not in the cache and fills the remainder with smi zeros. Returns | 6068 // not in the cache and fills the remainder with smi zeros. Returns |
| 6071 // the length of the successfully copied prefix. | 6069 // the length of the successfully copied prefix. |
| 6072 static int CopyCachedAsciiCharsToArray(Heap* heap, | 6070 static int CopyCachedAsciiCharsToArray(Heap* heap, |
| 6073 const char* chars, | 6071 const char* chars, |
| 6074 FixedArray* elements, | 6072 FixedArray* elements, |
| 6075 int length) { | 6073 int length) { |
| 6076 AssertNoAllocation no_gc; | 6074 AssertNoAllocation no_gc; |
| 6077 FixedArray* ascii_cache = heap->single_character_string_cache(); | 6075 FixedArray* ascii_cache = heap->single_character_string_cache(); |
| 6078 Object* undefined = heap->undefined_value(); | 6076 Object* undefined = heap->undefined_value(); |
| 6079 int i; | 6077 int i; |
| 6078 WriteBarrierMode mode = elements->GetWriteBarrierMode(no_gc); | |
| 6080 for (i = 0; i < length; ++i) { | 6079 for (i = 0; i < length; ++i) { |
| 6081 Object* value = ascii_cache->get(chars[i]); | 6080 Object* value = ascii_cache->get(chars[i]); |
| 6082 if (value == undefined) break; | 6081 if (value == undefined) break; |
| 6083 ASSERT(!heap->InNewSpace(value)); | 6082 ASSERT(!heap->InNewSpace(value)); |
|
Vyacheslav Egorov (Chromium)
2011/09/08 11:56:23
I think this assertion is not required any more.
| |
| 6084 elements->set(i, value, SKIP_WRITE_BARRIER); | 6083 elements->set(i, value, mode); |
| 6085 } | 6084 } |
| 6086 if (i < length) { | 6085 if (i < length) { |
| 6087 ASSERT(Smi::FromInt(0) == 0); | 6086 ASSERT(Smi::FromInt(0) == 0); |
| 6088 memset(elements->data_start() + i, 0, kPointerSize * (length - i)); | 6087 memset(elements->data_start() + i, 0, kPointerSize * (length - i)); |
| 6089 } | 6088 } |
| 6090 #ifdef DEBUG | 6089 #ifdef DEBUG |
| 6091 for (int j = 0; j < length; ++j) { | 6090 for (int j = 0; j < length; ++j) { |
| 6092 Object* element = elements->get(j); | 6091 Object* element = elements->get(j); |
| 6093 ASSERT(element == Smi::FromInt(0) || | 6092 ASSERT(element == Smi::FromInt(0) || |
| 6094 (element->IsString() && String::cast(element)->LooksValid())); | 6093 (element->IsString() && String::cast(element)->LooksValid())); |
| (...skipping 6897 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 12992 } else { | 12991 } else { |
| 12993 // Handle last resort GC and make sure to allow future allocations | 12992 // Handle last resort GC and make sure to allow future allocations |
| 12994 // to grow the heap without causing GCs (if possible). | 12993 // to grow the heap without causing GCs (if possible). |
| 12995 isolate->counters()->gc_last_resort_from_js()->Increment(); | 12994 isolate->counters()->gc_last_resort_from_js()->Increment(); |
| 12996 isolate->heap()->CollectAllGarbage(Heap::kNoGCFlags); | 12995 isolate->heap()->CollectAllGarbage(Heap::kNoGCFlags); |
| 12997 } | 12996 } |
| 12998 } | 12997 } |
| 12999 | 12998 |
| 13000 | 12999 |
| 13001 } } // namespace v8::internal | 13000 } } // namespace v8::internal |
| OLD | NEW |