[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Gnash-commit] /srv/bzr/gnash/avm2 r9572: Read a function's maximum numb
From: |
Tom Stellard |
Subject: |
[Gnash-commit] /srv/bzr/gnash/avm2 r9572: Read a function's maximum number of registers, and use it to initialize Machine::mRegisters. |
Date: |
Sun, 28 Sep 2008 14:37:27 +0800 |
User-agent: |
Bazaar (1.5) |
------------------------------------------------------------
revno: 9572
committer: Tom Stellard <address@hidden>
branch nick: gnash_dev
timestamp: Sun 2008-09-28 14:37:27 +0800
message:
Read a function's maximum number of registers, and use it to initialize
Machine::mRegisters.
modified:
libcore/abc_function.cpp
libcore/asClass.h
libcore/parser/abc_block.cpp
libcore/vm/Machine.cpp
libcore/vm/Machine.h
=== modified file 'libcore/abc_function.cpp'
--- a/libcore/abc_function.cpp 2008-08-31 00:41:54 +0000
+++ b/libcore/abc_function.cpp 2008-09-28 06:37:27 +0000
@@ -32,7 +32,7 @@
abc_function::operator()(const fn_call& fn)
{
log_debug("Calling an abc_function id=%u.",mMethodInfo->mMethodID);
- as_value val = mMachine->executeFunction(mMethodInfo->getBody(),fn);
+ as_value val =
mMachine->executeFunction(mMethodInfo->getBody(),mMethodInfo->getMaxRegisters(),fn);
log_debug("Done calling abc_function id=%u
value=%s",mMethodInfo->mMethodID,val.toDebugString());
return val;
=== modified file 'libcore/asClass.h'
--- a/libcore/asClass.h 2008-08-31 00:41:54 +0000
+++ b/libcore/asClass.h 2008-09-28 06:37:27 +0000
@@ -351,11 +351,15 @@
as_function *mImplementation;
unsigned char mFlags;
CodeStream *mBody;
-
+ boost::uint32_t mMaxRegisters;
bool addBinding(string_table::key name, asBinding b);
public:
+ boost::uint32_t getMaxRegisters(){ return mMaxRegisters;}
+
+ void setMaxRegisters(boost::uint32_t maxRegisters){ mMaxRegisters =
maxRegisters;}
+
boost::uint32_t mMethodID;
boost::uint32_t getBodyLength(){ return mBodyLength;}
=== modified file 'libcore/parser/abc_block.cpp'
--- a/libcore/parser/abc_block.cpp 2008-09-11 19:04:58 +0000
+++ b/libcore/parser/abc_block.cpp 2008-09-28 06:37:27 +0000
@@ -1093,7 +1093,7 @@
// Maximum stack size.
mS->skip_V32();
// Maximum register size.
- mS->skip_V32();
+ mMethods[moffset]->setMaxRegisters(mS->read_V32());
// Scope depth.
mS->skip_V32();
// Max scope depth.
=== modified file 'libcore/vm/Machine.cpp'
--- a/libcore/vm/Machine.cpp 2008-09-13 18:31:43 +0000
+++ b/libcore/vm/Machine.cpp 2008-09-28 06:37:27 +0000
@@ -2609,7 +2609,7 @@
asClass* start_script = pool_block->mScripts.back();
log_debug("Getting constructor.");
asMethod* method = start_script->getConstructor();
-
+ clearRegisters(method->getMaxRegisters());
// mRegisters.push(global);
int i;
for(i=0;i<start_script->mTraits.size();i++){
@@ -2629,11 +2629,11 @@
//This is called by abc_functions to execute their code stream.
//TODO: There is probably a better way to do this, once we understand what the
VM is supposed
//todo, this should be fixed.
-as_value Machine::executeFunction(CodeStream* stream,const fn_call& fn){
+as_value Machine::executeFunction(CodeStream* stream, boost::uint32_t
maxRegisters, const fn_call& fn){
//TODO: Figure out a good way to use the State object to handle returning
values.
bool prev_ext = mExitWithReturn;
- load_function(stream);
+ load_function(stream, maxRegisters);
mExitWithReturn = true;
mRegisters[0] = as_value(fn.this_ptr);
for(unsigned int i=0;i<fn.nargs;i++){
@@ -2655,7 +2655,7 @@
void Machine::instantiateClass(std::string className, as_object* global){
asClass* theClass = mPoolObject->locateClass(className);
- clearRegisters();
+ clearRegisters(theClass->getConstructor()->getMaxRegisters());
mStack.clear();
mScopeStack.clear();
mRegisters[0] = as_value(global);
@@ -2667,7 +2667,7 @@
mCH = vm.getClassHierarchy();
//Local registers should be initialized at the beginning of each
function call, but
//we don't currently parse the number of local registers for each
function.
- mRegisters.resize(16);
+// mRegisters.resize(16);
// mST = new string_table();
// mST = ST;
}
@@ -2764,10 +2764,10 @@
return args;
}
-void Machine::load_function(CodeStream* stream){
+void Machine::load_function(CodeStream* stream,boost::uint32_t maxRegisters){
saveState();
mStream = stream;
- clearRegisters();
+ clearRegisters(maxRegisters);
}
as_environment::ScopeStack* Machine::getScopeStack(){
@@ -2779,10 +2779,10 @@
}
void
-Machine::clearRegisters(){
+Machine::clearRegisters(boost::uint32_t maxRegisters){
mRegisters.clear();
- //TODO: Parse and use maximum stack size value for methods.
- mRegisters.resize(16);
+
+ mRegisters.resize(maxRegisters);
}
=== modified file 'libcore/vm/Machine.h'
--- a/libcore/vm/Machine.h 2008-09-13 10:30:51 +0000
+++ b/libcore/vm/Machine.h 2008-09-28 06:37:27 +0000
@@ -207,7 +207,7 @@
void initMachine(abc_block* pool_block,as_object* global);
- as_value executeFunction(CodeStream* stream,const fn_call& fn);
+ as_value executeFunction(CodeStream* stream, boost::uint32_t
maxRegisters, const fn_call& fn);
void instantiateClass(std::string className, as_object* global);
@@ -265,13 +265,13 @@
std::auto_ptr< std::vector<as_value> > get_args(unsigned int argc);
- void load_function(CodeStream* stream);
+ void load_function(CodeStream* stream, boost::uint32_t maxRegisters);
as_environment::ScopeStack* getScopeStack();
void executeCodeblock(CodeStream* stream);
- void clearRegisters();
+ void clearRegisters(boost::uint32_t maxRegsiters);
as_value get_register(int index){
LOG_DEBUG_AVM("Getting value at a register %d ",index);
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Gnash-commit] /srv/bzr/gnash/avm2 r9572: Read a function's maximum number of registers, and use it to initialize Machine::mRegisters.,
Tom Stellard <=