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

Side by Side Diff: src/factory.cc

Issue 43008: Make unique id to all scripts work with snapshot (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: Created 11 years, 9 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 | « no previous file | src/heap.h » ('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 2006-2008 the V8 project authors. All rights reserved. 1 // Copyright 2006-2008 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 135 matching lines...) Expand 10 before | Expand all | Expand 10 after
146 146
147 Handle<AccessorInfo> Factory::NewAccessorInfo() { 147 Handle<AccessorInfo> Factory::NewAccessorInfo() {
148 Handle<AccessorInfo> info = 148 Handle<AccessorInfo> info =
149 Handle<AccessorInfo>::cast(NewStruct(ACCESSOR_INFO_TYPE)); 149 Handle<AccessorInfo>::cast(NewStruct(ACCESSOR_INFO_TYPE));
150 info->set_flag(0); // Must clear the flag, it was initialized as undefined. 150 info->set_flag(0); // Must clear the flag, it was initialized as undefined.
151 return info; 151 return info;
152 } 152 }
153 153
154 154
155 Handle<Script> Factory::NewScript(Handle<String> source) { 155 Handle<Script> Factory::NewScript(Handle<String> source) {
156 static uint32_t next_id = 1; 156 // Generate id for this script.
157 157 int id;
158 if (Heap::last_script_id()->IsUndefined()) {
159 // Script ids start from one.
160 id = 1;
161 } else {
162 // Increment id, wrap when positive smi is exhausted.
163 id = Smi::cast(Heap::last_script_id())->value();
164 id++;
165 if (!Smi::IsValid(id)) {
166 id = 0;
167 }
168 }
169 Heap::SetLastScriptId(Smi::FromInt(id));
170
171 // Create and initialize script object.
158 Handle<Script> script = Handle<Script>::cast(NewStruct(SCRIPT_TYPE)); 172 Handle<Script> script = Handle<Script>::cast(NewStruct(SCRIPT_TYPE));
159 script->set_source(*source); 173 script->set_source(*source);
160 script->set_name(Heap::undefined_value()); 174 script->set_name(Heap::undefined_value());
161 script->set_id(*Factory::NewNumberFromUint(next_id++)); 175 script->set_id(Heap::last_script_id());
162 script->set_line_offset(Smi::FromInt(0)); 176 script->set_line_offset(Smi::FromInt(0));
163 script->set_column_offset(Smi::FromInt(0)); 177 script->set_column_offset(Smi::FromInt(0));
164 script->set_type(Smi::FromInt(SCRIPT_TYPE_NORMAL)); 178 script->set_type(Smi::FromInt(SCRIPT_TYPE_NORMAL));
165 script->set_wrapper(*Factory::NewProxy(0, TENURED)); 179 script->set_wrapper(*Factory::NewProxy(0, TENURED));
166 script->set_line_ends(Heap::undefined_value()); 180 script->set_line_ends(Heap::undefined_value());
181
167 return script; 182 return script;
168 } 183 }
169 184
170 185
171 Handle<Proxy> Factory::NewProxy(Address addr, PretenureFlag pretenure) { 186 Handle<Proxy> Factory::NewProxy(Address addr, PretenureFlag pretenure) {
172 CALL_HEAP_FUNCTION(Heap::AllocateProxy(addr, pretenure), Proxy); 187 CALL_HEAP_FUNCTION(Heap::AllocateProxy(addr, pretenure), Proxy);
173 } 188 }
174 189
175 190
176 Handle<Proxy> Factory::NewProxy(const AccessorDescriptor* desc) { 191 Handle<Proxy> Factory::NewProxy(const AccessorDescriptor* desc) {
(...skipping 683 matching lines...) Expand 10 before | Expand all | Expand 10 after
860 Execution::ConfigureInstance(instance, 875 Execution::ConfigureInstance(instance,
861 instance_template, 876 instance_template,
862 pending_exception); 877 pending_exception);
863 } else { 878 } else {
864 *pending_exception = false; 879 *pending_exception = false;
865 } 880 }
866 } 881 }
867 882
868 883
869 } } // namespace v8::internal 884 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « no previous file | src/heap.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698