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

Side by Side Diff: src/compiler.cc

Issue 2866008: [Isolates] Move contents of Top into Isolate.... (Closed) Base URL: http://v8.googlecode.com/svn/branches/experimental/isolates/
Patch Set: ensure we're synced Created 10 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/codegen.cc ('k') | src/contexts.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 2010 the V8 project authors. All rights reserved. 1 // Copyright 2010 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 154 matching lines...) Expand 10 before | Expand all | Expand 10 after
165 bool is_eval, 165 bool is_eval,
166 Compiler::ValidationState validate, 166 Compiler::ValidationState validate,
167 Handle<Script> script, 167 Handle<Script> script,
168 Handle<Context> context, 168 Handle<Context> context,
169 v8::Extension* extension, 169 v8::Extension* extension,
170 ScriptDataImpl* pre_data) { 170 ScriptDataImpl* pre_data) {
171 CompilationZoneScope zone_scope(DELETE_ON_EXIT); 171 CompilationZoneScope zone_scope(DELETE_ON_EXIT);
172 172
173 PostponeInterruptsScope postpone; 173 PostponeInterruptsScope postpone;
174 174
175 ASSERT(!i::Top::global_context().is_null()); 175 ASSERT(!i::Isolate::Current()->global_context().is_null());
176 script->set_context_data((*i::Top::global_context())->data()); 176 script->set_context_data((*i::Isolate::Current()->global_context())->data());
177 177
178 bool is_json = (validate == Compiler::VALIDATE_JSON); 178 bool is_json = (validate == Compiler::VALIDATE_JSON);
179 #ifdef ENABLE_DEBUGGER_SUPPORT 179 #ifdef ENABLE_DEBUGGER_SUPPORT
180 if (is_eval || is_json) { 180 if (is_eval || is_json) {
181 script->set_compilation_type( 181 script->set_compilation_type(
182 is_json ? Smi::FromInt(Script::COMPILATION_TYPE_JSON) : 182 is_json ? Smi::FromInt(Script::COMPILATION_TYPE_JSON) :
183 Smi::FromInt(Script::COMPILATION_TYPE_EVAL)); 183 Smi::FromInt(Script::COMPILATION_TYPE_EVAL));
184 // For eval scripts add information on the function from which eval was 184 // For eval scripts add information on the function from which eval was
185 // called. 185 // called.
186 if (is_eval) { 186 if (is_eval) {
(...skipping 16 matching lines...) Expand all
203 ASSERT(is_eval || is_global); 203 ASSERT(is_eval || is_global);
204 204
205 // Build AST. 205 // Build AST.
206 FunctionLiteral* lit = 206 FunctionLiteral* lit =
207 MakeAST(is_global, script, extension, pre_data, is_json); 207 MakeAST(is_global, script, extension, pre_data, is_json);
208 208
209 LiveEditFunctionTracker live_edit_tracker(lit); 209 LiveEditFunctionTracker live_edit_tracker(lit);
210 210
211 // Check for parse errors. 211 // Check for parse errors.
212 if (lit == NULL) { 212 if (lit == NULL) {
213 ASSERT(Top::has_pending_exception()); 213 ASSERT(Isolate::Current()->has_pending_exception());
214 return Handle<SharedFunctionInfo>::null(); 214 return Handle<SharedFunctionInfo>::null();
215 } 215 }
216 216
217 // Measure how long it takes to do the compilation; only take the 217 // Measure how long it takes to do the compilation; only take the
218 // rest of the function into account to avoid overlap with the 218 // rest of the function into account to avoid overlap with the
219 // parsing statistics. 219 // parsing statistics.
220 HistogramTimer* rate = is_eval 220 HistogramTimer* rate = is_eval
221 ? &Counters::compile_eval 221 ? &Counters::compile_eval
222 : &Counters::compile; 222 : &Counters::compile;
223 HistogramTimerScope timer(rate); 223 HistogramTimerScope timer(rate);
224 224
225 // Compile the code. 225 // Compile the code.
226 CompilationInfo info(lit, script, is_eval); 226 CompilationInfo info(lit, script, is_eval);
227 Handle<Code> code = MakeCode(context, &info); 227 Handle<Code> code = MakeCode(context, &info);
228 228
229 // Check for stack-overflow exceptions. 229 // Check for stack-overflow exceptions.
230 if (code.is_null()) { 230 if (code.is_null()) {
231 Top::StackOverflow(); 231 Isolate::Current()->StackOverflow();
232 return Handle<SharedFunctionInfo>::null(); 232 return Handle<SharedFunctionInfo>::null();
233 } 233 }
234 234
235 if (script->name()->IsString()) { 235 if (script->name()->IsString()) {
236 PROFILE(CodeCreateEvent( 236 PROFILE(CodeCreateEvent(
237 is_eval ? Logger::EVAL_TAG : 237 is_eval ? Logger::EVAL_TAG :
238 Logger::ToNativeByScript(Logger::SCRIPT_TAG, *script), 238 Logger::ToNativeByScript(Logger::SCRIPT_TAG, *script),
239 *code, String::cast(script->name()))); 239 *code, String::cast(script->name())));
240 OPROFILE(CreateNativeCodeRegion(String::cast(script->name()), 240 OPROFILE(CreateNativeCodeRegion(String::cast(script->name()),
241 code->instruction_start(), 241 code->instruction_start(),
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
338 if (extension == NULL && !result.is_null()) { 338 if (extension == NULL && !result.is_null()) {
339 compilation_cache->PutScript(source, result); 339 compilation_cache->PutScript(source, result);
340 } 340 }
341 341
342 // Get rid of the pre-parsing data (if necessary). 342 // Get rid of the pre-parsing data (if necessary).
343 if (input_pre_data == NULL && pre_data != NULL) { 343 if (input_pre_data == NULL && pre_data != NULL) {
344 delete pre_data; 344 delete pre_data;
345 } 345 }
346 } 346 }
347 347
348 if (result.is_null()) Top::ReportPendingMessages(); 348 if (result.is_null()) Isolate::Current()->ReportPendingMessages();
349 return result; 349 return result;
350 } 350 }
351 351
352 352
353 Handle<SharedFunctionInfo> Compiler::CompileEval(Handle<String> source, 353 Handle<SharedFunctionInfo> Compiler::CompileEval(Handle<String> source,
354 Handle<Context> context, 354 Handle<Context> context,
355 bool is_global, 355 bool is_global,
356 ValidationState validate) { 356 ValidationState validate) {
357 // Note that if validation is required then no path through this 357 // Note that if validation is required then no path through this
358 // function is allowed to return a value without validating that 358 // function is allowed to return a value without validating that
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
416 // Generate the AST for the lazily compiled function. The AST may be 416 // Generate the AST for the lazily compiled function. The AST may be
417 // NULL in case of parser stack overflow. 417 // NULL in case of parser stack overflow.
418 FunctionLiteral* lit = MakeLazyAST(info->script(), 418 FunctionLiteral* lit = MakeLazyAST(info->script(),
419 name, 419 name,
420 start_position, 420 start_position,
421 end_position, 421 end_position,
422 is_expression); 422 is_expression);
423 423
424 // Check for parse errors. 424 // Check for parse errors.
425 if (lit == NULL) { 425 if (lit == NULL) {
426 ASSERT(Top::has_pending_exception()); 426 ASSERT(Isolate::Current()->has_pending_exception());
427 return false; 427 return false;
428 } 428 }
429 info->set_function(lit); 429 info->set_function(lit);
430 430
431 // Measure how long it takes to do the lazy compilation; only take 431 // Measure how long it takes to do the lazy compilation; only take
432 // the rest of the function into account to avoid overlap with the 432 // the rest of the function into account to avoid overlap with the
433 // lazy parsing statistics. 433 // lazy parsing statistics.
434 HistogramTimerScope timer(&Counters::compile_lazy); 434 HistogramTimerScope timer(&Counters::compile_lazy);
435 435
436 // Compile the code. 436 // Compile the code.
437 Handle<Code> code = MakeCode(Handle<Context>::null(), info); 437 Handle<Code> code = MakeCode(Handle<Context>::null(), info);
438 438
439 // Check for stack-overflow exception. 439 // Check for stack-overflow exception.
440 if (code.is_null()) { 440 if (code.is_null()) {
441 Top::StackOverflow(); 441 Isolate::Current()->StackOverflow();
442 return false; 442 return false;
443 } 443 }
444 444
445 RecordFunctionCompilation(Logger::LAZY_COMPILE_TAG, 445 RecordFunctionCompilation(Logger::LAZY_COMPILE_TAG,
446 name, 446 name,
447 Handle<String>(shared->inferred_name()), 447 Handle<String>(shared->inferred_name()),
448 start_position, 448 start_position,
449 info->script(), 449 info->script(),
450 code); 450 code);
451 451
(...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after
637 PROFILE(CodeCreateEvent(Logger::ToNativeByScript(tag, *script), 637 PROFILE(CodeCreateEvent(Logger::ToNativeByScript(tag, *script),
638 *code, *func_name)); 638 *code, *func_name));
639 OPROFILE(CreateNativeCodeRegion(*func_name, 639 OPROFILE(CreateNativeCodeRegion(*func_name,
640 code->instruction_start(), 640 code->instruction_start(),
641 code->instruction_size())); 641 code->instruction_size()));
642 } 642 }
643 } 643 }
644 } 644 }
645 645
646 } } // namespace v8::internal 646 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/codegen.cc ('k') | src/contexts.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698