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

Unified Diff: src/builtins.cc

Issue 873623002: cleanup check for compatible receiver of api callback (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | src/objects.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/builtins.cc
diff --git a/src/builtins.cc b/src/builtins.cc
index 6fea01411723603a35d3eda984168ace1d2cea70..f48fa15348d83dd3856ba4f9075da458d73be45a 100644
--- a/src/builtins.cc
+++ b/src/builtins.cc
@@ -1022,45 +1022,6 @@ BUILTIN(GeneratorPoisonPill) {
//
-// Searches the hidden prototype chain of the given object for the first
-// object that is an instance of the given type. If no such object can
-// be found then Heap::null_value() is returned.
-static inline Object* FindHidden(Heap* heap,
- Object* object,
- FunctionTemplateInfo* type) {
- for (PrototypeIterator iter(heap->isolate(), object,
- PrototypeIterator::START_AT_RECEIVER);
- !iter.IsAtEnd(PrototypeIterator::END_AT_NON_HIDDEN); iter.Advance()) {
- if (type->IsTemplateFor(iter.GetCurrent())) {
- return iter.GetCurrent();
- }
- }
- return heap->null_value();
-}
-
-
-// Returns the holder JSObject if the function can legally be called
-// with this receiver. Returns Heap::null_value() if the call is
-// illegal. Any arguments that don't fit the expected type is
-// overwritten with undefined. Note that holder and the arguments are
-// implicitly rewritten with the first object in the hidden prototype
-// chain that actually has the expected type.
-static inline Object* TypeCheck(Heap* heap, Object* recv,
- FunctionTemplateInfo* info) {
- // API calls are only supported with JSObject receivers.
- if (!recv->IsJSObject()) return heap->null_value();
- Object* recv_type = info->signature();
- if (recv_type->IsUndefined()) return recv;
- // If necessary, check the receiver
- Object* holder = recv;
- if (!recv_type->IsUndefined()) {
- holder = FindHidden(heap, holder, FunctionTemplateInfo::cast(recv_type));
- if (holder == heap->null_value()) return heap->null_value();
- }
- return holder;
-}
-
-
template <bool is_construct>
MUST_USE_RESULT static Object* HandleApiCallHelper(
BuiltinArguments<NEEDS_CALLED_FUNCTION> args, Isolate* isolate) {
@@ -1084,7 +1045,7 @@ MUST_USE_RESULT static Object* HandleApiCallHelper(
DCHECK(!args[0]->IsNull());
if (args[0]->IsUndefined()) args[0] = function->global_proxy();
- Object* raw_holder = TypeCheck(heap, args[0], *fun_data);
+ Object* raw_holder = fun_data->GetCompatibleReceiver(isolate, args[0]);
if (raw_holder->IsNull()) {
// This function cannot be called with the given receiver. Abort!
« no previous file with comments | « no previous file | src/objects.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698