Skip to content

Commit

Permalink
Fixed building on Mac OS X by recognizing i386 and friends as IA-32 p…
Browse files Browse the repository at this point in the history
…latforms.

Added propagation of stack overflow exceptions that occur while compiling nested functions.

Improved debugger with support for recursive break points and handling of exceptions that occur in the debugger JavaScript code.

Renamed GetInternal to GetInternalField and SetInternal to SetInternalField in the API and moved InternalFieldCount and SetInternalFieldCount from FunctionTemplate to ObjectTemplate.
  • Loading branch information
kasper.lund committed Jul 16, 2008
1 parent d6288fa commit f9a058f
Show file tree
Hide file tree
Showing 15 changed files with 257 additions and 171 deletions.
16 changes: 16 additions & 0 deletions ChangeLog
@@ -1,3 +1,19 @@
2008-07-16: Version 0.1.2 (127441)

Fixed building on Mac OS X by recognizing i386 and friends as
IA-32 platforms.

Added propagation of stack overflow exceptions that occur while
compiling nested functions.

Improved debugger with support for recursive break points and
handling of exceptions that occur in the debugger JavaScript code.

Renamed GetInternal to GetInternalField and SetInternal to
SetInternalField in the API and moved InternalFieldCount and
SetInternalFieldCount from FunctionTemplate to ObjectTemplate.


2008-07-09: Version 0.1.1 (126448)

Fixed bug in stack overflow check code for IA-32 targets where a
Expand Down
10 changes: 5 additions & 5 deletions SConstruct
Expand Up @@ -26,6 +26,7 @@
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

import platform
import re
import sys
from os.path import join, dirname, abspath
root_dir = dirname(File('SConstruct').rfile().abspath)
Expand All @@ -47,17 +48,17 @@ def GuessOS():
elif id == 'Windows':
return 'win32'
else:
Abort("Don't know how to build v8 for OS '%s'." % id)
return '<none>'


def GuessProcessor():
id = platform.machine()
if id.startswith('arm'):
return 'arm'
elif (not id) or id.startswith('x86'):
elif (not id) or (not re.match('(x|i[3-6])86', id) is None):
return 'ia32'
else:
Abort("Don't know how to build v8 for processor '%s'." % id)
return '<none>'


def GuessToolchain(os):
Expand All @@ -70,8 +71,7 @@ def GuessToolchain(os):
elif 'msvc' in tools:
return 'msvc'
else:
tools = ', '.join(tools)
Abort("Don't know how to build v8 using these tools: %s" % tools)
return '<none>'


