Revert "Introducing managed pointers classes (ecma_generic_ptr_t, ecma_pointer_t<T>); using ecma_generic_ptr_t to store pointer in ecma_value_t."
This reverts commit f88c0d665b4ff7e2add495bc2980adf7a1622f31.
This commit is contained in:
@@ -20,31 +20,8 @@
|
|||||||
|
|
||||||
/** \addtogroup ecma ECMA
|
/** \addtogroup ecma ECMA
|
||||||
* @{
|
* @{
|
||||||
*/
|
|
||||||
|
|
||||||
/** \addtogroup compressedpointer Compressed pointer
|
|
||||||
* @{
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Ecma-pointer field is used to calculate ecma-value's address.
|
|
||||||
*
|
*
|
||||||
* Ecma-pointer contains value's shifted offset from common Ecma-pointers' base.
|
* \addtogroup ecmacompressedpointers Helpers for operations with compressed heap pointers
|
||||||
* The offset is shifted right by MEM_ALIGNMENT_LOG.
|
|
||||||
* Least significant MEM_ALIGNMENT_LOG bits of non-shifted offset are zeroes.
|
|
||||||
*/
|
|
||||||
#define ECMA_POINTER_FIELD_WIDTH MEM_COMPRESSED_POINTER_WIDTH
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The NULL value for compressed pointers
|
|
||||||
*/
|
|
||||||
#define ECMA_NULL_POINTER MEM_COMPRESSED_POINTER_NULL
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @}
|
|
||||||
*/
|
|
||||||
|
|
||||||
/** \addtogroup ecmacompressedpointers Helpers for operations with compressed heap pointers
|
|
||||||
* @{
|
* @{
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|||||||
@@ -24,10 +24,31 @@
|
|||||||
#define JERRY_ECMA_GLOBALS_H
|
#define JERRY_ECMA_GLOBALS_H
|
||||||
|
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
#include "ecma-managed-pointer.h"
|
|
||||||
#include "globals.h"
|
#include "globals.h"
|
||||||
#include "mem-allocator.h"
|
#include "mem-allocator.h"
|
||||||
|
|
||||||
|
/** \addtogroup compressedpointer Compressed pointer
|
||||||
|
* @{
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Ecma-pointer field is used to calculate ecma-value's address.
|
||||||
|
*
|
||||||
|
* Ecma-pointer contains value's shifted offset from common Ecma-pointers' base.
|
||||||
|
* The offset is shifted right by MEM_ALIGNMENT_LOG.
|
||||||
|
* Least significant MEM_ALIGNMENT_LOG bits of non-shifted offset are zeroes.
|
||||||
|
*/
|
||||||
|
#define ECMA_POINTER_FIELD_WIDTH MEM_COMPRESSED_POINTER_WIDTH
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The NULL value for compressed pointers
|
||||||
|
*/
|
||||||
|
#define ECMA_NULL_POINTER MEM_COMPRESSED_POINTER_NULL
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @}
|
||||||
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Type of ecma-value
|
* Type of ecma-value
|
||||||
*/
|
*/
|
||||||
@@ -748,13 +769,6 @@ typedef struct
|
|||||||
} u;
|
} u;
|
||||||
} ecma_string_t;
|
} ecma_string_t;
|
||||||
|
|
||||||
/**
|
|
||||||
* Managed pointers definition
|
|
||||||
*/
|
|
||||||
typedef ecma_pointer_t<ecma_number_t> ecma_number_ptr_t;
|
|
||||||
typedef ecma_pointer_t<ecma_string_t> ecma_string_ptr_t;
|
|
||||||
typedef ecma_pointer_t<ecma_object_t> ecma_object_ptr_t;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @}
|
* @}
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -1,133 +0,0 @@
|
|||||||
/* Copyright 2015 Samsung Electronics Co., Ltd.
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "ecma-compressed-pointers.h"
|
|
||||||
|
|
||||||
#ifndef ECMA_MANAGED_POINTER_H
|
|
||||||
#define ECMA_MANAGED_POINTER_H
|
|
||||||
|
|
||||||
/** \addtogroup ecma ECMA
|
|
||||||
* @{
|
|
||||||
*
|
|
||||||
* \addtogroup ecmamanagedpointers ECMA managed on-stack pointers
|
|
||||||
* @{
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Untyped (generic) managed pointer
|
|
||||||
*/
|
|
||||||
class ecma_generic_ptr_t
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
/* Constructors */
|
|
||||||
__attribute_always_inline__
|
|
||||||
ecma_generic_ptr_t () : _ptr (NULL) {}
|
|
||||||
|
|
||||||
ecma_generic_ptr_t (const ecma_generic_ptr_t&) = delete;
|
|
||||||
ecma_generic_ptr_t (ecma_generic_ptr_t&) = delete;
|
|
||||||
ecma_generic_ptr_t (ecma_generic_ptr_t&&) = delete;
|
|
||||||
|
|
||||||
/* Getter */
|
|
||||||
template<typename T>
|
|
||||||
operator T () const
|
|
||||||
{
|
|
||||||
return static_cast<T> (_ptr);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Assignment operators */
|
|
||||||
__attribute_always_inline__
|
|
||||||
ecma_generic_ptr_t& operator = (void* ptr) /**< new pointer value */
|
|
||||||
{
|
|
||||||
_ptr = ptr;
|
|
||||||
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
|
|
||||||
__attribute_always_inline__
|
|
||||||
ecma_generic_ptr_t& operator = (const ecma_generic_ptr_t& ptr) /**< managed pointer
|
|
||||||
* to take value from */
|
|
||||||
{
|
|
||||||
_ptr = ptr._ptr;
|
|
||||||
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
|
|
||||||
ecma_generic_ptr_t& operator = (ecma_generic_ptr_t &) = delete;
|
|
||||||
ecma_generic_ptr_t& operator = (ecma_generic_ptr_t &&) = delete;
|
|
||||||
|
|
||||||
/* Packing to compressed pointer */
|
|
||||||
__attribute_always_inline__
|
|
||||||
void pack_to (uintptr_t& compressed_pointer) const /**< reference to compressed pointer */
|
|
||||||
{
|
|
||||||
ECMA_SET_NON_NULL_POINTER (compressed_pointer, _ptr);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Unpacking from compressed pointer */
|
|
||||||
__attribute_always_inline__
|
|
||||||
void unpack_from (uintptr_t compressed_pointer) /**< compressed pointer */
|
|
||||||
{
|
|
||||||
*this = ECMA_GET_NON_NULL_POINTER (void, compressed_pointer);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected: /* accessible to ecma_pointer_t */
|
|
||||||
void *_ptr; /* pointer storage */
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Typed interface to ecma_generic_ptr_t
|
|
||||||
*/
|
|
||||||
template <class T>
|
|
||||||
class ecma_pointer_t : protected ecma_generic_ptr_t
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
/* Member access */
|
|
||||||
__attribute_always_inline__
|
|
||||||
T* operator -> () const
|
|
||||||
{
|
|
||||||
return _ptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Dereference */
|
|
||||||
__attribute_always_inline__
|
|
||||||
T operator * () const
|
|
||||||
{
|
|
||||||
return *_ptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Assignment operators */
|
|
||||||
__attribute_always_inline__
|
|
||||||
ecma_generic_ptr_t& operator = (T* ptr) /**< new pointer value */
|
|
||||||
{
|
|
||||||
_ptr = ptr;
|
|
||||||
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
|
|
||||||
__attribute_always_inline__
|
|
||||||
ecma_pointer_t<T>& operator = (const T& value) /**< value to assign to variable
|
|
||||||
* under the pointer */
|
|
||||||
{
|
|
||||||
*_ptr = value;
|
|
||||||
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @}
|
|
||||||
* @}
|
|
||||||
*/
|
|
||||||
|
|
||||||
#endif /* !ECMA_MANAGED_POINTER_H */
|
|
||||||
@@ -15,7 +15,6 @@
|
|||||||
|
|
||||||
#include "ecma-compressed-pointers.h"
|
#include "ecma-compressed-pointers.h"
|
||||||
#include "ecma-globals.h"
|
#include "ecma-globals.h"
|
||||||
#include "ecma-managed-pointer.h"
|
|
||||||
#include "jrt-bit-fields.h"
|
#include "jrt-bit-fields.h"
|
||||||
|
|
||||||
#ifndef ECMA_VALUE_H
|
#ifndef ECMA_VALUE_H
|
||||||
@@ -113,7 +112,7 @@ class ecma_value_t
|
|||||||
|| _type == ECMA_TYPE_STRING
|
|| _type == ECMA_TYPE_STRING
|
||||||
|| _type == ECMA_TYPE_OBJECT);
|
|| _type == ECMA_TYPE_OBJECT);
|
||||||
|
|
||||||
_value_p.pack_to (value);
|
ECMA_SET_NON_NULL_POINTER (value, _value_p);
|
||||||
}
|
}
|
||||||
|
|
||||||
return pack (_type, value);
|
return pack (_type, value);
|
||||||
@@ -179,7 +178,7 @@ class ecma_value_t
|
|||||||
|| _type == ECMA_TYPE_STRING
|
|| _type == ECMA_TYPE_STRING
|
||||||
|| _type == ECMA_TYPE_OBJECT);
|
|| _type == ECMA_TYPE_OBJECT);
|
||||||
|
|
||||||
_value_p.unpack_from (value);
|
_value_p = ECMA_GET_NON_NULL_POINTER (void, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
return *this;
|
return *this;
|
||||||
@@ -325,7 +324,7 @@ class ecma_value_t
|
|||||||
union
|
union
|
||||||
{
|
{
|
||||||
ecma_simple_value_t _simple_value;
|
ecma_simple_value_t _simple_value;
|
||||||
ecma_generic_ptr_t _value_p;
|
void* _value_p;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user