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 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
69 delete_these_arrays_on_tear_down_(NULL) { | 69 delete_these_arrays_on_tear_down_(NULL) { |
70 } | 70 } |
71 | 71 |
72 | 72 |
73 Handle<String> Bootstrapper::NativesSourceLookup(int index) { | 73 Handle<String> Bootstrapper::NativesSourceLookup(int index) { |
74 ASSERT(0 <= index && index < Natives::GetBuiltinsCount()); | 74 ASSERT(0 <= index && index < Natives::GetBuiltinsCount()); |
75 Isolate* isolate = Isolate::Current(); | 75 Isolate* isolate = Isolate::Current(); |
76 Factory* factory = isolate->factory(); | 76 Factory* factory = isolate->factory(); |
77 Heap* heap = isolate->heap(); | 77 Heap* heap = isolate->heap(); |
78 if (heap->natives_source_cache()->get(index)->IsUndefined()) { | 78 if (heap->natives_source_cache()->get(index)->IsUndefined()) { |
79 if (!Snapshot::IsEnabled() || FLAG_new_snapshot) { | 79 // We can use external strings for the natives. |
80 // We can use external strings for the natives. | 80 Vector<const char> source = Natives::GetRawScriptSource(index); |
81 Vector<const char> source = Natives::GetRawScriptSource(index); | 81 NativesExternalStringResource* resource = |
82 NativesExternalStringResource* resource = | 82 new NativesExternalStringResource(this, |
83 new NativesExternalStringResource(this, | 83 source.start(), |
84 source.start(), | 84 source.length()); |
85 source.length()); | 85 Handle<String> source_code = |
86 Handle<String> source_code = | 86 factory->NewExternalStringFromAscii(resource); |
87 factory->NewExternalStringFromAscii(resource); | 87 heap->natives_source_cache()->set(index, *source_code); |
88 heap->natives_source_cache()->set(index, *source_code); | |
89 } else { | |
90 // Old snapshot code can't cope with external strings at all. | |
91 Handle<String> source_code = | |
92 factory->NewStringFromAscii(Natives::GetRawScriptSource(index)); | |
93 heap->natives_source_cache()->set(index, *source_code); | |
94 } | |
95 } | 88 } |
96 Handle<Object> cached_source(heap->natives_source_cache()->get(index)); | 89 Handle<Object> cached_source(heap->natives_source_cache()->get(index)); |
97 return Handle<String>::cast(cached_source); | 90 return Handle<String>::cast(cached_source); |
98 } | 91 } |
99 | 92 |
100 | 93 |
101 void Bootstrapper::Initialize(bool create_heap_objects) { | 94 void Bootstrapper::Initialize(bool create_heap_objects) { |
102 extensions_cache_.Initialize(create_heap_objects); | 95 extensions_cache_.Initialize(create_heap_objects); |
103 GCExtension::Register(); | 96 GCExtension::Register(); |
104 ExternalizeStringExtension::Register(); | 97 ExternalizeStringExtension::Register(); |
(...skipping 2264 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2369 return from + sizeof(NestingCounterType); | 2362 return from + sizeof(NestingCounterType); |
2370 } | 2363 } |
2371 | 2364 |
2372 | 2365 |
2373 // Called when the top-level V8 mutex is destroyed. | 2366 // Called when the top-level V8 mutex is destroyed. |
2374 void Bootstrapper::FreeThreadResources() { | 2367 void Bootstrapper::FreeThreadResources() { |
2375 ASSERT(!IsActive()); | 2368 ASSERT(!IsActive()); |
2376 } | 2369 } |
2377 | 2370 |
2378 } } // namespace v8::internal | 2371 } } // namespace v8::internal |
OLD | NEW |