Skip to content

Commit ffed242

Browse files
committed
JavaScriptCore-7608.4.9.1.3
1 parent 5ea6380 commit ffed242

File tree

2,357 files changed

+387530
-412056
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

2,357 files changed

+387530
-412056
lines changed

API/APICast.h

+19-13
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
#include "JSCJSValue.h"
3131
#include "JSCJSValueInlines.h"
3232
#include "JSGlobalObject.h"
33+
#include "HeapCellInlines.h"
3334

3435
namespace JSC {
3536
class ExecState;
@@ -68,7 +69,7 @@ inline JSC::JSGlobalObject* toJSGlobalObject(JSGlobalContextRef context)
6869
inline JSC::JSValue toJS(JSC::ExecState* exec, JSValueRef v)
6970
{
7071
ASSERT_UNUSED(exec, exec);
71-
#if USE(JSVALUE32_64)
72+
#if !CPU(ADDRESS64)
7273
JSC::JSCell* jsCell = reinterpret_cast<JSC::JSCell*>(const_cast<OpaqueJSValue*>(v));
7374
if (!jsCell)
7475
return JSC::jsNull();
@@ -78,28 +79,28 @@ inline JSC::JSValue toJS(JSC::ExecState* exec, JSValueRef v)
7879
else
7980
result = jsCell;
8081
#else
81-
JSC::JSValue result = JSC::JSValue::decode(reinterpret_cast<JSC::EncodedJSValue>(const_cast<OpaqueJSValue*>(v)));
82+
JSC::JSValue result = bitwise_cast<JSC::JSValue>(v);
8283
#endif
8384
if (!result)
8485
return JSC::jsNull();
8586
if (result.isCell())
86-
RELEASE_ASSERT(result.asCell()->methodTable());
87+
RELEASE_ASSERT(result.asCell()->methodTable(exec->vm()));
8788
return result;
8889
}
8990

9091
inline JSC::JSValue toJSForGC(JSC::ExecState* exec, JSValueRef v)
9192
{
9293
ASSERT_UNUSED(exec, exec);
93-
#if USE(JSVALUE32_64)
94+
#if !CPU(ADDRESS64)
9495
JSC::JSCell* jsCell = reinterpret_cast<JSC::JSCell*>(const_cast<OpaqueJSValue*>(v));
9596
if (!jsCell)
9697
return JSC::JSValue();
9798
JSC::JSValue result = jsCell;
9899
#else
99-
JSC::JSValue result = JSC::JSValue::decode(reinterpret_cast<JSC::EncodedJSValue>(const_cast<OpaqueJSValue*>(v)));
100+
JSC::JSValue result = bitwise_cast<JSC::JSValue>(v);
100101
#endif
101102
if (result && result.isCell())
102-
RELEASE_ASSERT(result.asCell()->methodTable());
103+
RELEASE_ASSERT(result.asCell()->methodTable(exec->vm()));
103104
return result;
104105
}
105106

@@ -113,7 +114,7 @@ inline JSC::JSObject* toJS(JSObjectRef o)
113114
{
114115
JSC::JSObject* object = uncheckedToJS(o);
115116
if (object)
116-
RELEASE_ASSERT(object->methodTable());
117+
RELEASE_ASSERT(object->methodTable(*object->vm()));
117118
return object;
118119
}
119120

@@ -127,21 +128,26 @@ inline JSC::VM* toJS(JSContextGroupRef g)
127128
return reinterpret_cast<JSC::VM*>(const_cast<OpaqueJSContextGroup*>(g));
128129
}
129130

