Archive for October, 2007

Web hosting company - c. Classes C and E are local to

Wednesday, October 31st, 2007

c. Classes C and E are local to this module, and cannot be extended elsewhere; the other classes may be extended. . *14.4 Use method replication to improve your analysis of the program in Exercise 14.3. That is, make every class override f and g. For example, in class B (which does not already override f), put a copy of method A_f, and in D put acopyof C_F: class B extends A { … int f() { return 1; } } class D extends C { … int f() { this.g(); return 3; } } Similarly, add new instances E_f, F_f, and C_g. Now, for each set of assumptions (a), (b), and (c), show which method calls go to known static instances. . **14.5 Devise an efficient implementation mechanism for any typecase that only mentions final classes. A final class is one that cannot be extended. (In Java, there is a final keyword; but even in other object-oriented languages, a class that is not exported from a module is effectively final, and a link-time whole-program analysis can discover which classes are never extended, whether declared final or not.) You may make any of the following assumptions, but state which assumptions you need to use: a. The linker has control over the placement of class-descriptor records. b. Class descriptors are integers managed by the linker that index into a table of descriptor records. c. The compiler explicitly marks final classes (in their descriptors). d. Code for typecase can be generated at link time. e. After the program is running, no other classes and subclasses are dynamically linked into the program. Team-Fly Team-Fly Chapter 15: Functional Programming Languages func-tion: a mathematical correspondence that assigns exactly one element of one set to each element of the same or another set Webster’s Dictionary OVERVIEW
Note: In case you are looking for affordable and reliable webhost to host and run your j2ee application check Vision J2ee Web Hosting services.

Web hosting isp - Chambers et al. [1991] describe several techniques to

Wednesday, October 31st, 2007

Chambers et al. [1991] describe several techniques to make classless, dynamically typed languages perform efficiently: pseudo-class descriptors, multiple versions of method instances, and other optimizations. Diwan et al. [1996] describe optimizations for statically typed languages that can replace dynamic method calls by static function calls. Conventional object-oriented languages choose a method instance for a call a.f(x,y) based only on the class of the method receiver (a) and not other arguments (x,y). Languages with multimethods [Bobrow et al. 1989] allow dynamic method lookup based on the types of all arguments. This would solve the problem of orthogonal directions of modularity discussed on page 93. Chambers and Leavens [1995] show how to do static type-checking for multimethods; Amiel et al. [1994] and Chen and Turau [1994] show how to do efficient dynamic multimethod lookup. Nelson [1991] describes Modula-3, Stroustrup [1997] describes C++, and Arnold and Gosling [1996] describe Java. Team-Fly Team-Fly EXERCISES . *14.1 A problem with the display technique (as explained on page 290) for testing class membership is that the maximum class-nesting depth N must be fixed in advance, and every class descriptor needs N words of space even if most classes are not deeply nested. Design a variant of the display technique that does not suffer from these problems; it will be a couple of instructions more costly than the one described on page 290. . 14.2 The hash-table technique for finding field offsets and method instances in the presence of multiple inheritance is shown incompletely on page 289 - the case of f . ptrx is not resolved. Choose a collision-resolution technique, explain how it works, and analyze the extra cost (in instructions) in the case that f = ptrx(no collision) and f . ptrx (collision). . *14.3 Consider the following class hierarchy, which contains five method-call sites. The task is to show which of the method-call sites call known method instances, and (in each case) show which method instance. For example, you might say that “method-instance X_g always calls Y_f; method Z_g may call more than one instance of f.” classA {intf(){return1;}} class B extends A { int g() { this.f(); return 2; } } class C extends B { int f() { this.g(); return 3; } } class D extends C { int g() { this.f(); return 4; } } class E extends A { int g() { this.f(); return 5; } } class F extends E { int g() { this.f(); return 6; } } Do this analysis for each of the following assumptions: a. This is the entire program, and there are no other subclasses of these modules. b. This is part of a large program, and any of these classes may be extended elsewhere.
Note: If you are looking for cheap and reliable webhost to host and run your mysql application check mysql web server services.

