| 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/v8.h" | 5 #include "src/v8.h" |
| 6 | 6 |
| 7 #include "src/compiler.h" | 7 #include "src/compiler.h" |
| 8 | 8 |
| 9 #include "src/bootstrapper.h" | 9 #include "src/bootstrapper.h" |
| 10 #include "src/codegen.h" | 10 #include "src/codegen.h" |
| (...skipping 1066 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1077 live_edit_tracker.RecordFunctionInfo(result, lit, info->zone()); | 1077 live_edit_tracker.RecordFunctionInfo(result, lit, info->zone()); |
| 1078 } | 1078 } |
| 1079 | 1079 |
| 1080 isolate->debug()->OnAfterCompile(script); | 1080 isolate->debug()->OnAfterCompile(script); |
| 1081 | 1081 |
| 1082 return result; | 1082 return result; |
| 1083 } | 1083 } |
| 1084 | 1084 |
| 1085 | 1085 |
| 1086 MaybeHandle<JSFunction> Compiler::GetFunctionFromEval( | 1086 MaybeHandle<JSFunction> Compiler::GetFunctionFromEval( |
| 1087 Handle<String> source, | 1087 Handle<String> source, Handle<SharedFunctionInfo> outer_info, |
| 1088 Handle<Context> context, | 1088 Handle<Context> context, StrictMode strict_mode, |
| 1089 StrictMode strict_mode, | 1089 ParseRestriction restriction, int scope_position) { |
| 1090 ParseRestriction restriction, | |
| 1091 int scope_position) { | |
| 1092 Isolate* isolate = source->GetIsolate(); | 1090 Isolate* isolate = source->GetIsolate(); |
| 1093 int source_length = source->length(); | 1091 int source_length = source->length(); |
| 1094 isolate->counters()->total_eval_size()->Increment(source_length); | 1092 isolate->counters()->total_eval_size()->Increment(source_length); |
| 1095 isolate->counters()->total_compile_size()->Increment(source_length); | 1093 isolate->counters()->total_compile_size()->Increment(source_length); |
| 1096 | 1094 |
| 1097 CompilationCache* compilation_cache = isolate->compilation_cache(); | 1095 CompilationCache* compilation_cache = isolate->compilation_cache(); |
| 1098 MaybeHandle<SharedFunctionInfo> maybe_shared_info = | 1096 MaybeHandle<SharedFunctionInfo> maybe_shared_info = |
| 1099 compilation_cache->LookupEval(source, context, strict_mode, | 1097 compilation_cache->LookupEval(source, outer_info, context, strict_mode, |
| 1100 scope_position); | 1098 scope_position); |
| 1101 Handle<SharedFunctionInfo> shared_info; | 1099 Handle<SharedFunctionInfo> shared_info; |
| 1102 | 1100 |
| 1103 if (!maybe_shared_info.ToHandle(&shared_info)) { | 1101 if (!maybe_shared_info.ToHandle(&shared_info)) { |
| 1104 Handle<Script> script = isolate->factory()->NewScript(source); | 1102 Handle<Script> script = isolate->factory()->NewScript(source); |
| 1105 CompilationInfoWithZone info(script); | 1103 CompilationInfoWithZone info(script); |
| 1106 info.MarkAsEval(); | 1104 info.MarkAsEval(); |
| 1107 if (context->IsNativeContext()) info.MarkAsGlobal(); | 1105 if (context->IsNativeContext()) info.MarkAsGlobal(); |
| 1108 info.SetStrictMode(strict_mode); | 1106 info.SetStrictMode(strict_mode); |
| 1109 info.SetParseRestriction(restriction); | 1107 info.SetParseRestriction(restriction); |
| 1110 info.SetContext(context); | 1108 info.SetContext(context); |
| 1111 | 1109 |
| 1112 Debug::RecordEvalCaller(script); | 1110 Debug::RecordEvalCaller(script); |
| 1113 | 1111 |
| 1114 shared_info = CompileToplevel(&info); | 1112 shared_info = CompileToplevel(&info); |
| 1115 | 1113 |
| 1116 if (shared_info.is_null()) { | 1114 if (shared_info.is_null()) { |
| 1117 return MaybeHandle<JSFunction>(); | 1115 return MaybeHandle<JSFunction>(); |
| 1118 } else { | 1116 } else { |
| 1119 // Explicitly disable optimization for eval code. We're not yet prepared | 1117 // Explicitly disable optimization for eval code. We're not yet prepared |
| 1120 // to handle eval-code in the optimizing compiler. | 1118 // to handle eval-code in the optimizing compiler. |
| 1121 shared_info->DisableOptimization(kEval); | 1119 shared_info->DisableOptimization(kEval); |
| 1122 | 1120 |
| 1123 // If caller is strict mode, the result must be in strict mode as well. | 1121 // If caller is strict mode, the result must be in strict mode as well. |
| 1124 DCHECK(strict_mode == SLOPPY || shared_info->strict_mode() == STRICT); | 1122 DCHECK(strict_mode == SLOPPY || shared_info->strict_mode() == STRICT); |
| 1125 if (!shared_info->dont_cache()) { | 1123 if (!shared_info->dont_cache()) { |
| 1126 compilation_cache->PutEval( | 1124 compilation_cache->PutEval(source, outer_info, context, shared_info, |
| 1127 source, context, shared_info, scope_position); | 1125 scope_position); |
| 1128 } | 1126 } |
| 1129 } | 1127 } |
| 1130 } else if (shared_info->ic_age() != isolate->heap()->global_ic_age()) { | 1128 } else if (shared_info->ic_age() != isolate->heap()->global_ic_age()) { |
| 1131 shared_info->ResetForNewContext(isolate->heap()->global_ic_age()); | 1129 shared_info->ResetForNewContext(isolate->heap()->global_ic_age()); |
| 1132 } | 1130 } |
| 1133 | 1131 |
| 1134 return isolate->factory()->NewFunctionFromSharedFunctionInfo( | 1132 return isolate->factory()->NewFunctionFromSharedFunctionInfo( |
| 1135 shared_info, context, NOT_TENURED); | 1133 shared_info, context, NOT_TENURED); |
| 1136 } | 1134 } |
| 1137 | 1135 |
| (...skipping 292 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1430 AllowHandleDereference allow_deref; | 1428 AllowHandleDereference allow_deref; |
| 1431 bool tracing_on = info()->IsStub() | 1429 bool tracing_on = info()->IsStub() |
| 1432 ? FLAG_trace_hydrogen_stubs | 1430 ? FLAG_trace_hydrogen_stubs |
| 1433 : (FLAG_trace_hydrogen && | 1431 : (FLAG_trace_hydrogen && |
| 1434 info()->closure()->PassesFilter(FLAG_trace_hydrogen_filter)); | 1432 info()->closure()->PassesFilter(FLAG_trace_hydrogen_filter)); |
| 1435 return (tracing_on && | 1433 return (tracing_on && |
| 1436 base::OS::StrChr(const_cast<char*>(FLAG_trace_phase), name_[0]) != NULL); | 1434 base::OS::StrChr(const_cast<char*>(FLAG_trace_phase), name_[0]) != NULL); |
| 1437 } | 1435 } |
| 1438 | 1436 |
| 1439 } } // namespace v8::internal | 1437 } } // namespace v8::internal |
| OLD | NEW |