Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(367)

Side by Side Diff: src/arm/full-codegen-arm.cc

Issue 917753002: new classes: implement default constructors. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Rebase to run try jobs Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | src/arm64/full-codegen-arm64.cc » ('j') | src/x64/code-stubs-x64.cc » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 #if V8_TARGET_ARCH_ARM 7 #if V8_TARGET_ARCH_ARM
8 8
9 #include "src/code-factory.h" 9 #include "src/code-factory.h"
10 #include "src/code-stubs.h" 10 #include "src/code-stubs.h"
(...skipping 3048 matching lines...) Expand 10 before | Expand all | Expand 10 after
3059 // r1: the start position of the scope the calls resides in. 3059 // r1: the start position of the scope the calls resides in.
3060 __ mov(r1, Operand(Smi::FromInt(scope()->start_position()))); 3060 __ mov(r1, Operand(Smi::FromInt(scope()->start_position())));
3061 3061
3062 // Do the runtime call. 3062 // Do the runtime call.
3063 __ Push(r5); 3063 __ Push(r5);
3064 __ Push(r4, r3, r2, r1); 3064 __ Push(r4, r3, r2, r1);
3065 __ CallRuntime(Runtime::kResolvePossiblyDirectEval, 6); 3065 __ CallRuntime(Runtime::kResolvePossiblyDirectEval, 6);
3066 } 3066 }
3067 3067
3068 3068
3069 void FullCodeGenerator::EmitLoadSuperConstructor(SuperReference* super_ref) { 3069 void FullCodeGenerator::EmitLoadSuperConstructor() {
3070 DCHECK(super_ref != NULL);
3071 __ ldr(r0, MemOperand(fp, JavaScriptFrameConstants::kFunctionOffset)); 3070 __ ldr(r0, MemOperand(fp, JavaScriptFrameConstants::kFunctionOffset));
3072 __ Push(r0); 3071 __ Push(r0);
3073 __ CallRuntime(Runtime::kGetPrototype, 1); 3072 __ CallRuntime(Runtime::kGetPrototype, 1);
3074 } 3073 }
3075 3074
3076 3075
3077 void FullCodeGenerator::VisitCall(Call* expr) { 3076 void FullCodeGenerator::VisitCall(Call* expr) {
3078 #ifdef DEBUG 3077 #ifdef DEBUG
3079 // We want to verify that RecordJSReturnSite gets called on all paths 3078 // We want to verify that RecordJSReturnSite gets called on all paths
3080 // through this function. Avoid early returns. 3079 // through this function. Avoid early returns.
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
3186 if (is_named_call) { 3185 if (is_named_call) {
3187 EmitCallWithLoadIC(expr); 3186 EmitCallWithLoadIC(expr);
3188 } else { 3187 } else {
3189 EmitKeyedCallWithLoadIC(expr, property->key()); 3188 EmitKeyedCallWithLoadIC(expr, property->key());
3190 } 3189 }
3191 } 3190 }
3192 } else if (call_type == Call::SUPER_CALL) { 3191 } else if (call_type == Call::SUPER_CALL) {
3193 if (FLAG_experimental_classes) { 3192 if (FLAG_experimental_classes) {
3194 EmitSuperConstructorCall(expr); 3193 EmitSuperConstructorCall(expr);
3195 } else { 3194 } else {
3195 EmitLoadSuperConstructor();
3196 __ Push(result_register());
3196 SuperReference* super_ref = callee->AsSuperReference(); 3197 SuperReference* super_ref = callee->AsSuperReference();
3197 EmitLoadSuperConstructor(super_ref);
3198 __ Push(result_register());
3199 VisitForStackValue(super_ref->this_var()); 3198 VisitForStackValue(super_ref->this_var());
3200 EmitCall(expr, CallICState::METHOD); 3199 EmitCall(expr, CallICState::METHOD);
3201 } 3200 }
3202 } else { 3201 } else {
3203 DCHECK(call_type == Call::OTHER_CALL); 3202 DCHECK(call_type == Call::OTHER_CALL);
3204 // Call to an arbitrary expression not handled specially above. 3203 // Call to an arbitrary expression not handled specially above.
3205 { PreservePositionScope scope(masm()->positions_recorder()); 3204 { PreservePositionScope scope(masm()->positions_recorder());
3206 VisitForStackValue(callee); 3205 VisitForStackValue(callee);
3207 } 3206 }
3208 __ LoadRoot(r1, Heap::kUndefinedValueRootIndex); 3207 __ LoadRoot(r1, Heap::kUndefinedValueRootIndex);
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
3261 context()->Plug(r0); 3260 context()->Plug(r0);
3262 } 3261 }
3263 3262
3264 3263
3265 void FullCodeGenerator::EmitSuperConstructorCall(Call* expr) { 3264 void FullCodeGenerator::EmitSuperConstructorCall(Call* expr) {
3266 Comment cmnt(masm_, "[ SuperConstructorCall"); 3265 Comment cmnt(masm_, "[ SuperConstructorCall");
3267 Variable* new_target_var = scope()->DeclarationScope()->new_target_var(); 3266 Variable* new_target_var = scope()->DeclarationScope()->new_target_var();
3268 GetVar(result_register(), new_target_var); 3267 GetVar(result_register(), new_target_var);
3269 __ Push(result_register()); 3268 __ Push(result_register());
3270 3269
3271 SuperReference* super_ref = expr->expression()->AsSuperReference(); 3270 EmitLoadSuperConstructor();
3272 EmitLoadSuperConstructor(super_ref);
3273 __ push(result_register()); 3271 __ push(result_register());
3274 3272
3273 SuperReference* super_ref = expr->expression()->AsSuperReference();
3275 Variable* this_var = super_ref->this_var()->var(); 3274 Variable* this_var = super_ref->this_var()->var();
3276 3275
3277 GetVar(r0, this_var); 3276 GetVar(r0, this_var);
3278 __ CompareRoot(r0, Heap::kTheHoleValueRootIndex); 3277 __ CompareRoot(r0, Heap::kTheHoleValueRootIndex);
3279 Label uninitialized_this; 3278 Label uninitialized_this;
3280 __ b(eq, &uninitialized_this); 3279 __ b(eq, &uninitialized_this);
3281 __ mov(r0, Operand(this_var->name())); 3280 __ mov(r0, Operand(this_var->name()));
3282 __ Push(r0); 3281 __ Push(r0);
3283 __ CallRuntime(Runtime::kThrowReferenceError, 1); 3282 __ CallRuntime(Runtime::kThrowReferenceError, 1);
3284 __ bind(&uninitialized_this); 3283 __ bind(&uninitialized_this);
(...skipping 885 matching lines...) Expand 10 before | Expand all | Expand 10 after
4170 4169
4171 __ bind(&runtime); 4170 __ bind(&runtime);
4172 __ push(r0); 4171 __ push(r0);
4173 __ CallRuntime(Runtime::kCall, args->length()); 4172 __ CallRuntime(Runtime::kCall, args->length());
4174 __ bind(&done); 4173 __ bind(&done);
4175 4174
4176 context()->Plug(r0); 4175 context()->Plug(r0);
4177 } 4176 }
4178 4177
4179 4178
4179 void FullCodeGenerator::EmitDefaultConstructorCallSuper(CallRuntime* expr) {
4180 Variable* new_target_var = scope()->DeclarationScope()->new_target_var();
4181 GetVar(result_register(), new_target_var);
4182 __ Push(result_register());
4183
4184 EmitLoadSuperConstructor();
4185 __ Push(result_register());
4186
4187 // Check if the calling frame is an arguments adaptor frame.
4188 Label adaptor_frame, args_set_up, runtime;
4189 __ ldr(r2, MemOperand(fp, StandardFrameConstants::kCallerFPOffset));
4190 __ ldr(r3, MemOperand(r2, StandardFrameConstants::kContextOffset));
4191 __ cmp(r3, Operand(Smi::FromInt(StackFrame::ARGUMENTS_ADAPTOR)));
4192 __ b(eq, &adaptor_frame);
4193 // default constructor has no arguments, so no adaptor frame means no args.
4194 __ mov(r0, Operand::Zero());
4195 __ b(&args_set_up);
4196
4197 // Copy arguments from adaptor frame.
4198 {
4199 __ bind(&adaptor_frame);
4200 __ ldr(r1, MemOperand(r2, ArgumentsAdaptorFrameConstants::kLengthOffset));
4201 __ SmiUntag(r1, r1);
4202
4203 // Subtract 1 from arguments count, for new.target.
4204 __ sub(r1, r1, Operand(1));
4205 __ mov(r0, r1);
4206
4207 // Get arguments pointer in r2.
4208 __ add(r2, r2, Operand(r1, LSL, kPointerSizeLog2));
4209 __ add(r2, r2, Operand(StandardFrameConstants::kCallerSPOffset));
4210 Label loop;
4211 __ bind(&loop);
4212 // Pre-decrement r2 with kPointerSize on each iteration.
4213 // Pre-decrement in order to skip receiver.
4214 __ ldr(r3, MemOperand(r2, kPointerSize, NegPreIndex));
4215 __ Push(r3);
4216 __ sub(r1, r1, Operand(1));
4217 __ cmp(r1, Operand::Zero());
4218 __ b(ne, &loop);
4219 }
4220
4221 __ bind(&args_set_up);
4222 __ ldr(r1, MemOperand(sp, r0, LSL, kPointerSizeLog2));
4223
4224 CallConstructStub stub(isolate(), SUPER_CONSTRUCTOR_CALL);
4225 __ Call(stub.GetCode(), RelocInfo::CONSTRUCT_CALL);
4226
4227 __ Drop(1);
4228
4229 context()->Plug(result_register());
4230 }
4231
4232
4180 void FullCodeGenerator::EmitRegExpConstructResult(CallRuntime* expr) { 4233 void FullCodeGenerator::EmitRegExpConstructResult(CallRuntime* expr) {
4181 RegExpConstructResultStub stub(isolate()); 4234 RegExpConstructResultStub stub(isolate());
4182 ZoneList<Expression*>* args = expr->arguments(); 4235 ZoneList<Expression*>* args = expr->arguments();
4183 DCHECK(args->length() == 3); 4236 DCHECK(args->length() == 3);
4184 VisitForStackValue(args->at(0)); 4237 VisitForStackValue(args->at(0));
4185 VisitForStackValue(args->at(1)); 4238 VisitForStackValue(args->at(1));
4186 VisitForAccumulatorValue(args->at(2)); 4239 VisitForAccumulatorValue(args->at(2));
4187 __ pop(r1); 4240 __ pop(r1);
4188 __ pop(r2); 4241 __ pop(r2);
4189 __ CallStub(&stub); 4242 __ CallStub(&stub);
(...skipping 1248 matching lines...) Expand 10 before | Expand all | Expand 10 after
5438 5491
5439 DCHECK(interrupt_address == 5492 DCHECK(interrupt_address ==
5440 isolate->builtins()->OsrAfterStackCheck()->entry()); 5493 isolate->builtins()->OsrAfterStackCheck()->entry());
5441 return OSR_AFTER_STACK_CHECK; 5494 return OSR_AFTER_STACK_CHECK;
5442 } 5495 }
5443 5496
5444 5497
5445 } } // namespace v8::internal 5498 } } // namespace v8::internal
5446 5499
5447 #endif // V8_TARGET_ARCH_ARM 5500 #endif // V8_TARGET_ARCH_ARM
OLDNEW
« no previous file with comments | « no previous file | src/arm64/full-codegen-arm64.cc » ('j') | src/x64/code-stubs-x64.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698