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 1865 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1876 case NAMED_PROPERTY: | 1876 case NAMED_PROPERTY: |
1877 EmitNamedPropertyAssignment(expr); | 1877 EmitNamedPropertyAssignment(expr); |
1878 break; | 1878 break; |
1879 case KEYED_PROPERTY: | 1879 case KEYED_PROPERTY: |
1880 EmitKeyedPropertyAssignment(expr); | 1880 EmitKeyedPropertyAssignment(expr); |
1881 break; | 1881 break; |
1882 } | 1882 } |
1883 } | 1883 } |
1884 | 1884 |
1885 | 1885 |
| 1886 void FullCodeGenerator::VisitYield(Yield* expr) { |
| 1887 Comment cmnt(masm_, "[ Yield"); |
| 1888 // Evaluate yielded value first; the initial iterator definition depends on |
| 1889 // this. It stays on the stack while we update the iterator. |
| 1890 VisitForStackValue(expr->expression()); |
| 1891 |
| 1892 switch (expr->yield_kind()) { |
| 1893 case Yield::INITIAL: |
| 1894 case Yield::SUSPEND: { |
| 1895 VisitForStackValue(expr->generator_object()); |
| 1896 __ CallRuntime(Runtime::kSuspendJSGeneratorObject, 1); |
| 1897 __ mov(context_register(), |
| 1898 Operand(ebp, StandardFrameConstants::kContextOffset)); |
| 1899 |
| 1900 Label resume; |
| 1901 __ CompareRoot(result_register(), Heap::kTheHoleValueRootIndex); |
| 1902 __ j(not_equal, &resume); |
| 1903 __ pop(result_register()); |
| 1904 if (expr->yield_kind() == Yield::SUSPEND) { |
| 1905 // TODO(wingo): Box into { value: VALUE, done: false }. |
| 1906 } |
| 1907 EmitReturnSequence(); |
| 1908 |
| 1909 __ bind(&resume); |
| 1910 context()->Plug(result_register()); |
| 1911 break; |
| 1912 } |
| 1913 |
| 1914 case Yield::FINAL: { |
| 1915 VisitForAccumulatorValue(expr->generator_object()); |
| 1916 __ mov(FieldOperand(result_register(), |
| 1917 JSGeneratorObject::kContinuationOffset), |
| 1918 Immediate(Smi::FromInt(JSGeneratorObject::kGeneratorClosed))); |
| 1919 __ pop(result_register()); |
| 1920 // TODO(wingo): Box into { value: VALUE, done: true }. |
| 1921 |
| 1922 // Exit all nested statements. |
| 1923 NestedStatement* current = nesting_stack_; |
| 1924 int stack_depth = 0; |
| 1925 int context_length = 0; |
| 1926 while (current != NULL) { |
| 1927 current = current->Exit(&stack_depth, &context_length); |
| 1928 } |
| 1929 __ Drop(stack_depth); |
| 1930 EmitReturnSequence(); |
| 1931 break; |
| 1932 } |
| 1933 |
| 1934 case Yield::DELEGATING: |
| 1935 UNIMPLEMENTED(); |
| 1936 } |
| 1937 } |
| 1938 |
| 1939 |
1886 void FullCodeGenerator::EmitNamedPropertyLoad(Property* prop) { | 1940 void FullCodeGenerator::EmitNamedPropertyLoad(Property* prop) { |
1887 SetSourcePosition(prop->position()); | 1941 SetSourcePosition(prop->position()); |
1888 Literal* key = prop->key()->AsLiteral(); | 1942 Literal* key = prop->key()->AsLiteral(); |
1889 ASSERT(!key->handle()->IsSmi()); | 1943 ASSERT(!key->handle()->IsSmi()); |
1890 __ mov(ecx, Immediate(key->handle())); | 1944 __ mov(ecx, Immediate(key->handle())); |
1891 Handle<Code> ic = isolate()->builtins()->LoadIC_Initialize(); | 1945 Handle<Code> ic = isolate()->builtins()->LoadIC_Initialize(); |
1892 CallIC(ic, RelocInfo::CODE_TARGET, prop->PropertyFeedbackId()); | 1946 CallIC(ic, RelocInfo::CODE_TARGET, prop->PropertyFeedbackId()); |
1893 } | 1947 } |
1894 | 1948 |
1895 | 1949 |
(...skipping 2662 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4558 *stack_depth = 0; | 4612 *stack_depth = 0; |
4559 *context_length = 0; | 4613 *context_length = 0; |
4560 return previous_; | 4614 return previous_; |
4561 } | 4615 } |
4562 | 4616 |
4563 #undef __ | 4617 #undef __ |
4564 | 4618 |
4565 } } // namespace v8::internal | 4619 } } // namespace v8::internal |
4566 | 4620 |
4567 #endif // V8_TARGET_ARCH_IA32 | 4621 #endif // V8_TARGET_ARCH_IA32 |
OLD | NEW |