Web hosting asp - For multiple-inheritance and classless languages, the dynamic method-lookup

Wednesday, October 31st, 2007

For multiple-inheritance and classless languages, the dynamic method-lookup cost is even higher. Thus, optimizing compilers for object-oriented languages do global program analysis to determine those places where a method call is always calling the same method instance; then the dynamic method call can be replaced by a static function call. For a method call c.f(), where c is of class C, type hierarchy analysis is used to determine which subclasses of C contain methods f that may override C_f. If there is no such method, then the method instance must be C_f. This idea is combined with type propagation, a form of static dataflow analysis similar to reaching definitions (see Section 17.2). After an assignment c . new C, the exact class of c is known. This information can be propagated through the assignment d . c, and so on. When d.f() is encountered, the type-propagation information limits the range of the type hierarchy that might contribute method instances to d. Suppose a method f defined in class C calls method g on this. But g is a dynamic method and may be overridden, so this call requires a dynamic method lookup. An optimizing compiler may make a different copy of a method instance C_f for each subclass (e.g., D,E) that extends C. Then when the (new copy) D_f calls g, the compiler knows to call the instance D_g without a dynamic method lookup. Team-Fly Team-Fly PROGRAM MiniJava WITH CLASS EXTENSION Implement class extension in your MiniJava compiler. Team-Fly Team-Fly FURTHER READING Dahl and Nygaard’s Simula-67 language [Birtwistle et al. 1973] introduced the notion of classes, objects, single inheritance, static methods, instance testing, typecase, and the prefix technique to implement static single inheritance. In addition it had coroutines and garbage collection. Cohen [1991] suggested the display for constant-time testing of class membership. Dynamic methods and multiple inheritance appeared in Smalltalk [Goldberg et al. 1983], but the first implementations used slow searches of parent classes to find method instances. Rose [1988] and Connor et al. [1989] discuss fast hash-based field-and method-access algorithms for multiple inheritance. The use of graph coloring in implementing multiple inheritance is due to Dixon et al. [1989]. Lippman [1996] shows how C++-style multiple inheritance is implemented.
In case you need quality webspace to host and run your web applications, try our personal web hosting services.

Team-Fly Team-Fly 14.6 CLASSLESS LANGUAGES (Web site directory) Some object-oriented languages

Tuesday, October 30th, 2007

Team-Fly Team-Fly 14.6 CLASSLESS LANGUAGES Some object-oriented languages do not use the notion of class at all. In such a language, each object implements whatever methods and has whatever data fields it wants. Type-checking for such languages is usually dynamic (done at run time) instead of static (done at compile time). Many objects are created by cloning: copying an existing object (or template object) and then modifying some of the fields. Thus, even in a classless language there will be groups (”pseudoclasses”) of similar objects that can share descriptors. When b is created by cloning a, it can share a descriptor with a. Only if a new field is added or a method field is updated (overridden) does b require a new descriptor. The techniques used in compiling classless languages are similar to those for class-based languages with multiple inheritance and dynamic linking: Pseudo-class descriptors contain hash tables that yield field offsets and method instances. The same kinds of global program analysis and optimization that are used for class-based languages -finding which method instance will be called from a (dynamic) method call site -are just as useful for classless languages. Team-Fly Team-Fly 14.7 OPTIMIZING OBJECT-ORIENTED PROGRAMS An optimization of particular importance to object-oriented languages (which also benefit from most optimizations that apply to programming languages in general) is the conversion of dynamic method calls to static method-instance calls. Compared with an ordinary function call, at each method call site there is a dynamic method lookup to determine the method instance. For single-inheritance languages, method lookup takes only two instructions. This seems like a small cost, but: . Modern machines can jump to constant addresses more efficiently than to addresses fetched from tables. When the address is manifest in the instruction stream, the processor is able to pre-fetch the instruction cache at the destination and direct the instruction-issue mechanism to fetch at the target of the jump. Unpredictable jumps stall the instruction-issue and -execution pipeline for several cycles. . An optimizing compiler that does inline expansion or interprocedural analysis will have trouble analyzing the consequences of a call if it doesn’t even know which method instance is called at a given site.
We highly recommend you visit web and email hosting services if you need stable and cheap web hosting platform for your web applications.

