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

Side by Side Diff: src/bootstrapper.cc

Issue 7066048: Compress sources of JS libraries in addition to the snapshot. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Make decompressor class public Created 9 years, 6 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/bootstrapper.h ('k') | src/d8.cc » ('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 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 29 matching lines...) Expand all
40 #include "snapshot.h" 40 #include "snapshot.h"
41 #include "extensions/externalize-string-extension.h" 41 #include "extensions/externalize-string-extension.h"
42 #include "extensions/gc-extension.h" 42 #include "extensions/gc-extension.h"
43 43
44 namespace v8 { 44 namespace v8 {
45 namespace internal { 45 namespace internal {
46 46
47 47
48 NativesExternalStringResource::NativesExternalStringResource( 48 NativesExternalStringResource::NativesExternalStringResource(
49 Bootstrapper* bootstrapper, 49 Bootstrapper* bootstrapper,
50 const char* source) 50 const char* source,
51 : data_(source), length_(StrLength(source)) { 51 size_t length)
52 : data_(source), length_(length) {
52 if (bootstrapper->delete_these_non_arrays_on_tear_down_ == NULL) { 53 if (bootstrapper->delete_these_non_arrays_on_tear_down_ == NULL) {
53 bootstrapper->delete_these_non_arrays_on_tear_down_ = new List<char*>(2); 54 bootstrapper->delete_these_non_arrays_on_tear_down_ = new List<char*>(2);
54 } 55 }
55 // The resources are small objects and we only make a fixed number of 56 // The resources are small objects and we only make a fixed number of
56 // them, but let's clean them up on exit for neatness. 57 // them, but let's clean them up on exit for neatness.
57 bootstrapper->delete_these_non_arrays_on_tear_down_-> 58 bootstrapper->delete_these_non_arrays_on_tear_down_->
58 Add(reinterpret_cast<char*>(this)); 59 Add(reinterpret_cast<char*>(this));
59 } 60 }
60 61
61 62
62 Bootstrapper::Bootstrapper() 63 Bootstrapper::Bootstrapper()
63 : nesting_(0), 64 : nesting_(0),
64 extensions_cache_(Script::TYPE_EXTENSION), 65 extensions_cache_(Script::TYPE_EXTENSION),
65 delete_these_non_arrays_on_tear_down_(NULL), 66 delete_these_non_arrays_on_tear_down_(NULL),
66 delete_these_arrays_on_tear_down_(NULL) { 67 delete_these_arrays_on_tear_down_(NULL) {
67 } 68 }
68 69
69 70
70 Handle<String> Bootstrapper::NativesSourceLookup(int index) { 71 Handle<String> Bootstrapper::NativesSourceLookup(int index) {
71 ASSERT(0 <= index && index < Natives::GetBuiltinsCount()); 72 ASSERT(0 <= index && index < Natives::GetBuiltinsCount());
72 Isolate* isolate = Isolate::Current(); 73 Isolate* isolate = Isolate::Current();
73 Factory* factory = isolate->factory(); 74 Factory* factory = isolate->factory();
74 Heap* heap = isolate->heap(); 75 Heap* heap = isolate->heap();
75 if (heap->natives_source_cache()->get(index)->IsUndefined()) { 76 if (heap->natives_source_cache()->get(index)->IsUndefined()) {
76 if (!Snapshot::IsEnabled() || FLAG_new_snapshot) { 77 if (!Snapshot::IsEnabled() || FLAG_new_snapshot) {
77 // We can use external strings for the natives. 78 // We can use external strings for the natives.
79 Vector<const char> source = Natives::GetRawScriptSource(index);
78 NativesExternalStringResource* resource = 80 NativesExternalStringResource* resource =
79 new NativesExternalStringResource(this, 81 new NativesExternalStringResource(this,
80 Natives::GetScriptSource(index).start()); 82 source.start(),
83 source.length());
81 Handle<String> source_code = 84 Handle<String> source_code =
82 factory->NewExternalStringFromAscii(resource); 85 factory->NewExternalStringFromAscii(resource);
83 heap->natives_source_cache()->set(index, *source_code); 86 heap->natives_source_cache()->set(index, *source_code);
84 } else { 87 } else {
85 // Old snapshot code can't cope with external strings at all. 88 // Old snapshot code can't cope with external strings at all.
86 Handle<String> source_code = 89 Handle<String> source_code =
87 factory->NewStringFromAscii(Natives::GetScriptSource(index)); 90 factory->NewStringFromAscii(Natives::GetRawScriptSource(index));
88 heap->natives_source_cache()->set(index, *source_code); 91 heap->natives_source_cache()->set(index, *source_code);
89 } 92 }
90 } 93 }
91 Handle<Object> cached_source(heap->natives_source_cache()->get(index)); 94 Handle<Object> cached_source(heap->natives_source_cache()->get(index));
92 return Handle<String>::cast(cached_source); 95 return Handle<String>::cast(cached_source);
93 } 96 }
94 97
95 98
96 void Bootstrapper::Initialize(bool create_heap_objects) { 99 void Bootstrapper::Initialize(bool create_heap_objects) {
97 extensions_cache_.Initialize(create_heap_objects); 100 extensions_cache_.Initialize(create_heap_objects);
(...skipping 1077 matching lines...) Expand 10 before | Expand all | Expand 10 after
1175 Handle<String> source_code = 1178 Handle<String> source_code =
1176 isolate->bootstrapper()->NativesSourceLookup(index); 1179 isolate->bootstrapper()->NativesSourceLookup(index);
1177 return CompileNative(name, source_code); 1180 return CompileNative(name, source_code);
1178 } 1181 }
1179 1182
1180 1183
1181 bool Genesis::CompileExperimentalBuiltin(Isolate* isolate, int index) { 1184 bool Genesis::CompileExperimentalBuiltin(Isolate* isolate, int index) {
1182 Vector<const char> name = ExperimentalNatives::GetScriptName(index); 1185 Vector<const char> name = ExperimentalNatives::GetScriptName(index);
1183 Factory* factory = isolate->factory(); 1186 Factory* factory = isolate->factory();
1184 Handle<String> source_code = 1187 Handle<String> source_code =
1185 factory->NewStringFromAscii(ExperimentalNatives::GetScriptSource(index)); 1188 factory->NewStringFromAscii(
1189 ExperimentalNatives::GetRawScriptSource(index));
1186 return CompileNative(name, source_code); 1190 return CompileNative(name, source_code);
1187 } 1191 }
1188 1192
1189 1193
1190 bool Genesis::CompileNative(Vector<const char> name, Handle<String> source) { 1194 bool Genesis::CompileNative(Vector<const char> name, Handle<String> source) {
1191 HandleScope scope; 1195 HandleScope scope;
1192 Isolate* isolate = source->GetIsolate(); 1196 Isolate* isolate = source->GetIsolate();
1193 #ifdef ENABLE_DEBUGGER_SUPPORT 1197 #ifdef ENABLE_DEBUGGER_SUPPORT
1194 isolate->debugger()->set_compiling_natives(true); 1198 isolate->debugger()->set_compiling_natives(true);
1195 #endif 1199 #endif
(...skipping 980 matching lines...) Expand 10 before | Expand all | Expand 10 after
2176 return from + sizeof(NestingCounterType); 2180 return from + sizeof(NestingCounterType);
2177 } 2181 }
2178 2182
2179 2183
2180 // Called when the top-level V8 mutex is destroyed. 2184 // Called when the top-level V8 mutex is destroyed.
2181 void Bootstrapper::FreeThreadResources() { 2185 void Bootstrapper::FreeThreadResources() {
2182 ASSERT(!IsActive()); 2186 ASSERT(!IsActive());
2183 } 2187 }
2184 2188
2185 } } // namespace v8::internal 2189 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/bootstrapper.h ('k') | src/d8.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698