OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "src/compiler.h" | 5 #include "src/compiler.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "src/ast-numbering.h" | 9 #include "src/ast-numbering.h" |
10 #include "src/bootstrapper.h" | 10 #include "src/bootstrapper.h" |
(...skipping 256 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
267 int CompilationInfo::TraceInlinedFunction(Handle<SharedFunctionInfo> shared, | 267 int CompilationInfo::TraceInlinedFunction(Handle<SharedFunctionInfo> shared, |
268 SourcePosition position, | 268 SourcePosition position, |
269 int parent_id) { | 269 int parent_id) { |
270 DCHECK(track_positions_); | 270 DCHECK(track_positions_); |
271 | 271 |
272 int inline_id = static_cast<int>(inlined_function_infos_.size()); | 272 int inline_id = static_cast<int>(inlined_function_infos_.size()); |
273 InlinedFunctionInfo info(parent_id, position, UnboundScript::kNoScriptId, | 273 InlinedFunctionInfo info(parent_id, position, UnboundScript::kNoScriptId, |
274 shared->start_position()); | 274 shared->start_position()); |
275 if (!shared->script()->IsUndefined()) { | 275 if (!shared->script()->IsUndefined()) { |
276 Handle<Script> script(Script::cast(shared->script())); | 276 Handle<Script> script(Script::cast(shared->script())); |
277 info.script_id = script->id()->value(); | 277 info.script_id = script->id(); |
278 | 278 |
279 if (FLAG_hydrogen_track_positions && !script->source()->IsUndefined()) { | 279 if (FLAG_hydrogen_track_positions && !script->source()->IsUndefined()) { |
280 CodeTracer::Scope tracing_scope(isolate()->GetCodeTracer()); | 280 CodeTracer::Scope tracing_scope(isolate()->GetCodeTracer()); |
281 OFStream os(tracing_scope.file()); | 281 OFStream os(tracing_scope.file()); |
282 os << "--- FUNCTION SOURCE (" << shared->DebugName()->ToCString().get() | 282 os << "--- FUNCTION SOURCE (" << shared->DebugName()->ToCString().get() |
283 << ") id{" << optimization_id() << "," << inline_id << "} ---\n"; | 283 << ") id{" << optimization_id() << "," << inline_id << "} ---\n"; |
284 { | 284 { |
285 DisallowHeapAllocation no_allocation; | 285 DisallowHeapAllocation no_allocation; |
286 int start = shared->start_position(); | 286 int start = shared->start_position(); |
287 int len = shared->end_position() - start; | 287 int len = shared->end_position() - start; |
(...skipping 982 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1270 MaybeHandle<SharedFunctionInfo> maybe_shared_info = | 1270 MaybeHandle<SharedFunctionInfo> maybe_shared_info = |
1271 compilation_cache->LookupEval(source, outer_info, context, language_mode, | 1271 compilation_cache->LookupEval(source, outer_info, context, language_mode, |
1272 line_offset); | 1272 line_offset); |
1273 Handle<SharedFunctionInfo> shared_info; | 1273 Handle<SharedFunctionInfo> shared_info; |
1274 | 1274 |
1275 Handle<Script> script; | 1275 Handle<Script> script; |
1276 if (!maybe_shared_info.ToHandle(&shared_info)) { | 1276 if (!maybe_shared_info.ToHandle(&shared_info)) { |
1277 script = isolate->factory()->NewScript(source); | 1277 script = isolate->factory()->NewScript(source); |
1278 if (!script_name.is_null()) { | 1278 if (!script_name.is_null()) { |
1279 script->set_name(*script_name); | 1279 script->set_name(*script_name); |
1280 script->set_line_offset(Smi::FromInt(line_offset)); | 1280 script->set_line_offset(line_offset); |
1281 script->set_column_offset(Smi::FromInt(column_offset)); | 1281 script->set_column_offset(column_offset); |
1282 } | 1282 } |
1283 script->set_origin_options(options); | 1283 script->set_origin_options(options); |
1284 Zone zone; | 1284 Zone zone; |
1285 ParseInfo parse_info(&zone, script); | 1285 ParseInfo parse_info(&zone, script); |
1286 CompilationInfo info(&parse_info); | 1286 CompilationInfo info(&parse_info); |
1287 parse_info.set_eval(); | 1287 parse_info.set_eval(); |
1288 if (context->IsNativeContext()) parse_info.set_global(); | 1288 if (context->IsNativeContext()) parse_info.set_global(); |
1289 parse_info.set_language_mode(language_mode); | 1289 parse_info.set_language_mode(language_mode); |
1290 parse_info.set_parse_restriction(restriction); | 1290 parse_info.set_parse_restriction(restriction); |
1291 parse_info.set_context(context); | 1291 parse_info.set_context(context); |
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1388 compile_options == ScriptCompiler::kProduceCodeCache) { | 1388 compile_options == ScriptCompiler::kProduceCodeCache) { |
1389 timer.Start(); | 1389 timer.Start(); |
1390 } | 1390 } |
1391 | 1391 |
1392 if (!maybe_result.ToHandle(&result)) { | 1392 if (!maybe_result.ToHandle(&result)) { |
1393 // No cache entry found. Compile the script. | 1393 // No cache entry found. Compile the script. |
1394 | 1394 |
1395 // Create a script object describing the script to be compiled. | 1395 // Create a script object describing the script to be compiled. |
1396 Handle<Script> script = isolate->factory()->NewScript(source); | 1396 Handle<Script> script = isolate->factory()->NewScript(source); |
1397 if (natives == NATIVES_CODE) { | 1397 if (natives == NATIVES_CODE) { |
1398 script->set_type(Smi::FromInt(Script::TYPE_NATIVE)); | 1398 script->set_type(Script::TYPE_NATIVE); |
1399 script->set_hide_source(true); | 1399 script->set_hide_source(true); |
1400 } | 1400 } |
1401 if (!script_name.is_null()) { | 1401 if (!script_name.is_null()) { |
1402 script->set_name(*script_name); | 1402 script->set_name(*script_name); |
1403 script->set_line_offset(Smi::FromInt(line_offset)); | 1403 script->set_line_offset(line_offset); |
1404 script->set_column_offset(Smi::FromInt(column_offset)); | 1404 script->set_column_offset(column_offset); |
1405 } | 1405 } |
1406 script->set_origin_options(resource_options); | 1406 script->set_origin_options(resource_options); |
1407 if (!source_map_url.is_null()) { | 1407 if (!source_map_url.is_null()) { |
1408 script->set_source_mapping_url(*source_map_url); | 1408 script->set_source_mapping_url(*source_map_url); |
1409 } | 1409 } |
1410 | 1410 |
1411 // Compile the function and add it to the cache. | 1411 // Compile the function and add it to the cache. |
1412 Zone zone; | 1412 Zone zone; |
1413 ParseInfo parse_info(&zone, script); | 1413 ParseInfo parse_info(&zone, script); |
1414 CompilationInfo info(&parse_info); | 1414 CompilationInfo info(&parse_info); |
(...skipping 346 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1761 } | 1761 } |
1762 | 1762 |
1763 #if DEBUG | 1763 #if DEBUG |
1764 void CompilationInfo::PrintAstForTesting() { | 1764 void CompilationInfo::PrintAstForTesting() { |
1765 PrintF("--- Source from AST ---\n%s\n", | 1765 PrintF("--- Source from AST ---\n%s\n", |
1766 PrettyPrinter(isolate(), zone()).PrintProgram(literal())); | 1766 PrettyPrinter(isolate(), zone()).PrintProgram(literal())); |
1767 } | 1767 } |
1768 #endif | 1768 #endif |
1769 } // namespace internal | 1769 } // namespace internal |
1770 } // namespace v8 | 1770 } // namespace v8 |
OLD | NEW |