Zeus web server - is compiled as follows: First a range-check comparison

Tuesday, October 30th, 2007

is compiled as follows: First a range-check comparison is made to ensure that i is within the range of case labels (0-4, in this case); then the address of the ith statement is fetched from the ith slot of a table, and control jumps to si. This approach will not work for typecase, because of subclassing. That is, even if we could make class descriptors be small integers instead of pointers, we cannot do an indexed jump based on the class of the object, because we will miss clauses that match superclasses of that class. Thus, Modula3 typecase is implemented as a chain of else-ifs. Assigning integers to classes is not trivial, because separately compiled modules can each define their own classes, and we do not want the integers to clash. But a sophisticated linker might be able to assign the integers at link time. If all the classes in the typecase were final classes (in the sense used by Java, that they cannot be extended), then this problem would not apply. Modula-3 does not have final classes; and Java does not have typecase. But a clever Java system might be able to recognize a chain of else-ifs that do instanceof tests for a set of final classes, and generate a indexed jump. Team-Fly Team-Fly 14.5 PRIVATE FIELDS AND METHODS True object-oriented languages can protect fields of objects from direct manipulation by other objects’ methods. A private field is one that cannot be fetched or updated from any function or method declared outside the object; a private method is one that cannot be called from outside the object. Privacy is enforced by the type-checking phase of the compiler. In the symbol table of C, along with each field offset and method offset, is a boolean flag indicating whether the field is private. When compiling the expression c.f() or c.x, it is a simple matter to check that field and reject accesses to private fields from any method outside the object declaration. There are many varieties of privacy and protection. Different languages allow . Fields and methods which are accessible only to the class that declares them. . Fields and methods accessible to the declaring class, and to any subclasses of that class. . Fields and methods accessible only within the same module (package, namespace) as the declaring class. . Fields that are read-only from outside the declaring class, but writable by methods of the class. In general, these varieties of protection can be statically enforced by compiletime type-checking, for class-based languages.
We would like to recommend you tested and proved virtual web hosting services, which you will surely find to be of great quality.

Web hosting support - IF ISTYPE(b,C) if (b instanceof C) THEN f(NARROW(b,C))

Monday, October 29th, 2007

