fixed #12151: [optimization] Functions in se::State should be inlined (#12617)

* fixed #12151: [optimization] Functions in se::State should be inlined

* Update native-unit-test.yml
This commit is contained in:
James Chen
2022-09-01 14:49:12 +08:00
committed by GitHub
parent d1e7907c02
commit e1e35558eb
3 changed files with 18 additions and 26 deletions
+1 -1
View File
@@ -1,4 +1,4 @@
name: <Native> Run Tests
name: <Native> Run Unit Tests
on:
pull_request:
-21
View File
@@ -25,7 +25,6 @@
****************************************************************************/
#include "State.h"
#include "Object.h"
namespace se {
@@ -48,24 +47,4 @@ State::~State() {
SAFE_DEC_REF(_thisObject);
}
void *State::nativeThisObject() const {
return _thisObject != nullptr ? _thisObject->getPrivateData() : nullptr;
}
Object *State::thisObject() {
// _nativeThisObject in Static method will be nullptr
// assert(_thisObject != nullptr);
return _thisObject;
}
const ValueArray &State::args() const {
if (_args != nullptr) {
return *(_args);
}
return EmptyValueArray;
}
Value &State::rval() {
return _retVal;
}
} // namespace se
+17 -4
View File
@@ -26,6 +26,7 @@
#pragma once
#include "Object.h"
#include "PrivateObject.h"
#include "Value.h"
@@ -42,25 +43,37 @@ public:
* @brief Gets void* pointer of `this` object's private data.
* @return A void* pointer of `this` object's private data.
*/
void *nativeThisObject() const;
inline void *nativeThisObject() const {
return _thisObject != nullptr ? _thisObject->getPrivateData() : nullptr;
}
/**
* @brief Gets the arguments of native binding functions or accesstors.
* @return The arguments of native binding functions or accesstors.
*/
const ValueArray &args() const;
inline const ValueArray &args() const {
return _args != nullptr ? (*_args) : EmptyValueArray;
}
/**
* @brief Gets the JavaScript `this` object wrapped in se::Object.
* @return The JavaScript `this` object wrapped in se::Object.
*/
Object *thisObject();
inline Object *thisObject() const {
return _thisObject;
}
/**
* @brief Gets the return value reference. Used for setting return value for a function.
* @return The return value reference.
*/
Value &rval();
inline const Value &rval() const {
return _retVal;
}
inline Value &rval() {
return _retVal;
}
// Private API used in wrapper
/**