def GetOptions():
Expand Down
27 changes: 18 additions & 9 deletions public/v8.h
Expand Up @@ -905,10 +905,12 @@ class Object : public Value {
*/
Local<String> ObjectProtoToString();

// TODO(1245384): Naming, consistent.
/** Gets the number of internal fields for this Object. */
int InternalFieldCount();
Local<Value> GetInternal(int index);
void SetInternal(int index, Handle<Value> value);
/** Gets the value in an internal field. */
Local<Value> GetInternalField(int index);
/** Sets the value in an internal field. */
void SetInternalField(int index, Handle<Value> value);

// Testers for local properties.
bool HasRealNamedProperty(Handle<String> key);
Expand All @@ -924,7 +926,7 @@ class Object : public Value {
/** Tests for a named lookup interceptor.*/
bool HasNamedLookupInterceptor();

/** Tests for an index lookup interceptor.*/
/** Tests for an index lookup interceptor.*/
bool HasIndexedLookupInterceptor();


Expand Down Expand Up @@ -1282,11 +1284,6 @@ class FunctionTemplate : public Template {
*/
Local<ObjectTemplate> PrototypeTemplate();

int InternalFieldCount();

/** Sets the number of internal fields on the object template.*/
void SetInternalFieldCount(int value);

void SetClassName(Handle<String> name);

/**
Expand Down Expand Up @@ -1406,6 +1403,18 @@ class ObjectTemplate : public Template {
IndexedSecurityCallback indexed_handler,
Handle<Value> data = Handle<Value>());

/**
* Gets the number of internal fields for objects generated from
* this template.
*/
int InternalFieldCount();

/**
* Sets the number of internal fields for objects generated from
* this template.
*/
void SetInternalFieldCount(int value);

private:
ObjectTemplate();
static Local<ObjectTemplate> New(Handle<FunctionTemplate> constructor);
Expand Down
199 changes: 101 additions & 98 deletions src/api.cc
Expand Up @@ -559,14 +559,6 @@ static void InitializeFunctionTemplate(
}


int FunctionTemplate::InternalFieldCount() {
if (IsDeadCheck("v8::FunctionTemplate::InternalFieldCount()")) {
return 0;
}
return i::Smi::cast(Utils::OpenHandle(this)->internal_field_count())->value();
}


Local<ObjectTemplate> FunctionTemplate::PrototypeTemplate() {
if (IsDeadCheck("v8::FunctionTemplate::PrototypeTemplate()")) {
return Local<ObjectTemplate>();
Expand All @@ -586,17 +578,6 @@ void FunctionTemplate::Inherit(v8::Handle<FunctionTemplate> value) {
}


void FunctionTemplate::SetInternalFieldCount(int value) {
if (IsDeadCheck("v8::FunctionTemplate::SetInternalFieldCount()")) return;
if (!ApiCheck(i::Smi::IsValid(value),
"v8::FunctionTemplate::SetInternalFieldCount()",
"Invalid internal field count")) {
return;
}
Utils::OpenHandle(this)->set_internal_field_count(i::Smi::FromInt(value));
}


// To distinguish the function templates, so that we can find them in the
// function cache of the global context.
static int next_serial_number = 0;
Expand All @@ -612,7 +593,6 @@ Local<FunctionTemplate> FunctionTemplate::New(InvocationCallback callback,
i::Handle<i::FunctionTemplateInfo>::cast(struct_obj);
InitializeFunctionTemplate(obj);
obj->set_serial_number(i::Smi::FromInt(next_serial_number++));
obj->set_internal_field_count(i::Smi::FromInt(0));
if (callback != 0) {
if (data.IsEmpty()) data = v8::Undefined();
Utils::ToLocal(obj)->SetCallHandler(callback, data);
Expand Down Expand Up @@ -750,6 +730,89 @@ Local<ObjectTemplate> FunctionTemplate::InstanceTemplate() {
}


void FunctionTemplate::SetClassName(Handle<String> name) {
if (IsDeadCheck("v8::FunctionTemplate::SetClassName()")) return;
Utils::OpenHandle(this)->set_class_name(*Utils::OpenHandle(*name));
}


void FunctionTemplate::SetHiddenPrototype(bool value) {
if (IsDeadCheck("v8::FunctionTemplate::SetHiddenPrototype()")) return;
Utils::OpenHandle(this)->set_hidden_prototype(value);
}


void FunctionTemplate::SetNamedInstancePropertyHandler(
NamedPropertyGetter getter,
NamedPropertySetter setter,
NamedPropertyQuery query,
NamedPropertyDeleter remover,
NamedPropertyEnumerator enumerator,
Handle<Value> data) {
if (IsDeadCheck("v8::FunctionTemplate::SetNamedInstancePropertyHandler()")) {
return;
}
HandleScope scope;
i::Handle<i::Struct> struct_obj =
i::Factory::NewStruct(i::INTERCEPTOR_INFO_TYPE);
i::Handle<i::InterceptorInfo> obj =
i::Handle<i::InterceptorInfo>::cast(struct_obj);
if (getter != 0) obj->set_getter(*FromCData(getter));
if (setter != 0) obj->set_setter(*FromCData(setter));
if (query != 0) obj->set_query(*FromCData(query));
if (remover != 0) obj->set_deleter(*FromCData(remover));
if (enumerator != 0) obj->set_enumerator(*FromCData(enumerator));
if (data.IsEmpty()) data = v8::Undefined();
obj->set_data(*Utils::OpenHandle(*data));
Utils::OpenHandle(this)->set_named_property_handler(*obj);
}


void FunctionTemplate::SetIndexedInstancePropertyHandler(
IndexedPropertyGetter getter,
IndexedPropertySetter setter,
IndexedPropertyQuery query,
IndexedPropertyDeleter remover,
IndexedPropertyEnumerator enumerator,
Handle<Value> data) {
if (IsDeadCheck(
"v8::FunctionTemplate::SetIndexedInstancePropertyHandler()")) {
return;
}
HandleScope scope;
i::Handle<i::Struct> struct_obj =
i::Factory::NewStruct(i::INTERCEPTOR_INFO_TYPE);
i::Handle<i::InterceptorInfo> obj =
i::Handle<i::InterceptorInfo>::cast(struct_obj);
if (getter != 0) obj->set_getter(*FromCData(getter));
if (setter != 0) obj->set_setter(*FromCData(setter));
if (query != 0) obj->set_query(*FromCData(query));
if (remover != 0) obj->set_deleter(*FromCData(remover));
if (enumerator != 0) obj->set_enumerator(*FromCData(enumerator));
if (data.IsEmpty()) data = v8::Undefined();
obj->set_data(*Utils::OpenHandle(*data));
Utils::OpenHandle(this)->set_indexed_property_handler(*obj);
}


void FunctionTemplate::SetInstanceCallAsFunctionHandler(
InvocationCallback callback,
Handle<Value> data) {
if (IsDeadCheck("v8::FunctionTemplate::SetInstanceCallAsFunctionHandler()")) {
return;
}
HandleScope scope;
i::Handle<i::Struct> struct_obj =
i::Factory::NewStruct(i::CALL_HANDLER_INFO_TYPE);
i::Handle<i::CallHandlerInfo> obj =
i::Handle<i::CallHandlerInfo>::cast(struct_obj);
obj->set_callback(*FromCData(callback));
if (data.IsEmpty()) data = v8::Undefined();
obj->set_data(*Utils::OpenHandle(*data));
Utils::OpenHandle(this)->set_instance_call_handler(*obj);
}


// --- O b j e c t T e m p l a t e ---


Expand All @@ -770,6 +833,7 @@ Local<ObjectTemplate> ObjectTemplate::New(
InitializeTemplate(obj, Consts::OBJECT_TEMPLATE);
if (!constructor.IsEmpty())
obj->set_constructor(*Utils::OpenHandle(*constructor));
obj->set_internal_field_count(i::Smi::FromInt(0));
return Utils::ToLocal(obj);
}

Expand Down Expand Up @@ -898,87 +962,26 @@ void ObjectTemplate::SetCallAsFunctionHandler(InvocationCallback callback,
}


void FunctionTemplate::SetClassName(Handle<String> name) {
if (IsDeadCheck("v8::FunctionTemplate::SetClassName()")) return;
Utils::OpenHandle(this)->set_class_name(*Utils::OpenHandle(*name));
}


void FunctionTemplate::SetHiddenPrototype(bool value) {
if (IsDeadCheck("v8::FunctionTemplate::SetHiddenPrototype()")) return;
Utils::OpenHandle(this)->set_hidden_prototype(value);
}


void FunctionTemplate::SetNamedInstancePropertyHandler(
NamedPropertyGetter getter,
NamedPropertySetter setter,
NamedPropertyQuery query,
NamedPropertyDeleter remover,
NamedPropertyEnumerator enumerator,
Handle<Value> data) {
if (IsDeadCheck("v8::FunctionTemplate::SetNamedInstancePropertyHandler()")) {
return;
int ObjectTemplate::InternalFieldCount() {
if (IsDeadCheck("v8::ObjectTemplate::InternalFieldCount()")) {
return 0;
}
HandleScope scope;
i::Handle<i::Struct> struct_obj =
i::Factory::NewStruct(i::INTERCEPTOR_INFO_TYPE);
i::Handle<i::InterceptorInfo> obj =
i::Handle<i::InterceptorInfo>::cast(struct_obj);
if (getter != 0) obj->set_getter(*FromCData(getter));
if (setter != 0) obj->set_setter(*FromCData(setter));
if (query != 0) obj->set_query(*FromCData(query));
if (remover != 0) obj->set_deleter(*FromCData(remover));
if (enumerator != 0) obj->set_enumerator(*FromCData(enumerator));
if (data.IsEmpty()) data = v8::Undefined();
obj->set_data(*Utils::OpenHandle(*data));
Utils::OpenHandle(this)->set_named_property_handler(*obj);
return i::Smi::cast(Utils::OpenHandle(this)->internal_field_count())->value();
}


void FunctionTemplate::SetIndexedInstancePropertyHandler(
IndexedPropertyGetter getter,
IndexedPropertySetter setter,
IndexedPropertyQuery query,
IndexedPropertyDeleter remover,
IndexedPropertyEnumerator enumerator,
Handle<Value> data) {
if (IsDeadCheck(
"v8::FunctionTemplate::SetIndexedInstancePropertyHandler()")) {
void ObjectTemplate::SetInternalFieldCount(int value) {
if (IsDeadCheck("v8::ObjectTemplate::SetInternalFieldCount()")) return;
if (!ApiCheck(i::Smi::IsValid(value),
"v8::ObjectTemplate::SetInternalFieldCount()",
"Invalid internal field count")) {
return;
}
HandleScope scope;
i::Handle<i::Struct> struct_obj =
i::Factory::NewStruct(i::INTERCEPTOR_INFO_TYPE);
i::Handle<i::InterceptorInfo> obj =
i::Handle<i::InterceptorInfo>::cast(struct_obj);
if (getter != 0) obj->set_getter(*FromCData(getter));
if (setter != 0) obj->set_setter(*FromCData(setter));
if (query != 0) obj->set_query(*FromCData(query));
if (remover != 0) obj->set_deleter(*FromCData(remover));
if (enumerator != 0) obj->set_enumerator(*FromCData(enumerator));
if (data.IsEmpty()) data = v8::Undefined();
obj->set_data(*Utils::OpenHandle(*data));
Utils::OpenHandle(this)->set_indexed_property_handler(*obj);
Utils::OpenHandle(this)->set_internal_field_count(i::Smi::FromInt(value));
}


void FunctionTemplate::SetInstanceCallAsFunctionHandler(
InvocationCallback callback,
Handle<Value> data) {
if (IsDeadCheck("v8::FunctionTemplate::SetInstanceCallAsFunctionHandler()")) {
return;
}
HandleScope scope;
i::Handle<i::Struct> struct_obj =
i::Factory::NewStruct(i::CALL_HANDLER_INFO_TYPE);
i::Handle<i::CallHandlerInfo> obj =
i::Handle<i::CallHandlerInfo>::cast(struct_obj);
obj->set_callback(*FromCData(callback));
if (data.IsEmpty()) data = v8::Undefined();
obj->set_data(*Utils::OpenHandle(*data));
Utils::OpenHandle(this)->set_instance_call_handler(*obj);
}
// --- S c r i p t D a t a ---


ScriptData* ScriptData::PreCompile(const char* input, int length) {
Expand Down Expand Up @@ -2041,11 +2044,11 @@ int v8::Object::InternalFieldCount() {
}


Local<Value> v8::Object::GetInternal(int index) {
if (IsDeadCheck("v8::Object::GetInternal()")) return Local<Value>();
Local<Value> v8::Object::GetInternalField(int index) {
if (IsDeadCheck("v8::Object::GetInternalField()")) return Local<Value>();
i::Handle<i::JSObject> obj = Utils::OpenHandle(this);
if (!ApiCheck(index < obj->GetInternalFieldCount(),
"v8::Object::GetInternal()",
"v8::Object::GetInternalField()",
"Reading internal field out of bounds")) {
return Local<Value>();
}
Expand All @@ -2054,11 +2057,11 @@ Local<Value> v8::Object::GetInternal(int index) {
}


void v8::Object::SetInternal(int index, v8::Handle<Value> value) {
if (IsDeadCheck("v8::Object::SetInternal()")) return;
void v8::Object::SetInternalField(int index, v8::Handle<Value> value) {
if (IsDeadCheck("v8::Object::SetInternalField()")) return;
i::Handle<i::JSObject> obj = Utils::OpenHandle(this);
if (!ApiCheck(index < obj->GetInternalFieldCount(),
"v8::Object::SetInternal()",
"v8::Object::SetInternalField()",
"Writing internal field out of bounds")) {
return;
}
Expand Down
6 changes: 6 additions & 0 deletions src/ast.h
Expand Up @@ -1217,6 +1217,12 @@ class Visitor BASE_EMBEDDED {
return (stack_overflow_ = true);
}

// If a stack-overflow exception is encountered when visiting a
// node, calling SetStackOverflow will make sure that the visitor
// bails out without visiting more nodes.
void SetStackOverflow() { stack_overflow_ = true; }


// Individual nodes
#define DEF_VISIT(type) \
virtual void Visit##type(type* node) = 0;
Expand Down

0 comments on commit f9a058f

Please sign in to comment.