| OLD | NEW |
| 1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 49 #include "scopeinfo.h" | 49 #include "scopeinfo.h" |
| 50 #include "scopes.h" | 50 #include "scopes.h" |
| 51 #include "vm-state-inl.h" | 51 #include "vm-state-inl.h" |
| 52 | 52 |
| 53 namespace v8 { | 53 namespace v8 { |
| 54 namespace internal { | 54 namespace internal { |
| 55 | 55 |
| 56 | 56 |
| 57 CompilationInfo::CompilationInfo(Handle<Script> script, | 57 CompilationInfo::CompilationInfo(Handle<Script> script, |
| 58 Zone* zone) | 58 Zone* zone) |
| 59 : flags_(LanguageModeField::encode(CLASSIC_MODE)), | 59 : flags_(LanguageModeField::encode(SLOPPY_MODE)), |
| 60 script_(script), | 60 script_(script), |
| 61 osr_ast_id_(BailoutId::None()), | 61 osr_ast_id_(BailoutId::None()), |
| 62 parameter_count_(0), | 62 parameter_count_(0), |
| 63 this_has_uses_(true), | 63 this_has_uses_(true), |
| 64 optimization_id_(-1) { | 64 optimization_id_(-1) { |
| 65 Initialize(script->GetIsolate(), BASE, zone); | 65 Initialize(script->GetIsolate(), BASE, zone); |
| 66 } | 66 } |
| 67 | 67 |
| 68 | 68 |
| 69 CompilationInfo::CompilationInfo(Handle<SharedFunctionInfo> shared_info, | 69 CompilationInfo::CompilationInfo(Handle<SharedFunctionInfo> shared_info, |
| 70 Zone* zone) | 70 Zone* zone) |
| 71 : flags_(LanguageModeField::encode(CLASSIC_MODE) | IsLazy::encode(true)), | 71 : flags_(LanguageModeField::encode(SLOPPY_MODE) | IsLazy::encode(true)), |
| 72 shared_info_(shared_info), | 72 shared_info_(shared_info), |
| 73 script_(Handle<Script>(Script::cast(shared_info->script()))), | 73 script_(Handle<Script>(Script::cast(shared_info->script()))), |
| 74 osr_ast_id_(BailoutId::None()), | 74 osr_ast_id_(BailoutId::None()), |
| 75 parameter_count_(0), | 75 parameter_count_(0), |
| 76 this_has_uses_(true), | 76 this_has_uses_(true), |
| 77 optimization_id_(-1) { | 77 optimization_id_(-1) { |
| 78 Initialize(script_->GetIsolate(), BASE, zone); | 78 Initialize(script_->GetIsolate(), BASE, zone); |
| 79 } | 79 } |
| 80 | 80 |
| 81 | 81 |
| 82 CompilationInfo::CompilationInfo(Handle<JSFunction> closure, | 82 CompilationInfo::CompilationInfo(Handle<JSFunction> closure, |
| 83 Zone* zone) | 83 Zone* zone) |
| 84 : flags_(LanguageModeField::encode(CLASSIC_MODE) | IsLazy::encode(true)), | 84 : flags_(LanguageModeField::encode(SLOPPY_MODE) | IsLazy::encode(true)), |
| 85 closure_(closure), | 85 closure_(closure), |
| 86 shared_info_(Handle<SharedFunctionInfo>(closure->shared())), | 86 shared_info_(Handle<SharedFunctionInfo>(closure->shared())), |
| 87 script_(Handle<Script>(Script::cast(shared_info_->script()))), | 87 script_(Handle<Script>(Script::cast(shared_info_->script()))), |
| 88 context_(closure->context()), | 88 context_(closure->context()), |
| 89 osr_ast_id_(BailoutId::None()), | 89 osr_ast_id_(BailoutId::None()), |
| 90 parameter_count_(0), | 90 parameter_count_(0), |
| 91 this_has_uses_(true), | 91 this_has_uses_(true), |
| 92 optimization_id_(-1) { | 92 optimization_id_(-1) { |
| 93 Initialize(script_->GetIsolate(), BASE, zone); | 93 Initialize(script_->GetIsolate(), BASE, zone); |
| 94 } | 94 } |
| 95 | 95 |
| 96 | 96 |
| 97 CompilationInfo::CompilationInfo(HydrogenCodeStub* stub, | 97 CompilationInfo::CompilationInfo(HydrogenCodeStub* stub, |
| 98 Isolate* isolate, | 98 Isolate* isolate, |
| 99 Zone* zone) | 99 Zone* zone) |
| 100 : flags_(LanguageModeField::encode(CLASSIC_MODE) | | 100 : flags_(LanguageModeField::encode(SLOPPY_MODE) | |
| 101 IsLazy::encode(true)), | 101 IsLazy::encode(true)), |
| 102 osr_ast_id_(BailoutId::None()), | 102 osr_ast_id_(BailoutId::None()), |
| 103 parameter_count_(0), | 103 parameter_count_(0), |
| 104 this_has_uses_(true), | 104 this_has_uses_(true), |
| 105 optimization_id_(-1) { | 105 optimization_id_(-1) { |
| 106 Initialize(isolate, STUB, zone); | 106 Initialize(isolate, STUB, zone); |
| 107 code_stub_ = stub; | 107 code_stub_ = stub; |
| 108 } | 108 } |
| 109 | 109 |
| 110 | 110 |
| (...skipping 19 matching lines...) Expand all Loading... |
| 130 if (mode == STUB) { | 130 if (mode == STUB) { |
| 131 mode_ = STUB; | 131 mode_ = STUB; |
| 132 return; | 132 return; |
| 133 } | 133 } |
| 134 mode_ = mode; | 134 mode_ = mode; |
| 135 abort_due_to_dependency_ = false; | 135 abort_due_to_dependency_ = false; |
| 136 if (script_->type()->value() == Script::TYPE_NATIVE) { | 136 if (script_->type()->value() == Script::TYPE_NATIVE) { |
| 137 MarkAsNative(); | 137 MarkAsNative(); |
| 138 } | 138 } |
| 139 if (!shared_info_.is_null()) { | 139 if (!shared_info_.is_null()) { |
| 140 ASSERT(language_mode() == CLASSIC_MODE); | 140 ASSERT(language_mode() == SLOPPY_MODE); |
| 141 SetLanguageMode(shared_info_->language_mode()); | 141 SetLanguageMode(shared_info_->language_mode()); |
| 142 } | 142 } |
| 143 set_bailout_reason(kUnknown); | 143 set_bailout_reason(kUnknown); |
| 144 } | 144 } |
| 145 | 145 |
| 146 | 146 |
| 147 CompilationInfo::~CompilationInfo() { | 147 CompilationInfo::~CompilationInfo() { |
| 148 delete deferred_handles_; | 148 delete deferred_handles_; |
| 149 delete no_frame_ranges_; | 149 delete no_frame_ranges_; |
| 150 #ifdef DEBUG | 150 #ifdef DEBUG |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 221 } | 221 } |
| 222 } | 222 } |
| 223 | 223 |
| 224 | 224 |
| 225 // Disable optimization for the rest of the compilation pipeline. | 225 // Disable optimization for the rest of the compilation pipeline. |
| 226 void CompilationInfo::DisableOptimization() { | 226 void CompilationInfo::DisableOptimization() { |
| 227 bool is_optimizable_closure = | 227 bool is_optimizable_closure = |
| 228 FLAG_optimize_closures && | 228 FLAG_optimize_closures && |
| 229 closure_.is_null() && | 229 closure_.is_null() && |
| 230 !scope_->HasTrivialOuterContext() && | 230 !scope_->HasTrivialOuterContext() && |
| 231 !scope_->outer_scope_calls_non_strict_eval() && | 231 !scope_->outer_scope_calls_sloppy_eval() && |
| 232 !scope_->inside_with(); | 232 !scope_->inside_with(); |
| 233 SetMode(is_optimizable_closure ? BASE : NONOPT); | 233 SetMode(is_optimizable_closure ? BASE : NONOPT); |
| 234 } | 234 } |
| 235 | 235 |
| 236 | 236 |
| 237 // Primitive functions are unlikely to be picked up by the stack-walking | 237 // Primitive functions are unlikely to be picked up by the stack-walking |
| 238 // profiler, so they trigger their own optimization when they're called | 238 // profiler, so they trigger their own optimization when they're called |
| 239 // for the SharedFunctionInfo::kCallsUntilPrimitiveOptimization-th time. | 239 // for the SharedFunctionInfo::kCallsUntilPrimitiveOptimization-th time. |
| 240 bool CompilationInfo::ShouldSelfOptimize() { | 240 bool CompilationInfo::ShouldSelfOptimize() { |
| 241 return FLAG_crankshaft && | 241 return FLAG_crankshaft && |
| (...skipping 644 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 886 if (shared_info.is_null()) { | 886 if (shared_info.is_null()) { |
| 887 return Handle<JSFunction>::null(); | 887 return Handle<JSFunction>::null(); |
| 888 } else { | 888 } else { |
| 889 // Explicitly disable optimization for eval code. We're not yet prepared | 889 // Explicitly disable optimization for eval code. We're not yet prepared |
| 890 // to handle eval-code in the optimizing compiler. | 890 // to handle eval-code in the optimizing compiler. |
| 891 shared_info->DisableOptimization(kEval); | 891 shared_info->DisableOptimization(kEval); |
| 892 | 892 |
| 893 // If caller is strict mode, the result must be in strict mode or | 893 // If caller is strict mode, the result must be in strict mode or |
| 894 // extended mode as well, but not the other way around. Consider: | 894 // extended mode as well, but not the other way around. Consider: |
| 895 // eval("'use strict'; ..."); | 895 // eval("'use strict'; ..."); |
| 896 ASSERT(language_mode != STRICT_MODE || !shared_info->is_classic_mode()); | 896 ASSERT(language_mode != STRICT_MODE || !shared_info->is_sloppy_mode()); |
| 897 // If caller is in extended mode, the result must also be in | 897 // If caller is in extended mode, the result must also be in |
| 898 // extended mode. | 898 // extended mode. |
| 899 ASSERT(language_mode != EXTENDED_MODE || | 899 ASSERT(language_mode != EXTENDED_MODE || |
| 900 shared_info->is_extended_mode()); | 900 shared_info->is_extended_mode()); |
| 901 if (!shared_info->dont_cache()) { | 901 if (!shared_info->dont_cache()) { |
| 902 compilation_cache->PutEval( | 902 compilation_cache->PutEval( |
| 903 source, context, shared_info, scope_position); | 903 source, context, shared_info, scope_position); |
| 904 } | 904 } |
| 905 } | 905 } |
| 906 } else if (shared_info->ic_age() != isolate->heap()->global_ic_age()) { | 906 } else if (shared_info->ic_age() != isolate->heap()->global_ic_age()) { |
| (...skipping 394 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1301 AllowHandleDereference allow_deref; | 1301 AllowHandleDereference allow_deref; |
| 1302 bool tracing_on = info()->IsStub() | 1302 bool tracing_on = info()->IsStub() |
| 1303 ? FLAG_trace_hydrogen_stubs | 1303 ? FLAG_trace_hydrogen_stubs |
| 1304 : (FLAG_trace_hydrogen && | 1304 : (FLAG_trace_hydrogen && |
| 1305 info()->closure()->PassesFilter(FLAG_trace_hydrogen_filter)); | 1305 info()->closure()->PassesFilter(FLAG_trace_hydrogen_filter)); |
| 1306 return (tracing_on && | 1306 return (tracing_on && |
| 1307 OS::StrChr(const_cast<char*>(FLAG_trace_phase), name_[0]) != NULL); | 1307 OS::StrChr(const_cast<char*>(FLAG_trace_phase), name_[0]) != NULL); |
| 1308 } | 1308 } |
| 1309 | 1309 |
| 1310 } } // namespace v8::internal | 1310 } } // namespace v8::internal |
| OLD | NEW |