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/full-codegen/full-codegen.h" | 5 #include "src/full-codegen/full-codegen.h" |
6 | 6 |
| 7 #include "src/ast/ast-numbering.h" |
7 #include "src/ast/ast.h" | 8 #include "src/ast/ast.h" |
8 #include "src/ast/ast-numbering.h" | |
9 #include "src/ast/prettyprinter.h" | 9 #include "src/ast/prettyprinter.h" |
10 #include "src/ast/scopeinfo.h" | 10 #include "src/ast/scopeinfo.h" |
11 #include "src/ast/scopes.h" | 11 #include "src/ast/scopes.h" |
12 #include "src/code-factory.h" | 12 #include "src/code-factory.h" |
13 #include "src/codegen.h" | 13 #include "src/codegen.h" |
14 #include "src/compiler.h" | 14 #include "src/compiler.h" |
15 #include "src/debug/debug.h" | 15 #include "src/debug/debug.h" |
16 #include "src/debug/liveedit.h" | 16 #include "src/debug/liveedit.h" |
| 17 #include "src/frames-inl.h" |
17 #include "src/isolate-inl.h" | 18 #include "src/isolate-inl.h" |
18 #include "src/macro-assembler.h" | 19 #include "src/macro-assembler.h" |
19 #include "src/snapshot/snapshot.h" | 20 #include "src/snapshot/snapshot.h" |
20 #include "src/tracing/trace-event.h" | 21 #include "src/tracing/trace-event.h" |
21 | 22 |
22 namespace v8 { | 23 namespace v8 { |
23 namespace internal { | 24 namespace internal { |
24 | 25 |
25 #define __ ACCESS_MASM(masm()) | 26 #define __ ACCESS_MASM(masm()) |
26 | 27 |
(...skipping 525 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
552 VisitForAccumulatorValue(args->at(last)); | 553 VisitForAccumulatorValue(args->at(last)); |
553 | 554 |
554 // Move the arguments to the registers, as required by the stub. | 555 // Move the arguments to the registers, as required by the stub. |
555 __ Move(callable.descriptor().GetRegisterParameter(last), | 556 __ Move(callable.descriptor().GetRegisterParameter(last), |
556 result_register()); | 557 result_register()); |
557 for (int i = last; i-- > 0;) { | 558 for (int i = last; i-- > 0;) { |
558 PopOperand(callable.descriptor().GetRegisterParameter(i)); | 559 PopOperand(callable.descriptor().GetRegisterParameter(i)); |
559 } | 560 } |
560 } | 561 } |
561 __ Call(callable.code(), RelocInfo::CODE_TARGET); | 562 __ Call(callable.code(), RelocInfo::CODE_TARGET); |
| 563 |
| 564 // Reload the context register after the call as i.e. TurboFan code stubs |
| 565 // won't preserve the context register. |
| 566 LoadFromFrameField(StandardFrameConstants::kContextOffset, |
| 567 context_register()); |
562 context()->Plug(result_register()); | 568 context()->Plug(result_register()); |
563 } | 569 } |
564 | 570 |
565 | 571 |
566 void FullCodeGenerator::EmitNumberToString(CallRuntime* expr) { | 572 void FullCodeGenerator::EmitNumberToString(CallRuntime* expr) { |
567 EmitIntrinsicAsStubCall(expr, CodeFactory::NumberToString(isolate())); | 573 EmitIntrinsicAsStubCall(expr, CodeFactory::NumberToString(isolate())); |
568 } | 574 } |
569 | 575 |
570 | 576 |
571 void FullCodeGenerator::EmitToString(CallRuntime* expr) { | 577 void FullCodeGenerator::EmitToString(CallRuntime* expr) { |
(...skipping 690 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1262 PrepareForBailoutForId(stmt->BackEdgeId(), NO_REGISTERS); | 1268 PrepareForBailoutForId(stmt->BackEdgeId(), NO_REGISTERS); |
1263 EmitBackEdgeBookkeeping(stmt, loop_statement.continue_label()); | 1269 EmitBackEdgeBookkeeping(stmt, loop_statement.continue_label()); |
1264 __ jmp(loop_statement.continue_label()); | 1270 __ jmp(loop_statement.continue_label()); |
1265 | 1271 |
1266 // Exit and decrement the loop depth. | 1272 // Exit and decrement the loop depth. |
1267 PrepareForBailoutForId(stmt->ExitId(), NO_REGISTERS); | 1273 PrepareForBailoutForId(stmt->ExitId(), NO_REGISTERS); |
1268 __ bind(loop_statement.break_label()); | 1274 __ bind(loop_statement.break_label()); |
1269 decrement_loop_depth(); | 1275 decrement_loop_depth(); |
1270 } | 1276 } |
1271 | 1277 |
| 1278 void FullCodeGenerator::VisitThisFunction(ThisFunction* expr) { |
| 1279 LoadFromFrameField(JavaScriptFrameConstants::kFunctionOffset, |
| 1280 result_register()); |
| 1281 context()->Plug(result_register()); |
| 1282 } |
1272 | 1283 |
1273 void FullCodeGenerator::VisitTryCatchStatement(TryCatchStatement* stmt) { | 1284 void FullCodeGenerator::VisitTryCatchStatement(TryCatchStatement* stmt) { |
1274 Comment cmnt(masm_, "[ TryCatchStatement"); | 1285 Comment cmnt(masm_, "[ TryCatchStatement"); |
1275 SetStatementPosition(stmt, SKIP_BREAK); | 1286 SetStatementPosition(stmt, SKIP_BREAK); |
1276 | 1287 |
1277 // The try block adds a handler to the exception handler chain before | 1288 // The try block adds a handler to the exception handler chain before |
1278 // entering, and removes it again when exiting normally. If an exception | 1289 // entering, and removes it again when exiting normally. If an exception |
1279 // is thrown during execution of the try block, the handler is consumed | 1290 // is thrown during execution of the try block, the handler is consumed |
1280 // and control is passed to the catch block with the exception in the | 1291 // and control is passed to the catch block with the exception in the |
1281 // result register. | 1292 // result register. |
(...skipping 656 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1938 return var->mode() == CONST_LEGACY || var->scope()->is_nonlinear() || | 1949 return var->mode() == CONST_LEGACY || var->scope()->is_nonlinear() || |
1939 var->initializer_position() >= proxy->position(); | 1950 var->initializer_position() >= proxy->position(); |
1940 } | 1951 } |
1941 | 1952 |
1942 | 1953 |
1943 #undef __ | 1954 #undef __ |
1944 | 1955 |
1945 | 1956 |
1946 } // namespace internal | 1957 } // namespace internal |
1947 } // namespace v8 | 1958 } // namespace v8 |
OLD | NEW |