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

Side by Side Diff: src/arm/builtins-arm.cc

Issue 1576423003: Fix the receiver check in the HandleFastApiCall builtin. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Rebased. Created 4 years, 11 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/builtins-arm64.cc » ('j') | no next file with comments »
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 #if V8_TARGET_ARCH_ARM 5 #if V8_TARGET_ARCH_ARM
6 6
7 #include "src/codegen.h" 7 #include "src/codegen.h"
8 #include "src/debug/debug.h" 8 #include "src/debug/debug.h"
9 #include "src/deoptimizer.h" 9 #include "src/deoptimizer.h"
10 #include "src/full-codegen/full-codegen.h" 10 #include "src/full-codegen/full-codegen.h"
(...skipping 1288 matching lines...) Expand 10 before | Expand all | Expand 10 after
1299 Register constructor = scratch2; 1299 Register constructor = scratch2;
1300 1300
1301 // If there is no signature, return the holder. 1301 // If there is no signature, return the holder.
1302 __ ldr(signature, FieldMemOperand(function_template_info, 1302 __ ldr(signature, FieldMemOperand(function_template_info,
1303 FunctionTemplateInfo::kSignatureOffset)); 1303 FunctionTemplateInfo::kSignatureOffset));
1304 __ CompareRoot(signature, Heap::kUndefinedValueRootIndex); 1304 __ CompareRoot(signature, Heap::kUndefinedValueRootIndex);
1305 Label receiver_check_passed; 1305 Label receiver_check_passed;
1306 __ b(eq, &receiver_check_passed); 1306 __ b(eq, &receiver_check_passed);
1307 1307
1308 // Walk the prototype chain. 1308 // Walk the prototype chain.
1309 __ ldr(map, FieldMemOperand(receiver, HeapObject::kMapOffset));
1309 Label prototype_loop_start; 1310 Label prototype_loop_start;
1310 __ bind(&prototype_loop_start); 1311 __ bind(&prototype_loop_start);
1311 1312
1312 // End if the receiver is null or if it's a hidden type.
1313 __ CompareRoot(receiver, Heap::kNullValueRootIndex);
1314 __ b(eq, receiver_check_failed);
1315 __ ldr(map, FieldMemOperand(receiver, HeapObject::kMapOffset));
1316 __ ldr(ip, FieldMemOperand(map, Map::kBitField3Offset));
1317 __ tst(ip, Operand(Map::IsHiddenPrototype::kMask));
1318 __ b(ne, receiver_check_failed);
1319
1320 // Get the constructor, if any. 1313 // Get the constructor, if any.
1321 __ GetMapConstructor(constructor, map, ip, ip); 1314 __ GetMapConstructor(constructor, map, ip, ip);
1322 __ cmp(ip, Operand(JS_FUNCTION_TYPE)); 1315 __ cmp(ip, Operand(JS_FUNCTION_TYPE));
1323 Label next_prototype; 1316 Label next_prototype;
1324 __ b(ne, &next_prototype); 1317 __ b(ne, &next_prototype);
1325 Register type = constructor; 1318 Register type = constructor;
1326 __ ldr(type, 1319 __ ldr(type,
1327 FieldMemOperand(constructor, JSFunction::kSharedFunctionInfoOffset)); 1320 FieldMemOperand(constructor, JSFunction::kSharedFunctionInfoOffset));
1328 __ ldr(type, FieldMemOperand(type, SharedFunctionInfo::kFunctionDataOffset)); 1321 __ ldr(type, FieldMemOperand(type, SharedFunctionInfo::kFunctionDataOffset));
1329 1322
1330 // Loop through the chain of inheriting function templates. 1323 // Loop through the chain of inheriting function templates.
1331 Label function_template_loop; 1324 Label function_template_loop;
1332 __ bind(&function_template_loop); 1325 __ bind(&function_template_loop);
1333 1326
1334 // If the signatures match, we have a compatible receiver. 1327 // If the signatures match, we have a compatible receiver.
1335 __ cmp(signature, type); 1328 __ cmp(signature, type);
1336 __ b(eq, &receiver_check_passed); 1329 __ b(eq, &receiver_check_passed);
1337 1330
1338 // If the current type is not a FunctionTemplateInfo, load the next prototype 1331 // If the current type is not a FunctionTemplateInfo, load the next prototype
1339 // in the chain. 1332 // in the chain.
1340 __ JumpIfSmi(type, &next_prototype); 1333 __ JumpIfSmi(type, &next_prototype);
1341 __ CompareObjectType(type, ip, ip, FUNCTION_TEMPLATE_INFO_TYPE); 1334 __ CompareObjectType(type, ip, ip, FUNCTION_TEMPLATE_INFO_TYPE);
1342 1335
1343 // Otherwise load the parent function template and iterate. 1336 // Otherwise load the parent function template and iterate.
1344 __ ldr(type, 1337 __ ldr(type,
1345 FieldMemOperand(type, FunctionTemplateInfo::kParentTemplateOffset), 1338 FieldMemOperand(type, FunctionTemplateInfo::kParentTemplateOffset),
1346 eq); 1339 eq);
1347 __ b(&function_template_loop, eq); 1340 __ b(&function_template_loop, eq);
1348 1341
1349 // Load the next prototype and iterate. 1342 // Load the next prototype.
1350 __ bind(&next_prototype); 1343 __ bind(&next_prototype);
1351 __ ldr(receiver, FieldMemOperand(map, Map::kPrototypeOffset)); 1344 __ ldr(receiver, FieldMemOperand(map, Map::kPrototypeOffset));
1345 // End if the prototype is null or not hidden.
1346 __ CompareRoot(receiver, Heap::kNullValueRootIndex);
1347 __ b(eq, receiver_check_failed);
1348 __ ldr(map, FieldMemOperand(receiver, HeapObject::kMapOffset));
1349 __ ldr(ip, FieldMemOperand(map, Map::kBitField3Offset));
1350 __ tst(ip, Operand(Map::IsHiddenPrototype::kMask));
1351 __ b(eq, receiver_check_failed);
1352 // Iterate.
1352 __ b(&prototype_loop_start); 1353 __ b(&prototype_loop_start);
1353 1354
1354 __ bind(&receiver_check_passed); 1355 __ bind(&receiver_check_passed);
1355 } 1356 }
1356 1357
1357 1358
1358 void Builtins::Generate_HandleFastApiCall(MacroAssembler* masm) { 1359 void Builtins::Generate_HandleFastApiCall(MacroAssembler* masm) {
1359 // ----------- S t a t e ------------- 1360 // ----------- S t a t e -------------
1360 // -- r0 : number of arguments excluding receiver 1361 // -- r0 : number of arguments excluding receiver
1361 // -- r1 : callee 1362 // -- r1 : callee
(...skipping 1068 matching lines...) Expand 10 before | Expand all | Expand 10 after
2430 } 2431 }
2431 } 2432 }
2432 2433
2433 2434
2434 #undef __ 2435 #undef __
2435 2436
2436 } // namespace internal 2437 } // namespace internal
2437 } // namespace v8 2438 } // namespace v8
2438 2439
2439 #endif // V8_TARGET_ARCH_ARM 2440 #endif // V8_TARGET_ARCH_ARM
OLDNEW
« no previous file with comments | « no previous file | src/arm64/builtins-arm64.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698