130-
inline JSValueRef toRef(JSC::ExecState* exec, JSC::JSValue v)
131+
inline JSValueRef toRef(JSC::VM& vm, JSC::JSValue v)
131132
{
132-
ASSERT(exec->vm().currentThreadIsHoldingAPILock());
133-
#if USE(JSVALUE32_64)
133+
ASSERT(vm.currentThreadIsHoldingAPILock());
134+
#if !CPU(ADDRESS64)
134135
if (!v)
135136
return 0;
136137
if (!v.isCell())
137-
return reinterpret_cast<JSValueRef>(JSC::jsAPIValueWrapper(exec, v).asCell());
138+
return reinterpret_cast<JSValueRef>(JSC::JSAPIValueWrapper::create(vm, v));
138139
return reinterpret_cast<JSValueRef>(v.asCell());
139140
#else
140-
UNUSED_PARAM(exec);
141-
return reinterpret_cast<JSValueRef>(JSC::JSValue::encode(v));
141+
UNUSED_PARAM(vm);
142+
return bitwise_cast<JSValueRef>(v);
142143
#endif
143144
}
144145

146+
inline JSValueRef toRef(JSC::ExecState* exec, JSC::JSValue v)
147+
{
148+
return toRef(exec->vm(), v);
149+
}
150+
145151
inline JSObjectRef toRef(JSC::JSObject* o)
146152
{
147153
return reinterpret_cast<JSObjectRef>(o);

API/APIUtils.h

+4-5
Original file line numberDiff line numberDiff line change
@@ -37,17 +37,15 @@ enum class ExceptionStatus {
3737
DidNotThrow
3838
};
3939

40-
inline ExceptionStatus handleExceptionIfNeeded(JSC::ExecState* exec, JSValueRef* returnedExceptionRef)
40+
inline ExceptionStatus handleExceptionIfNeeded(JSC::CatchScope& scope, JSC::ExecState* exec, JSValueRef* returnedExceptionRef)
4141
{
42-
JSC::VM& vm = exec->vm();
43-
auto scope = DECLARE_CATCH_SCOPE(vm);
4442
if (UNLIKELY(scope.exception())) {
4543
JSC::Exception* exception = scope.exception();
4644
if (returnedExceptionRef)
4745
*returnedExceptionRef = toRef(exec, exception->value());
4846
scope.clearException();
4947
#if ENABLE(REMOTE_INSPECTOR)
50-
exec->vmEntryGlobalObject()->inspectorController().reportAPIException(exec, exception);
48+
scope.vm().vmEntryGlobalObject(exec)->inspectorController().reportAPIException(exec, exception);
5149
#endif
5250
return ExceptionStatus::DidThrow;
5351
}
@@ -59,7 +57,8 @@ inline void setException(JSC::ExecState* exec, JSValueRef* returnedExceptionRef,
5957
if (returnedExceptionRef)
6058
*returnedExceptionRef = toRef(exec, exception);
6159
#if ENABLE(REMOTE_INSPECTOR)
62-
exec->vmEntryGlobalObject()->inspectorController().reportAPIException(exec, JSC::Exception::create(exec->vm(), exception));
60+
JSC::VM& vm = exec->vm();
61+
vm.vmEntryGlobalObject(exec)->inspectorController().reportAPIException(exec, JSC::Exception::create(vm, exception));
6362
#endif
6463
}
6564

API/JSAPIGlobalObject.cpp

+54
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
/*
2+
* Copyright (C) 2019 Apple Inc. All rights reserved.
3+
*
4+
* Redistribution and use in source and binary forms, with or without
5+
* modification, are permitted provided that the following conditions
6+
* are met:
7+
* 1. Redistributions of source code must retain the above copyright
8+
* notice, this list of conditions and the following disclaimer.
9+
* 2. Redistributions in binary form must reproduce the above copyright
10+
* notice, this list of conditions and the following disclaimer in the
11+
* documentation and/or other materials provided with the distribution.
12+
*
13+
* THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
14+
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15+
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16+
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR
17+
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
18+
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
19+
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
20+
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
21+
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22+
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
23+
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24+
*/
25+
26+
#include "config.h"
27+
#include "JSAPIGlobalObject.h"
28+
29+
#if !JSC_OBJC_API_ENABLED
30+
31+
namespace JSC {
32+
33+
const ClassInfo JSAPIGlobalObject::s_info = { "GlobalObject", &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSAPIGlobalObject) };
34+
35+
const GlobalObjectMethodTable JSAPIGlobalObject::s_globalObjectMethodTable = {
36+
&supportsRichSourceInfo,
37+
&shouldInterruptScript,
38+
&javaScriptRuntimeFlags,
39+
nullptr, // queueTaskToEventLoop
40+
&shouldInterruptScriptBeforeTimeout,
41+
nullptr, // moduleLoaderImportModule
42+
nullptr, // moduleLoaderResolve
43+
nullptr, // moduleLoaderFetch
44+
nullptr, // moduleLoaderCreateImportMetaProperties
45+
nullptr, // moduleLoaderEvaluate
46+
nullptr, // promiseRejectionTracker
47+
nullptr, // defaultLanguage
48+
nullptr, // compileStreaming
49+
nullptr, // instantiateStreaming
50+
};
51+
52+
}
53+
54+
#endif

API/JSAPIGlobalObject.h

+69
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
/*
2+
* Copyright (C) 2019 Apple Inc. All rights reserved.
3+
*
4+
* Redistribution and use in source and binary forms, with or without
5+
* modification, are permitted provided that the following conditions
6+
* are met:
7+
* 1. Redistributions of source code must retain the above copyright
8+
* notice, this list of conditions and the following disclaimer.
9+
* 2. Redistributions in binary form must reproduce the above copyright
10+
* notice, this list of conditions and the following disclaimer in the
11+
* documentation and/or other materials provided with the distribution.
12+
*
13+
* THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
14+
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15+
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16+
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR
17+
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
18+
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
19+
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
20+
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
21+
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22+
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
23+
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24+
*/
25+
26+
#pragma once
27+
28+
#include "JSGlobalObject.h"
29+
30+
OBJC_CLASS JSScript;
31+
32+
namespace JSC {
33+
34+
class JSAPIGlobalObject : public JSGlobalObject {
35+
public:
36+
using Base = JSGlobalObject;
37+
38+
DECLARE_EXPORT_INFO;
39+
static const GlobalObjectMethodTable s_globalObjectMethodTable;
40+
41+
static JSAPIGlobalObject* create(VM& vm, Structure* structure)
42+
{
43+
auto* object = new (NotNull, allocateCell<JSAPIGlobalObject>(vm.heap)) JSAPIGlobalObject(vm, structure);
44+
object->finishCreation(vm);
45+
return object;
46+
}
47+
48+
static Structure* createStructure(VM& vm, JSValue prototype)
49+
{
50+
auto* result = Structure::create(vm, 0, prototype, TypeInfo(GlobalObjectType, StructureFlags), info());
51+
result->setTransitionWatchpointIsLikelyToBeFired(true);
52+
return result;
53+
}
54+
55+
static JSInternalPromise* moduleLoaderImportModule(JSGlobalObject*, ExecState*, JSModuleLoader*, JSString* moduleNameValue, JSValue parameters, const SourceOrigin&);
56+
static Identifier moduleLoaderResolve(JSGlobalObject*, ExecState*, JSModuleLoader*, JSValue keyValue, JSValue referrerValue, JSValue);
57+
static JSInternalPromise* moduleLoaderFetch(JSGlobalObject*, ExecState*, JSModuleLoader*, JSValue, JSValue, JSValue);
58+
static JSObject* moduleLoaderCreateImportMetaProperties(JSGlobalObject*, ExecState*, JSModuleLoader*, JSValue, JSModuleRecord*, JSValue);
59+
static JSValue moduleLoaderEvaluate(JSGlobalObject*, ExecState*, JSModuleLoader*, JSValue, JSValue, JSValue);
60+
61+
JSValue loadAndEvaluateJSScriptModule(const JSLockHolder&, JSScript *);
62+
63+
private:
64+
JSAPIGlobalObject(VM& vm, Structure* structure)
65+
: Base(vm, structure, &s_globalObjectMethodTable)
66+
{ }
67+
};
68+
69+
}

0 commit comments

Comments
 (0)