IF ISTYPE(b,C) if (b instanceof C) THEN f(NARROW(b,C)) f((C)b) ELSE … else … Now there are two consecutive, identical type tests: one explicit (ISTYPE or instanceof) and one implicit (in NARROW or the cast). A good compiler will do enough flow analysis to notice that the then-clause is reached only if b is in fact an instance of C, so that the type-check in the narrowing operation can be eliminated. C++ is an unsafe object-oriented language. It has a static cast mechanism without run-time checking; careless use of this mechanism can make the program “go wrong” in unpredictable ways. C++ also has dynamic_cast with run-time checking, which is like the mechanisms in Modula-3 and Java. Typecase Explicit instanceof testing, followed by a narrowing cast to a subclass, is not a wholesome “object-oriented” style. Instead of using this idiom, programmers are expected to use dynamic methods that accomplish the right thing in each subclass. Nevertheless, the test-then-narrow idiom is fairly common. Modula-3 has a typecase facility that makes the idiom more beautiful and efficient (but not any more “object-oriented”): TYPECASE expr OF C1(v1) => S1 | C2(v2) => S2 | Cn (vn) => Sn ELSE S0 END If the expr evaluates to an instance of class Ci, then a new variable vi of type Ci points to the result of the expr, and statement Si is executed. The declaration of vi is implicit in the TYPECASE, and its scope covers only Si. If more than one of the Ci match (which can happen if, for example, one is a superclass of another), then only the first matching clause is taken. If none of the Ci match, then the ELSE clause is taken (statement S0 is executed). Typecase can be converted straightforwardly to a chain of else-ifs, with each if doing an instance test, a narrowing, and a local variable declaration. However, if there are very many clauses, then it can take a long time to go through all the else-ifs. Therefore it is attractive to treat it like a case (switch) statement on integers, using an indexed jump (computed goto). That is, an ordinary case statement on integers: ML: C, Java: case i switch (i) { of 0 => s0 case 0: s0; break; | 1=> s1 case 1: s1; break; | 2=> s2 case 2: s2; break; | 3=> s3 case 3: s3; break; | 4=> s4 case 4: s4; break; |_=> sd default: sd;
You want to have a cheap webhost for your apache application, then check apache web hosting services.

(x,C) instanceof C Given a variable x of (Web site layout)

Monday, October 29th, 2007

(x,C) instanceof C Given a variable x of class C, where x actually points to an object of NARROW (D)x class D that extends C, yield an expression whose compile-time type is (x,D) class D. Since each object points to its class descriptor, the address of the class descriptor can serve as a “type-tag.” However, if x is an instance of D, and D extends C, then x is also an instance of C. Assuming there is no multiple inheritance, a simple way to implement x instanceof C is to generate code that performs the following loop at run time: goto L1 where t1.super is the superclass (parent class) of class t1. However, there is a faster approach using a display of parent classes. Assume that the class nesting depth is limited to some constant, such as 20. Reserve a 20-word block in each class descriptor. In the descriptor for a class D whose nesting depth is j, put a pointer to descriptor D in the jth slot, a pointer to D.super inthe (j - 1)th slot, a pointer to D.super.super in slot j - 2, andsoonupto Object in slot 0. In all slots numbered greater than j, put nil. Now, if x is an instance of D, or of any subclass of D, then the jth slot of x’s class descriptor will point to the class descriptor D. Otherwise it will not. So x instanceof D requires 1. Fetch the class descriptor d at offset 0 from object c. 2. Fetch the jth class-pointer slot from d. 3. Compare with the class descriptor D. This works because the class-nesting depth of D is known at compile time. Type coercions Given a variable c of type C, it is always legal to treat c as any supertype of C -if C extends B, and variable b has type B, then the assignment b . c is legal and safe. But the reverse is not true. The assignment c . b is safe only if b is really (at run time) an instance of C, which is not always the case. If we have b . new B, c . b, followed by fetching some field of c that is part of class C but not class B, then this fetch will lead to unpredictable behavior. Thus, safe object-oriented languages (such as Modula-3 and Java) accompany any coercion from a superclass to a subclass with a run-time type-check that raises an exception unless the run-time value is really an instance of the subclass (e.g., unless b instanceof C). It is a common idiom to write Modula-3: Java:
If you are in need for cheap and reliable webhost to host your website, we recommend http web server services.

field names to offsets and method names to (Simple web server)

Sunday, October 28th, 2007

field names to offsets and method names to method instances. This works well with separate compilation and dynamic linking. The characters of the field names are not hashed at run time. Instead, each field name a is hashed at compile time to an integer hasha in the range [0, N - 1]. Also, for each field name a unique run-time record (pointer) ptra is made. Each class descriptor has a field-offset table Ftab of size N containing field-offsets and method instances, and (for purposes of collision detection) a parallel key table Ktab containing field-name pointers. If the class has a field x, then field-offset-table slot number hashx contains the offset for x, and key-table slot number hashx contains the pointer ptrx . To fetch a field x of object c, the compiler generates code to 1. Fetch the class descriptor d at offset 0 from object c. 2. Fetch the field name f from the address offset d + Ktab + hash . x 3. Test whether f = ptrx; if so 4. Fetch the field offset k from d + Ftab + hash . x 5. Fetch the contents of the field from c + k. This algorithm has four instructions of overhead, which may still be tolerable. A similar algorithm works for dynamic method-instance lookup. The algorithm as described does not say what to do if the test at line 3 fails. Any hash-table collision- resolution technique can be used. [1]Distinct field name does not mean simple equivalence of strings. Each fresh declaration of field or method x (where it is not overriding the x of a parent class) is really a distinct name. Team-Fly Team-Fly 14.4 TESTING CLASS MEMBERSHIP Some object-oriented languages allow the program to test membership of an object in a class at run time, as summarized in Table 14.6. Table 14.6. Facilities for type testing and safe casting. Modula-3 Java x Test whether object x belongs class C, or to any subclass of C. ISTYPE
If you are looking for cheap and quality webhost to host and run your website check Jboss Web Hosting services.

now the “colors” (Web server type) are not the offsets of

Sunday, October 28th, 2007

now the “colors” are not the offsets of those fields within the objects but within the descriptors. To fetch a field a of object x, we fetch the a-word from x’s descriptor; this word contains a small integer telling the position of the actual a data within x. Figure 14.5: Field offsets in descriptors for multiple inheritance. In this scheme, class descriptors have empty slots, but the objects do not; this is acceptable because a system with millions of objects is likely to have only dozens of class descriptors. But each data fetch (or store) requires three instructions instead of one: 1. Fetch the descriptor pointer from the object. 2. Fetch the field-offset value from the descriptor. 3. Fetch (or store) the data at the appropriate offset in the object. In practice, it is likely that other operations on the object will have fetched the descriptor pointer already, and multiple operations on the same field (e.g., fetch then store) won’t need to refetch the offset from the descriptor; commonsubexpression elimination can remove much of this redundant overhead. Method lookup Finding method instances in a language with multiple inheritance is just as complicated as finding field offsets. The global graph-coloring approach works well: The method names can be mixed with the field names to form nodes of a large interference graph. Descriptor entries for fields give locations within the objects; descriptor entries for methods give machine-code addresses of method instances. Problems with dynamic linking Any global approach suffers from the problem that the coloring (and layout of class descriptors) can be done only at link time; the job is certainly within the capability of a special-purpose linker. However, many object-oriented systems have the capability to load new classes into a running system; these classes may be extensions (subclasses) of classes already in use. Link-time graph coloring poses many problems for a system that allows dynamic incremental linking. Hashing Instead of global graph coloring, we can put a hash table in each class descriptor, mapping
Go visit our java server pages services for a reliable, lowcost webhost to satisfy all your needs.

Cpanel web hosting - Figure 14.3: Class descriptors for dynamic method lookup.

Saturday, October 27th, 2007

Figure 14.3: Class descriptors for dynamic method lookup. To solve this problem, the class descriptor must contain a vector with a method instance for each (nonstatic) method name. When class B inherits from A, the method table starts with entries for all method names known to A, and then continues with new methods declared by B. This is very much like the arrangement of fields in objects with inheritance. Figure 14.3 shows what happens when class D overrides method f. Although the entry for f is at the beginning of D’s method table, as it is also at the beginning of the ancestor class A’s method table, it points to a different method-instance label because f has been overridden. To execute c.f(), where f is a dynamic method, the compiled code must execute these instructions: 1. Fetch the class descriptor d at offset 0 from object c. 2. Fetch the method-instance pointer p from the (constant) f offset of d. 3. Jump to address p, saving return address (that is, call p). Team-Fly Team-Fly 14.3 MULTIPLE INHERITANCE In languages that permit a class D to extend several parent classes A, B, C (that is, where A is nota subclass of B, or vice versa), finding field offsets and method instances is more difficult. It is impossible to put all the A fields at the beginning of D and to put all the B fields at the beginning of D. Global graph coloring One solution to this problem is to statically analyze all classes at once, finding some offset for each field name that can be used in every record containing that field. We can model this as a graph-coloring problem: There is a node for each distinct field name, and an edge for any two fields which coexist (perhaps by inheritance) in the same class.[1] The offsets 0, 1, 2; are the colors. Figure 14.4 shows an example. Figure 14.4: Multiple inheritance of data fields. The problem with this approach is that it leaves empty slots in the middle of objects, since it cannot always color the N fields of each class with colors with the first N colors. To eliminate the empty slots in objects, we pack the fields of each object and have the class descriptor tell where each field is. Figure 14.5 shows an example. We have done graph coloring on all the field names, as before, but
From our experience, we can recommend PHP5 Web Hosting services, if you need affordable webhost to host and run your web application.