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 239 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
250 // type feedback vector. | 250 // type feedback vector. |
251 CHECK(!feedback_vector_->SpecDiffersFrom(literal()->feedback_vector_spec())); | 251 CHECK(!feedback_vector_->SpecDiffersFrom(literal()->feedback_vector_spec())); |
252 } | 252 } |
253 | 253 |
254 | 254 |
255 bool CompilationInfo::has_simple_parameters() { | 255 bool CompilationInfo::has_simple_parameters() { |
256 return scope()->has_simple_parameters(); | 256 return scope()->has_simple_parameters(); |
257 } | 257 } |
258 | 258 |
259 | 259 |
260 bool CompilationInfo::MayUseThis() const { | |
261 return scope()->has_this_declaration() && scope()->receiver()->is_used(); | |
262 } | |
263 | |
264 | |
265 int CompilationInfo::TraceInlinedFunction(Handle<SharedFunctionInfo> shared, | 260 int CompilationInfo::TraceInlinedFunction(Handle<SharedFunctionInfo> shared, |
266 SourcePosition position, | 261 SourcePosition position, |
267 int parent_id) { | 262 int parent_id) { |
268 DCHECK(track_positions_); | 263 DCHECK(track_positions_); |
269 | 264 |
270 int inline_id = static_cast<int>(inlined_function_infos_.size()); | 265 int inline_id = static_cast<int>(inlined_function_infos_.size()); |
271 InlinedFunctionInfo info(parent_id, position, UnboundScript::kNoScriptId, | 266 InlinedFunctionInfo info(parent_id, position, UnboundScript::kNoScriptId, |
272 shared->start_position()); | 267 shared->start_position()); |
273 if (!shared->script()->IsUndefined()) { | 268 if (!shared->script()->IsUndefined()) { |
274 Handle<Script> script(Script::cast(shared->script())); | 269 Handle<Script> script(Script::cast(shared->script())); |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
321 base::SmartArrayPointer<char> name(new char[len]); | 316 base::SmartArrayPointer<char> name(new char[len]); |
322 memcpy(name.get(), code_stub_debug_name_, len); | 317 memcpy(name.get(), code_stub_debug_name_, len); |
323 return name; | 318 return name; |
324 } else { | 319 } else { |
325 AllowHandleDereference allow_deref; | 320 AllowHandleDereference allow_deref; |
326 return literal()->debug_name()->ToCString(); | 321 return literal()->debug_name()->ToCString(); |
327 } | 322 } |
328 } | 323 } |
329 | 324 |
330 | 325 |
| 326 bool CompilationInfo::MustReplaceUndefinedReceiverWithGlobalProxy() { |
| 327 return is_sloppy(language_mode()) && !is_native() && |
| 328 scope()->has_this_declaration() && scope()->receiver()->is_used(); |
| 329 } |
| 330 |
| 331 |
331 class HOptimizedGraphBuilderWithPositions: public HOptimizedGraphBuilder { | 332 class HOptimizedGraphBuilderWithPositions: public HOptimizedGraphBuilder { |
332 public: | 333 public: |
333 explicit HOptimizedGraphBuilderWithPositions(CompilationInfo* info) | 334 explicit HOptimizedGraphBuilderWithPositions(CompilationInfo* info) |
334 : HOptimizedGraphBuilder(info) { | 335 : HOptimizedGraphBuilder(info) { |
335 } | 336 } |
336 | 337 |
337 #define DEF_VISIT(type) \ | 338 #define DEF_VISIT(type) \ |
338 void Visit##type(type* node) override { \ | 339 void Visit##type(type* node) override { \ |
339 SourcePosition old_position = SourcePosition::Unknown(); \ | 340 SourcePosition old_position = SourcePosition::Unknown(); \ |
340 if (node->position() != RelocInfo::kNoPosition) { \ | 341 if (node->position() != RelocInfo::kNoPosition) { \ |
(...skipping 1402 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1743 // character is in the FLAG_trace_phase command line parameter. | 1744 // character is in the FLAG_trace_phase command line parameter. |
1744 AllowHandleDereference allow_deref; | 1745 AllowHandleDereference allow_deref; |
1745 bool tracing_on = info()->IsStub() | 1746 bool tracing_on = info()->IsStub() |
1746 ? FLAG_trace_hydrogen_stubs | 1747 ? FLAG_trace_hydrogen_stubs |
1747 : (FLAG_trace_hydrogen && | 1748 : (FLAG_trace_hydrogen && |
1748 info()->closure()->PassesFilter(FLAG_trace_hydrogen_filter)); | 1749 info()->closure()->PassesFilter(FLAG_trace_hydrogen_filter)); |
1749 return (tracing_on && | 1750 return (tracing_on && |
1750 base::OS::StrChr(const_cast<char*>(FLAG_trace_phase), name_[0]) != NULL); | 1751 base::OS::StrChr(const_cast<char*>(FLAG_trace_phase), name_[0]) != NULL); |
1751 } | 1752 } |
1752 | 1753 |
1753 | |
1754 #if DEBUG | 1754 #if DEBUG |
1755 void CompilationInfo::PrintAstForTesting() { | 1755 void CompilationInfo::PrintAstForTesting() { |
1756 PrintF("--- Source from AST ---\n%s\n", | 1756 PrintF("--- Source from AST ---\n%s\n", |
1757 PrettyPrinter(isolate(), zone()).PrintProgram(literal())); | 1757 PrettyPrinter(isolate(), zone()).PrintProgram(literal())); |
1758 } | 1758 } |
1759 #endif | 1759 #endif |
1760 } // namespace internal | 1760 } // namespace internal |
1761 } // namespace v8 | 1761 } // namespace v8 |
OLD | NEW |