Changeset 194863 in webkit for trunk/Source/JavaScriptCore/runtime/InternalFunction.cpp
- Timestamp:
- Jan 11, 2016, 1:31:04 PM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/JavaScriptCore/runtime/InternalFunction.cpp
r171824 r194863 2 2 * Copyright (C) 1999-2002 Harri Porten ([email protected]) 3 3 * Copyright (C) 2001 Peter Kelly ([email protected]) 4 * Copyright (C) 2004, 2007, 2008 Apple Inc. All rights reserved.4 * Copyright (C) 2004, 2007, 2008, 2016 Apple Inc. All rights reserved. 5 5 * 6 6 * This library is free software; you can redistribute it and/or … … 79 79 } 80 80 81 Structure* InternalFunction::createSubclassStructure(ExecState* exec, JSValue newTarget, Structure* baseClass) 82 { 83 84 VM& vm = exec->vm(); 85 // We allow newTarget == JSValue() because the API needs to be able to create classes without having a real JS frame. 86 // Since we don't allow subclassing in the API we just treat newTarget == JSValue() as newTarget == exec->callee() 87 ASSERT(!newTarget || newTarget.isFunction()); 88 89 if (newTarget && newTarget != exec->callee()) { 90 // newTarget may be an InternalFunction if we were called from Reflect.construct. 91 JSFunction* targetFunction = jsDynamicCast<JSFunction*>(newTarget); 92 93 if (LIKELY(targetFunction)) { 94 Structure* structure = targetFunction->rareData(vm)->internalFunctionAllocationStructure(); 95 if (LIKELY(structure && structure->classInfo() == baseClass->classInfo())) 96 return structure; 97 98 // Note, Reflect.construct might cause the profile to churn but we don't care. 99 JSObject* prototype = jsDynamicCast<JSObject*>(newTarget.get(exec, exec->propertyNames().prototype)); 100 if (prototype) 101 return targetFunction->rareData(vm)->createInternalFunctionAllocationStructureFromBase(vm, prototype, baseClass); 102 } else { 103 JSObject* prototype = jsDynamicCast<JSObject*>(newTarget.get(exec, exec->propertyNames().prototype)); 104 if (prototype) { 105 // This only happens if someone Reflect.constructs our builtin constructor with another builtin constructor as the new.target. 106 // Thus, we don't care about the cost of looking up the structure from our hash table every time. 107 return vm.prototypeMap.emptyStructureForPrototypeFromBaseStructure(prototype, baseClass); 108 } 109 } 110 } 111 112 return baseClass; 113 } 114 115 81 116 } // namespace JSC
Note:
See TracChangeset
for help on using the changeset viewer.