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

Unified Diff: src/arm64/code-stubs-arm64.cc

Issue 1980483003: [es6] Reintroduce the instanceof operator in the backends. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Igors comments. Created 4 years, 7 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/arm64/builtins-arm64.cc ('k') | src/arm64/interface-descriptors-arm64.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/arm64/code-stubs-arm64.cc
diff --git a/src/arm64/code-stubs-arm64.cc b/src/arm64/code-stubs-arm64.cc
index e36e4f9dcca6419a7ca6dab39fbd361bf50d5e77..a96b3dfa9833285d67ebdb60384c6c533680e735 100644
--- a/src/arm64/code-stubs-arm64.cc
+++ b/src/arm64/code-stubs-arm64.cc
@@ -1504,123 +1504,6 @@ void LoadIndexedStringStub::Generate(MacroAssembler* masm) {
}
-void InstanceOfStub::Generate(MacroAssembler* masm) {
- Register const object = x1; // Object (lhs).
- Register const function = x0; // Function (rhs).
- Register const object_map = x2; // Map of {object}.
- Register const function_map = x3; // Map of {function}.
- Register const function_prototype = x4; // Prototype of {function}.
- Register const scratch = x5;
-
- DCHECK(object.is(InstanceOfDescriptor::LeftRegister()));
- DCHECK(function.is(InstanceOfDescriptor::RightRegister()));
-
- // Check if {object} is a smi.
- Label object_is_smi;
- __ JumpIfSmi(object, &object_is_smi);
-
- // Lookup the {function} and the {object} map in the global instanceof cache.
- // Note: This is safe because we clear the global instanceof cache whenever
- // we change the prototype of any object.
- Label fast_case, slow_case;
- __ Ldr(object_map, FieldMemOperand(object, HeapObject::kMapOffset));
- __ JumpIfNotRoot(function, Heap::kInstanceofCacheFunctionRootIndex,
- &fast_case);
- __ JumpIfNotRoot(object_map, Heap::kInstanceofCacheMapRootIndex, &fast_case);
- __ LoadRoot(x0, Heap::kInstanceofCacheAnswerRootIndex);
- __ Ret();
-
- // If {object} is a smi we can safely return false if {function} is a JS
- // function, otherwise we have to miss to the runtime and throw an exception.
- __ Bind(&object_is_smi);
- __ JumpIfSmi(function, &slow_case);
- __ JumpIfNotObjectType(function, function_map, scratch, JS_FUNCTION_TYPE,
- &slow_case);
- __ LoadRoot(x0, Heap::kFalseValueRootIndex);
- __ Ret();
-
- // Fast-case: The {function} must be a valid JSFunction.
- __ Bind(&fast_case);
- __ JumpIfSmi(function, &slow_case);
- __ JumpIfNotObjectType(function, function_map, scratch, JS_FUNCTION_TYPE,
- &slow_case);
-
- // Go to the runtime if the function is not a constructor.
- __ Ldrb(scratch, FieldMemOperand(function_map, Map::kBitFieldOffset));
- __ Tbz(scratch, Map::kIsConstructor, &slow_case);
-
- // Ensure that {function} has an instance prototype.
- __ Tbnz(scratch, Map::kHasNonInstancePrototype, &slow_case);
-
- // Get the "prototype" (or initial map) of the {function}.
- __ Ldr(function_prototype,
- FieldMemOperand(function, JSFunction::kPrototypeOrInitialMapOffset));
- __ AssertNotSmi(function_prototype);
-
- // Resolve the prototype if the {function} has an initial map. Afterwards the
- // {function_prototype} will be either the JSReceiver prototype object or the
- // hole value, which means that no instances of the {function} were created so
- // far and hence we should return false.
- Label function_prototype_valid;
- __ JumpIfNotObjectType(function_prototype, scratch, scratch, MAP_TYPE,
- &function_prototype_valid);
- __ Ldr(function_prototype,
- FieldMemOperand(function_prototype, Map::kPrototypeOffset));
- __ Bind(&function_prototype_valid);
- __ AssertNotSmi(function_prototype);
-
- // Update the global instanceof cache with the current {object} map and
- // {function}. The cached answer will be set when it is known below.
- __ StoreRoot(function, Heap::kInstanceofCacheFunctionRootIndex);
- __ StoreRoot(object_map, Heap::kInstanceofCacheMapRootIndex);
-
- // Loop through the prototype chain looking for the {function} prototype.
- // Assume true, and change to false if not found.
- Register const object_instance_type = function_map;
- Register const map_bit_field = function_map;
- Register const null = scratch;
- Register const result = x0;
-
- Label done, loop, fast_runtime_fallback;
- __ LoadRoot(result, Heap::kTrueValueRootIndex);
- __ LoadRoot(null, Heap::kNullValueRootIndex);
- __ Bind(&loop);
-
- // Check if the object needs to be access checked.
- __ Ldrb(map_bit_field, FieldMemOperand(object_map, Map::kBitFieldOffset));
- __ TestAndBranchIfAnySet(map_bit_field, 1 << Map::kIsAccessCheckNeeded,
- &fast_runtime_fallback);
- // Check if the current object is a Proxy.
- __ CompareInstanceType(object_map, object_instance_type, JS_PROXY_TYPE);
- __ B(eq, &fast_runtime_fallback);
-
- __ Ldr(object, FieldMemOperand(object_map, Map::kPrototypeOffset));
- __ Cmp(object, function_prototype);
- __ B(eq, &done);
- __ Cmp(object, null);
- __ Ldr(object_map, FieldMemOperand(object, HeapObject::kMapOffset));
- __ B(ne, &loop);
- __ LoadRoot(result, Heap::kFalseValueRootIndex);
- __ Bind(&done);
- __ StoreRoot(result, Heap::kInstanceofCacheAnswerRootIndex);
- __ Ret();
-
- // Found Proxy or access check needed: Call the runtime
- __ Bind(&fast_runtime_fallback);
- __ Push(object, function_prototype);
- // Invalidate the instanceof cache.
- __ Move(scratch, Smi::FromInt(0));
- __ StoreRoot(scratch, Heap::kInstanceofCacheFunctionRootIndex);
- __ TailCallRuntime(Runtime::kHasInPrototypeChain);
-
- // Slow-case: Call the %InstanceOf runtime function.
- __ bind(&slow_case);
- __ Push(object, function);
- __ TailCallRuntime(is_es6_instanceof() ? Runtime::kOrdinaryHasInstance
- : Runtime::kInstanceOf);
-}
-
-
void RegExpExecStub::Generate(MacroAssembler* masm) {
#ifdef V8_INTERPRETED_REGEXP
__ TailCallRuntime(Runtime::kRegExpExec);
« no previous file with comments | « src/arm64/builtins-arm64.cc ('k') | src/arm64/interface-descriptors-arm64.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698